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

Upgrade rubocop to 0.48 #8652

Merged
merged 4 commits into from Mar 27, 2017
Merged

Upgrade rubocop to 0.48 #8652

merged 4 commits into from Mar 27, 2017

Conversation

giginet
Copy link
Collaborator

@giginet giginet commented Mar 26, 2017

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Description

Updated rubocop to latest version and .rubocop.yml.

Motivation and Context

rubocop 0.48 has been released.
Because of this change, CI is failing.
#8649

So I updated rubocop and .rubocop.yml.

Copy link
Collaborator Author

@giginet giginet left a comment

Choose a reason for hiding this comment

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

I added settings about new cops.
Let's discuss this.

.rubocop.yml Outdated
@@ -81,6 +81,16 @@ Style/DotPosition:
Style/DoubleNegation:
Enabled: false

Style/SymbolArray:
Copy link
Collaborator Author

@giginet giginet Mar 26, 2017

Choose a reason for hiding this comment

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

SymbolArray cop is enabled by default.
This cop changes all [] into %i.
It has big effect on entire project.
So I disabled.

ref:rubocop/rubocop#4124

Copy link
Contributor

Choose a reason for hiding this comment

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

This explanation is great. Can you add it as a comment above the config item so we can easily see why we did it?

.rubocop.yml Outdated
Style/SymbolArray:
Enabled: false

Style/IndentHeredoc:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IndentHeredoc is introduced from Ruby 2.3.
However, we have to support Ruby 2.0.0.
So I disabled.

ref: rubocop/rubocop#4028

Copy link
Contributor

Choose a reason for hiding this comment

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

This explanation is great. Can you add it as a comment above the config item so we can easily see why we did it?

- '**/Rakefile'
- '**/Fastfile'
- '**/Deliverfile'
- '**/Snapfile'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

.rubocop.yml Outdated
Style/IndentHeredoc:
Enabled: false

Style/MixinGrouping:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In latest rubocop, this cop detects include of rspec matcher as Module::include.
This behavior is strange. It would be the issue on rubocop.
So I disabled.

screen shot 2017-03-27 at 15 05 59

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -89,6 +99,9 @@ Lint/HandleExceptions:
Lint/UnusedBlockArgument:
Enabled: false

Lint/AmbiguousBlockAssociation:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer AmbiguousBlockAssociation is enabled 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If this cop is enabled, autocorrect seems not to work.
Should we fix them manually?

screen shot 2017-03-27 at 15 01 04

@@ -58,8 +58,8 @@ def self.run(params)
# Removes .plist files that matched the given expression in the 'ignore' parameter
ignore_expression = params[:ignore]
if ignore_expression
info_plist_files.select! do |info_plist_file|
!info_plist_file.match(ignore_expression)
info_plist_files.reject! do |info_plist_file|
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yeah that looks fine 👍

Copy link
Collaborator

@nafu nafu left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍
We need more approval ✅

Copy link
Member

@KrauseFx KrauseFx left a comment

Choose a reason for hiding this comment

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

This looks great, thanks @giginet for this 👍 Please add the comments to the .rubocop.yml, then it's ready to be merged. Also, can you run the test suite on Ruby 2.0 to make sure everything works as expected?

@@ -58,8 +58,8 @@ def self.run(params)
# Removes .plist files that matched the given expression in the 'ignore' parameter
ignore_expression = params[:ignore]
if ignore_expression
info_plist_files.select! do |info_plist_file|
!info_plist_file.match(ignore_expression)
info_plist_files.reject! do |info_plist_file|
Copy link
Member

Choose a reason for hiding this comment

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

yeah that looks fine 👍

@@ -43,7 +43,7 @@ def self.run(params)
file_ruby = file.gsub('\ ', ' ')
File.exist?(file_ruby) and
(!select_regex or file_ruby =~ select_regex) and
(!exclude_regex or !(file_ruby =~ exclude_regex))
(!exclude_regex or file_ruby !~ exclude_regex)
Copy link
Member

Choose a reason for hiding this comment

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

Does this syntax also work with Ruby 2.0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

!~ operator is available since 1.9. So we can use this on Apple Ruby.

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, sounds good 👍

@giginet
Copy link
Collaborator Author

giginet commented Mar 27, 2017

I ran rspec and rubocop on '2.0.0-p648'. And they are passed fine 👍

@giginet
Copy link
Collaborator Author

giginet commented Mar 27, 2017

Thanks for reviewing!

@giginet giginet merged commit bbe0f81 into fastlane:master Mar 27, 2017
@giginet giginet deleted the rubocop48 branch March 27, 2017 10:20
@fastlane-bot
Copy link

Hey @giginet 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released yet to RubyGems.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

@KrauseFx KrauseFx mentioned this pull request Mar 30, 2017
@fastlane fastlane locked and limited conversation to collaborators Jun 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants