Skip to content

Commit

Permalink
Fix disabling departments via comment
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Dec 21, 2022
1 parent 8bb0c47 commit d1660e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit d1660e5

Please sign in to comment.