Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml

require: rubocop-jekyll

inherit_gem:
Expand All @@ -7,19 +9,3 @@ AllCops:
TargetRubyVersion: 2.3
Exclude:
- vendor/**/*

Metrics/BlockLength:
Exclude:
- spec/**/*

Metrics/LineLength:
Exclude:
- spec/**/*

Naming/MemoizedInstanceVariableName:
Exclude:
- lib/jekyll-redirect-from/page_without_a_file.rb

Naming/UncommunicativeMethodParamName:
Exclude:
- lib/jekyll-redirect-from/redirect_page.rb
21 changes: 21 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-10-26 17:43:57 +0200 using RuboCop version 0.60.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Exclude:
- 'lib/jekyll-redirect-from/page_without_a_file.rb'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's point marking this as a TODO.. It can never be "fixed"..
Best we add an inline comment to disable-reenable the cop

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like inline comments, I'd rather keep it here, even if it's not "fixable".


# Offense count: 2
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/UncommunicativeMethodParamName:
Exclude:
- 'lib/jekyll-redirect-from/redirect_page.rb'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be fixed within this PR itself..?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to fix it in a dedicated PR.

2 changes: 1 addition & 1 deletion jekyll-redirect-from.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "jekyll-sitemap", "~> 1.0"
spec.add_development_dependency "rake", "~> 12.0"
spec.add_development_dependency "rspec", "~> 3.5"
spec.add_development_dependency "rubocop-jekyll", "~> 0.1.0"
spec.add_development_dependency "rubocop-jekyll", "~> 0.3"
end
3 changes: 3 additions & 0 deletions lib/jekyll-redirect-from/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def generate(site)
# Must duplicate pages to modify while in loop
(site.docs_to_write + site.pages.dup).each do |doc|
next unless JekyllRedirectFrom::CLASSES.include?(doc.class)

generate_redirect_from(doc)
generate_redirect_to(doc)
end
Expand All @@ -37,6 +38,7 @@ def generate_redirect_from(doc)

def generate_redirect_to(doc)
return unless doc.redirect_to

page = RedirectPage.redirect_to(doc, doc.redirect_to)
doc.data.merge!(page.data)
doc.content = doc.output = page.output
Expand All @@ -45,6 +47,7 @@ def generate_redirect_to(doc)

def generate_redirects_json
return if File.exist? site.in_source_dir("redirects.json")

page = PageWithoutAFile.new(site, "", "", "redirects.json")
page.content = redirects.to_json
page.data["layout"] = nil
Expand Down