Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Rubocop to v0.48 #5997

Merged
merged 15 commits into from Apr 9, 2017
Merged

Bump Rubocop to v0.48 #5997

merged 15 commits into from Apr 9, 2017

Conversation

ashmaroli
Copy link
Member

@ashmaroli ashmaroli commented Apr 1, 2017

Fixes #5992, fixes #6005
WIP

Rubocop 0.48 introduced some new cops that broke our tests. While we temporarily locked to the previous version 0.47.1, this pull will remove the lock to bump Rubocop to v0.48 and beyond.

Lets discuss if the fixes proposed here are acceptable.

The remaining catches appear to me as bugs in Rubocop-0.48

IMO an array of symbols read better when the constituent entries appear to
to be symbols (e.g. [:label, :type] instead of %i(label type))
This cop recommends using sqiggly-heredocs (`<<~`) -- a Ruby 2.3 feature
or otherwise depend on external libraries like Activesupport, Powerpack,
or Unindent.

The better alternative is to disable this cop for as long as we support
Rubies older than v2.3

Ref: rubocop/rubocop#4028
@ashmaroli
Copy link
Member Author

@jekyll/ecosystem

@pathawks
Copy link
Member

pathawks commented Apr 1, 2017

All of the tests are failing

@@ -138,6 +138,8 @@ Style/StringLiterals:
EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
Style/SymbolArray:
Enabled: false
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an opinion and not a fact, this needs to be shipped as a unique pull request for everyone else to comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed.

Copy link
Member Author

Choose a reason for hiding this comment

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

this needs to be shipped as a unique pull request for everyone else to comment.

This PR will ship with this cop disabled in line with behavior from 0.47.1 It can enabled via a dedicated PR

@@ -106,7 +106,7 @@ def siteify_file(file, overrides_front_matter = {})
front_matter = {
"title" => title,
"permalink" => "/docs/#{slug}/",
"note" => "This file is autogenerated. Edit /#{file} instead."
"note" => "This file is autogenerated. Edit /#{file} instead.",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not the Ruby way. This is the Go way.

Copy link
Member Author

Choose a reason for hiding this comment

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

We follow this style at Jekyll since last few releases of Rubocop

@@ -139,7 +139,7 @@ def parse_date(input, msg = "Input could not be parsed.")
# Returns true if the YAML front matter is present.
# rubocop: disable PredicateName
def has_yaml_header?(file)
!!(File.open(file, "rb", &:readline) =~ %r!\A---\s*\r?\n!)
!File.open(file, "rb", &:readline) !~ %r!\A---\s*\r?\n!
Copy link
Contributor

Choose a reason for hiding this comment

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

You still have a ! so this change does nothing but superficially confuse the user. !! is straight forward and easy to spot from the get-go, where as ! then later !~ is confusing, without a significant performance improvement, this suites nothing.

Copy link
Member Author

Choose a reason for hiding this comment

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

The changes in this commit was made by rubocop -a

@ashmaroli
Copy link
Member Author

All of the tests are failing

I'm investigating.. 😭

…ds cop

This reverts commit 1a00f8f and
additionally disables InverseMethods StyleCop
Many bugfixes have been applied following the release of v0.48. Check if
those buggfixes apply to our failing tests.
@ashmaroli
Copy link
Member Author

Note: Will remove the last two temporary commits as and when associated issues have been resolved elsewhere. Labelled do-not-merge till then.

Gemfile Outdated
@@ -25,9 +25,9 @@ group :test do
gem "nokogiri"
gem "rspec"
gem "rspec-mocks"
gem "rubocop", "~> 0.47.1"
gem "test-theme", :path => File.expand_path("./test/fixtures/test-theme", File.dirname(__FILE__))
gem "rubocop", :git => "https://github.com/smakagon/rubocop", :branch => "4227_ambiguous_block_association_false_positive"
Copy link
Member

Choose a reason for hiding this comment

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

Clearly we don't want to merge this.

@ashmaroli
Copy link
Member Author

The checksum issue with gem faraday has been resolved upstream and consequently the temporary patch commit in this PR has been removed.

@ashmaroli
Copy link
Member Author

Removed the temporary patch commit from a fork of Rubocop, which has been merged into Rubocop's master.

@ashmaroli
Copy link
Member Author

@pathawks locking to latest release of Rubocop v0.48.1
@DirtyF the do-not-merge label may be removed.

Gemfile Outdated
@@ -25,7 +25,7 @@ group :test do
gem "nokogiri"
gem "rspec"
gem "rspec-mocks"
gem "rubocop", :git => "https://github.com/bbatsov/rubocop"
gem "rubocop", "~> 0.48.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@ashmaroli
Copy link
Member Author

ping @pathawks requesting a re-review 😃

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

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

Some comments/questions/concerns!

Style/IndentationWidth:
Severity: error
Style/InverseMethods:
Enabled: false
Copy link
Member

Choose a reason for hiding this comment

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

What is this?

Copy link
Member

Choose a reason for hiding this comment

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

}
assert_nil(
@files.find { |doc| doc.relative_path == "_slides/non-outputted-slide.html" }
)
Copy link
Member

Choose a reason for hiding this comment

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

What about

assert_nil @files.find do |doc|
  ...
end

Or does it complain about not having parentheses?

refute_nil(
@site.posts.index do |post|
post.relative_path == "_posts/2017-2-5-i-dont-like-zeroes.md"
end
Copy link
Member

Choose a reason for hiding this comment

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

Maybe in all these cases what we should do is pull out the method with the block, or use a unified helper (i thought we had one?):

post_of_interest = @site.posts.find {|post| post.relative_path == "_posts/2017-2-5-i-dont-like-zeroes.md" }
refute_nil post_of_interest

or, with a helper method

refute_nil find_by(:relative_path, "_posts/2017-2-5-i-dont-like-zeroes.md", @site.posts)

Copy link
Member Author

Choose a reason for hiding this comment

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

❤️ the helper method idea. Tackle in another PR?

@DirtyF
Copy link
Member

DirtyF commented Apr 9, 2017

@jekyllbot: merge +dev

@jekyllbot jekyllbot merged commit 7d7a312 into jekyll:master Apr 9, 2017
jekyllbot added a commit that referenced this pull request Apr 9, 2017
pathawks added a commit that referenced this pull request Oct 23, 2017
This was disabled in #5997 because it was new to Rubocop. I think it can
be enabled now.
@ashmaroli ashmaroli deleted the rubocop048 branch October 23, 2017 06:42
@jekyll jekyll locked and limited conversation to collaborators Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants