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 #9922] Replace extra disable directives with comma #9937

Merged
merged 1 commit into from Jul 16, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1 @@
* [#9922](https://github.com/rubocop/rubocop/issues/9922): Make better auto-corrections in `Style/DoubleCopDisableDirective`. ([@jonas054][])
8 changes: 1 addition & 7 deletions lib/rubocop/cop/style/double_cop_disable_directive.rb
Expand Up @@ -36,13 +36,7 @@ def on_new_investigation
next unless comment.text.scan(/# rubocop:(?:disable|todo)/).size > 1

add_offense(comment) do |corrector|
prefix = if comment.text.start_with?('# rubocop:disable')
'# rubocop:disable'
else
'# rubocop:todo'
end

corrector.replace(comment, comment.text[/#{prefix} \S+/])
corrector.replace(comment, comment.text.gsub(%r{ # rubocop:(disable|todo)}, ','))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cli/disable_uncorrectable_spec.rb
Expand Up @@ -177,7 +177,7 @@ def choose_move(who_to_move)
class Chess
# rubocop:todo Metrics/MethodLength
# rubocop:todo Metrics/AbcSize
def choose_move(who_to_move) # rubocop:todo Metrics/CyclomaticComplexity
def choose_move(who_to_move) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
legal_moves = all_legal_moves_that_dont_put_me_in_check(who_to_move)

return nil if legal_moves.empty?
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cop/style/double_cop_disable_directive_spec.rb
Expand Up @@ -9,7 +9,7 @@ def choose_move(who_to_move) # rubocop:disable Metrics/CyclomaticComplexity # ru
RUBY

expect_correction(<<~RUBY)
def choose_move(who_to_move) # rubocop:disable Metrics/CyclomaticComplexity
def choose_move(who_to_move) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
end
RUBY
end
Expand All @@ -22,7 +22,7 @@ def choose_move(who_to_move) # rubocop:todo Metrics/CyclomaticComplexity # ruboc
RUBY

expect_correction(<<~RUBY)
def choose_move(who_to_move) # rubocop:todo Metrics/CyclomaticComplexity
def choose_move(who_to_move) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
end
RUBY
end
Expand Down