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

[Fix #5980] Implement safe and safe-auto-correct options #6341

Merged
merged 2 commits into from Oct 7, 2018
Merged

Conversation

Darhazer
Copy link
Member


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@@ -117,9 +117,18 @@ def length
@registry.size
end

def enabled(config, only)
def enabled(config, only, only_safe = false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought we had a rule not to do optional boolean params. In general these days we should favour keyword params all the time.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could write an internal affairs cop to enforce this. Maybe it would be useful to have it public, but disabled by default. The expect_offense spec helpers takes in an optional argument for a file name. I'm not sure if we have other usages of optional arguments.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think such a cop should probably be public.

@@ -117,9 +117,18 @@ def length
@registry.size
end

def enabled(config, only)
def enabled(config, only, only_safe = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could write an internal affairs cop to enforce this. Maybe it would be useful to have it public, but disabled by default. The expect_offense spec helpers takes in an optional argument for a file name. I'm not sure if we have other usages of optional arguments.

@@ -20,7 +20,13 @@ def autocorrect_enabled?
# allow turning off autocorrect on a cop by cop basis
return true unless cop_config

cop_config['AutoCorrect'] != false
return false if cop_config['AutoCorrect'] == false
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess here some case might be a bit more readable then the 3 ifs. I'm with the current implementation, though.

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 28, 2018

One small point from me - we should probably add a couple of lines in the manual about safe/unsafe cops and put some tip that people should probably use --safe if they want to play it safe.

Great work overall!

@bbatsov bbatsov merged commit 806f95f into master Oct 7, 2018
@bbatsov bbatsov deleted the safe-option branch October 7, 2018 07:49
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.

None yet

3 participants