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 disabling departments via comment #11315

Merged
merged 1 commit into from
Dec 22, 2022
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
1 change: 1 addition & 0 deletions changelog/fix_disabling_departments_via_comment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#11308](https://github.com/rubocop/rubocop/issues/11308): Fix disabling departments via comment. ([@fatkodima][])
4 changes: 3 additions & 1 deletion lib/rubocop/cop/lint/redundant_cop_disable_directive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def each_line_range(cop, line_ranges)
end
end

# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def each_already_disabled(cop, line_ranges)
line_ranges.each_cons(2) do |previous_range, range|
next if ignore_offense?(range)
Expand All @@ -152,9 +153,10 @@ def each_already_disabled(cop, line_ranges)
cop
end

yield comment, redundant
yield comment, redundant if redundant
end
end
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

def find_redundant_cop(cop, range)
cop_offenses = offenses_to_check.select { |offense| offense.cop_name == cop }
Expand Down