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

Generate 'Exclude' list if different styles is used #3175

Merged
merged 1 commit into from
Jun 22, 2016

Conversation

flexoid
Copy link
Contributor

@flexoid flexoid commented May 27, 2016

If mixed styles of the specific cop is used across project files,
some of the cops (probably all style cops) now set 'Enabled: false'
regardless of the count of files with offense and "--exclude-limit" argument.

For example:

class Test
  def m1(a=1)
  end

  def m2(a = 1)
  end
end

.rubocop_todo.yml for the following ruby code was (with any --exclude-limit value):

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
  Enabled: false

Now it will be like this, as expected:

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
  Exclude:
    - 'test.rb'

With --exclude-limit 0:

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
  Enabled: false

And with m2 method commented:

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
  EnforcedStyle: no_space

@flexoid flexoid force-pushed the fix-exclude-for-style-cops branch 2 times, most recently from 3faa5f1 to 4177bc5 Compare May 27, 2016 21:07
@@ -19,6 +19,7 @@
* [#3140](https://github.com/bbatsov/rubocop/pull/3140): `Style/FrozenStringLiteralComment` works with file doesn't have any tokens. ([@pocke][])
* [#3154](https://github.com/bbatsov/rubocop/issues/3154): Fix handling of `()` in `Style/RedundantParentheses`. ([@lumeet][])
* [#3160](https://github.com/bbatsov/rubocop/pull/3160): `Style/Lambda` fix whitespacing when auto-correcting unparenthesized arguments. ([@palkan][])
* [#3175](https://github.com/bbatsov/rubocop/pull/3175): Generate 'Exclude' list for style cops to `.rubocop_todo.yml` if different styles is used. ([@flexoid][])
Copy link
Collaborator

Choose a reason for hiding this comment

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

if different styles are used

And it's not entirely correct to say that it's for style cops, because there are a handful of rails cops that have a configurable enforced style, and they will also be affected by this correction. So say "cops with configurable enforced style" instead.

@jonas054
Copy link
Collaborator

Code looks good. Just some remarks on the changelog entry.

@flexoid flexoid force-pushed the fix-exclude-for-style-cops branch 2 times, most recently from 0664c09 to 7f02e59 Compare May 30, 2016 20:40
@flexoid
Copy link
Contributor Author

flexoid commented May 30, 2016

@jonas054 thanks for your corrections, I just fixed changelog and rebased on master.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 21, 2016

Unfortunately you'll have to rebase this again.

@flexoid flexoid force-pushed the fix-exclude-for-style-cops branch from 7f02e59 to aa47893 Compare June 21, 2016 17:45
@flexoid
Copy link
Contributor Author

flexoid commented Jun 21, 2016

@bbatsov no problem, done

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 22, 2016

Are you sure? I still see a merge conflict.

Before, if mixed styles of the specific cop are used across project files,
some of the cops set 'Enabled: false' regardless of the count of
files with offense and "--exclude-limit" argument.
@flexoid flexoid force-pushed the fix-exclude-for-style-cops branch from aa47893 to f9ed49b Compare June 22, 2016 05:04
@flexoid
Copy link
Contributor Author

flexoid commented Jun 22, 2016

Master is changing so quickly :) Should be mergeable until next PR.

@bbatsov bbatsov merged commit 35544fe into rubocop:master Jun 22, 2016
Neodelf pushed a commit to Neodelf/rubocop that referenced this pull request Oct 15, 2016
Before, if mixed styles of the specific cop are used across project files,
some of the cops set 'Enabled: false' regardless of the count of
files with offense and "--exclude-limit" argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants