rubocop 1.16.0 → 1.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +70 -28
  4. data/lib/rubocop.rb +2 -0
  5. data/lib/rubocop/cli/command/suggest_extensions.rb +3 -3
  6. data/lib/rubocop/config_loader.rb +1 -1
  7. data/lib/rubocop/config_validator.rb +5 -5
  8. data/lib/rubocop/cop/base.rb +2 -2
  9. data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -1
  10. data/lib/rubocop/cop/bundler/gem_version.rb +38 -4
  11. data/lib/rubocop/cop/corrector.rb +4 -4
  12. data/lib/rubocop/cop/generator.rb +1 -1
  13. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
  14. data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
  15. data/lib/rubocop/cop/layout/array_alignment.rb +2 -2
  16. data/lib/rubocop/cop/layout/block_alignment.rb +1 -1
  17. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +7 -1
  18. data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
  19. data/lib/rubocop/cop/layout/dot_position.rb +7 -1
  20. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +13 -15
  21. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -2
  22. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -2
  23. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
  24. data/lib/rubocop/cop/layout/hash_alignment.rb +12 -9
  25. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +1 -1
  26. data/lib/rubocop/cop/layout/indentation_width.rb +8 -0
  27. data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +127 -0
  28. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +6 -6
  29. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +2 -2
  30. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +6 -6
  31. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +6 -6
  32. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +6 -6
  33. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +3 -3
  34. data/lib/rubocop/cop/layout/parameter_alignment.rb +2 -2
  35. data/lib/rubocop/cop/layout/redundant_line_break.rb +11 -9
  36. data/lib/rubocop/cop/layout/space_around_keyword.rb +12 -0
  37. data/lib/rubocop/cop/layout/space_around_operators.rb +7 -1
  38. data/lib/rubocop/cop/lint/literal_as_condition.rb +13 -1
  39. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +32 -17
  40. data/lib/rubocop/cop/lint/nested_percent_literal.rb +1 -1
  41. data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
  42. data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
  43. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +93 -65
  44. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +5 -0
  45. data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
  46. data/lib/rubocop/cop/lint/unused_block_argument.rb +1 -1
  47. data/lib/rubocop/cop/lint/useless_assignment.rb +1 -1
  48. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
  49. data/lib/rubocop/cop/migration/department_name.rb +3 -1
  50. data/lib/rubocop/cop/mixin/check_line_breakable.rb +10 -1
  51. data/lib/rubocop/cop/naming/inclusive_language.rb +249 -0
  52. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -2
  53. data/lib/rubocop/cop/style/class_and_module_children.rb +14 -0
  54. data/lib/rubocop/cop/style/comment_annotation.rb +50 -6
  55. data/lib/rubocop/cop/style/identical_conditional_branches.rb +29 -0
  56. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -1
  57. data/lib/rubocop/cop/style/multiline_when_then.rb +2 -11
  58. data/lib/rubocop/cop/style/multiple_comparison.rb +1 -1
  59. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
  60. data/lib/rubocop/cop/style/quoted_symbols.rb +8 -3
  61. data/lib/rubocop/cop/style/raise_args.rb +2 -0
  62. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
  63. data/lib/rubocop/cop/style/redundant_self.rb +24 -2
  64. data/lib/rubocop/cop/style/regexp_literal.rb +10 -1
  65. data/lib/rubocop/cop/style/special_global_vars.rb +3 -3
  66. data/lib/rubocop/cop/style/string_concatenation.rb +32 -5
  67. data/lib/rubocop/cop/style/string_literals.rb +2 -2
  68. data/lib/rubocop/cop/style/swap_values.rb +1 -1
  69. data/lib/rubocop/cop/style/unpack_first.rb +1 -1
  70. data/lib/rubocop/cop/variable_force/variable_table.rb +1 -1
  71. data/lib/rubocop/directive_comment.rb +53 -5
  72. data/lib/rubocop/options.rb +4 -4
  73. data/lib/rubocop/rake_task.rb +1 -1
  74. data/lib/rubocop/remote_config.rb +10 -2
  75. data/lib/rubocop/rspec/cop_helper.rb +1 -1
  76. data/lib/rubocop/rspec/expect_offense.rb +1 -1
  77. data/lib/rubocop/version.rb +1 -1
  78. metadata +9 -7
@@ -67,6 +67,28 @@ module RuboCop
67
67
  # do_x
68
68
  # do_z
69
69
  # end
70
+ #
71
+ # # bad
72
+ # case foo
73
+ # in 1
74
+ # do_x
75
+ # in 2
76
+ # do_x
77
+ # else
78
+ # do_x
79
+ # end
80
+ #
81
+ # # good
82
+ # case foo
83
+ # in 1
84
+ # do_x
85
+ # do_y
86
+ # in 2
87
+ # # nothing
88
+ # else
89
+ # do_x
90
+ # do_z
91
+ # end
70
92
  class IdenticalConditionalBranches < Base
71
93
  include RangeHelp
72
94
  extend AutoCorrector
@@ -87,6 +109,13 @@ module RuboCop
87
109
  check_branches(node, branches)
88
110
  end
89
111
 
112
+ def on_case_match(node)
113
+ return unless node.else? && node.else_branch
114
+
115
+ branches = node.in_pattern_branches.map(&:body).push(node.else_branch)
116
+ check_branches(node, branches)
117
+ end
118
+
90
119
  private
91
120
 
92
121
  def check_branches(node, branches)
@@ -116,7 +116,8 @@ module RuboCop
116
116
  end
117
117
 
118
118
  def call_with_braced_block?(node)
119
- (node.send_type? || node.super_type?) && node.block_node && node.block_node.braces?
119
+ (node.send_type? || node.super_type?) &&
120
+ ((node.parent&.block_type? || node.parent&.numblock_type?) && node.parent&.braces?)
120
121
  end
121
122
 
122
123
  def call_as_argument_or_chain?(node)
@@ -35,17 +35,7 @@ module RuboCop
35
35
  MSG = 'Do not use `then` for multiline `when` statement.'
36
36
 
37
37
  def on_when(node)
38
- # Without `then`, there's no offense
39
- return unless node.then?
40
-
41
- # Single line usage of `then` is not an offense
42
- return if !node.children.last.nil? && !node.multiline?
43
-
44
- # Requires `then` for write `when` and its body on the same line.
45
- return if require_then?(node)
46
-
47
- # For arrays and hashes there's no offense
48
- return if accept_node_type?(node.body)
38
+ return if !node.then? || require_then?(node)
49
39
 
50
40
  range = node.loc.begin
51
41
  add_offense(range) do |corrector|
@@ -57,6 +47,7 @@ module RuboCop
57
47
 
58
48
  private
59
49
 
50
+ # Requires `then` for write `when` and its body on the same line.
60
51
  def require_then?(when_node)
61
52
  unless when_node.conditions.first.first_line == when_node.conditions.last.last_line
62
53
  return true
@@ -44,7 +44,7 @@ module RuboCop
44
44
  extend AutoCorrector
45
45
 
46
46
  MSG = 'Avoid comparing a variable with multiple items ' \
47
- 'in a conditional, use `Array#include?` instead.'
47
+ 'in a conditional, use `Array#include?` instead.'
48
48
 
49
49
  def on_new_investigation
50
50
  @last_comparison = nil
@@ -68,7 +68,7 @@ module RuboCop
68
68
  delimiters = preferred_delimiters_for(type)
69
69
 
70
70
  "`#{type}`-literals should be delimited by " \
71
- "`#{delimiters[0]}` and `#{delimiters[1]}`."
71
+ "`#{delimiters[0]}` and `#{delimiters[1]}`."
72
72
  end
73
73
 
74
74
  def preferred_delimiters_for(type)
@@ -36,9 +36,9 @@ module RuboCop
36
36
  extend AutoCorrector
37
37
 
38
38
  MSG_SINGLE = "Prefer single-quoted symbols when you don't need string interpolation " \
39
- 'or special symbols.'
39
+ 'or special symbols.'
40
40
  MSG_DOUBLE = 'Prefer double-quoted symbols unless you need single quotes to ' \
41
- 'avoid extra backslashes for escaping.'
41
+ 'avoid extra backslashes for escaping.'
42
42
 
43
43
  def on_sym(node)
44
44
  return unless quoted?(node)
@@ -58,7 +58,7 @@ module RuboCop
58
58
  private
59
59
 
60
60
  def autocorrect(corrector, node)
61
- str = if hash_key?(node)
61
+ str = if hash_colon_key?(node)
62
62
  # strip quotes
63
63
  correct_quotes(node.source[1..-2])
64
64
  else
@@ -69,6 +69,11 @@ module RuboCop
69
69
  corrector.replace(node, str)
70
70
  end
71
71
 
72
+ def hash_colon_key?(node)
73
+ # Is the node a hash key with the colon style?
74
+ hash_key?(node) && node.parent.colon?
75
+ end
76
+
72
77
  def correct_quotes(str)
73
78
  if style == :single_quotes
74
79
  to_string_literal(str)
@@ -23,6 +23,7 @@ module RuboCop
23
23
  # # good
24
24
  # raise StandardError, 'message'
25
25
  # fail 'message'
26
+ # raise MyCustomError
26
27
  # raise MyCustomError.new(arg1, arg2, arg3)
27
28
  # raise MyKwArgError.new(key1: val1, key2: val2)
28
29
  #
@@ -37,6 +38,7 @@ module RuboCop
37
38
  #
38
39
  # # good
39
40
  # raise StandardError.new('message')
41
+ # raise MyCustomError
40
42
  # raise MyCustomError.new(arg1, arg2, arg3)
41
43
  # fail 'message'
42
44
  class RaiseArgs < Base
@@ -32,7 +32,7 @@ module RuboCop
32
32
 
33
33
  REQUIRES_ESCAPE_OUTSIDE_CHAR_CLASS_CHARS = '.*+?{}()|$'.chars.freeze
34
34
  MSG_REDUNDANT_CHARACTER_CLASS = 'Redundant single-element character class, ' \
35
- '`%<char_class>s` can be replaced with `%<element>s`.'
35
+ '`%<char_class>s` can be replaced with `%<element>s`.'
36
36
 
37
37
  def on_regexp(node)
38
38
  each_redundant_character_class(node) do |loc|
@@ -92,7 +92,7 @@ module RuboCop
92
92
 
93
93
  def on_masgn(node)
94
94
  lhs, rhs = *node
95
- lhs.children.each { |child| add_lhs_to_local_variables_scopes(rhs, child.to_a.first) }
95
+ add_masgn_lhs_variables(rhs, lhs)
96
96
  end
97
97
 
98
98
  def on_lvasgn(node)
@@ -106,7 +106,7 @@ module RuboCop
106
106
 
107
107
  return if allowed_send_node?(node)
108
108
 
109
- add_offense(node) do |corrector|
109
+ add_offense(node.receiver) do |corrector|
110
110
  corrector.remove(node.receiver)
111
111
  corrector.remove(node.loc.dot)
112
112
  end
@@ -116,6 +116,22 @@ module RuboCop
116
116
  add_scope(node, @local_variables_scopes[node])
117
117
  end
118
118
 
119
+ def on_if(node)
120
+ # Allow conditional nodes to use `self` in the condition if that variable
121
+ # name is used in an `lvasgn` or `masgn` within the `if`.
122
+ node.child_nodes.each do |child_node|
123
+ lhs, _rhs = *child_node
124
+
125
+ if child_node.lvasgn_type?
126
+ add_lhs_to_local_variables_scopes(node.condition, lhs)
127
+ elsif child_node.masgn_type?
128
+ add_masgn_lhs_variables(node.condition, lhs)
129
+ end
130
+ end
131
+ end
132
+ alias on_while on_if
133
+ alias on_until on_if
134
+
119
135
  private
120
136
 
121
137
  def add_scope(node, local_variables = [])
@@ -163,6 +179,12 @@ module RuboCop
163
179
  @local_variables_scopes[rhs] << lhs
164
180
  end
165
181
  end
182
+
183
+ def add_masgn_lhs_variables(rhs, lhs)
184
+ lhs.children.each do |child|
185
+ add_lhs_to_local_variables_scopes(rhs, child.to_a.first)
186
+ end
187
+ end
166
188
  end
167
189
  end
168
190
  end
@@ -117,7 +117,7 @@ module RuboCop
117
117
  def allowed_percent_r_literal?(node)
118
118
  style == :slashes && contains_disallowed_slash?(node) ||
119
119
  style == :percent_r ||
120
- allowed_mixed_percent_r?(node)
120
+ allowed_mixed_percent_r?(node) || allowed_omit_parentheses_with_percent_r_literal?(node)
121
121
  end
122
122
 
123
123
  def allowed_mixed_percent_r?(node)
@@ -149,6 +149,15 @@ module RuboCop
149
149
  config.for_cop('Style/PercentLiteralDelimiters') ['PreferredDelimiters']['%r'].chars
150
150
  end
151
151
 
152
+ def allowed_omit_parentheses_with_percent_r_literal?(node)
153
+ return false unless node.parent&.call_type?
154
+ return true if node.content.start_with?(' ')
155
+
156
+ enforced_style = config.for_cop('Style/MethodCallWithArgsParentheses')['EnforcedStyle']
157
+
158
+ enforced_style == 'omit_parentheses'
159
+ end
160
+
152
161
  def correct_delimiters(node, corrector)
153
162
  replacement = calculate_replacement(node)
154
163
  corrector.replace(node.loc.begin, replacement.first)
@@ -53,10 +53,10 @@ module RuboCop
53
53
  extend AutoCorrector
54
54
 
55
55
  MSG_BOTH = 'Prefer `%<prefer>s` from the stdlib \'English\' ' \
56
- 'module (don\'t forget to require it) or `%<regular>s` over ' \
57
- '`%<global>s`.'
56
+ 'module (don\'t forget to require it) or `%<regular>s` over ' \
57
+ '`%<global>s`.'
58
58
  MSG_ENGLISH = 'Prefer `%<prefer>s` from the stdlib \'English\' ' \
59
- 'module (don\'t forget to require it) over `%<global>s`.'
59
+ 'module (don\'t forget to require it) over `%<global>s`.'
60
60
  MSG_REGULAR = 'Prefer `%<prefer>s` over `%<global>s`.'
61
61
 
62
62
  ENGLISH_VARS = { # rubocop:disable Style/MutableConstant
@@ -15,18 +15,37 @@ module RuboCop
15
15
  # lines, this cop does not register an offense; instead,
16
16
  # `Style/LineEndConcatenation` will pick up the offense if enabled.
17
17
  #
18
- # @example
18
+ # Two modes are supported:
19
+ # 1. `aggressive` style checks and corrects all occurrences of `+` where
20
+ # either the left or right side of `+` is a string literal.
21
+ # 2. `conservative` style on the other hand, checks and corrects only if
22
+ # left side (receiver of `+` method call) is a string literal.
23
+ # This is useful when the receiver is some expression that returns string like `Pathname`
24
+ # instead of a string literal.
25
+ #
26
+ # @example Mode: aggressive (default)
19
27
  # # bad
20
28
  # email_with_name = user.name + ' <' + user.email + '>'
29
+ # Pathname.new('/') + 'test'
21
30
  #
22
31
  # # good
23
32
  # email_with_name = "#{user.name} <#{user.email}>"
24
33
  # email_with_name = format('%s <%s>', user.name, user.email)
34
+ # "#{Pathname.new('/')}test"
25
35
  #
26
36
  # # accepted, line-end concatenation
27
37
  # name = 'First' +
28
38
  # 'Last'
29
39
  #
40
+ # @example Mode: conservative
41
+ # # bad
42
+ # 'Hello' + user.name
43
+ #
44
+ # # good
45
+ # "Hello #{user.name}"
46
+ # user.name + '!!'
47
+ # Pathname.new('/') + 'test'
48
+ #
30
49
  class StringConcatenation < Base
31
50
  include Util
32
51
  include RangeHelp
@@ -52,10 +71,15 @@ module RuboCop
52
71
  return if line_end_concatenation?(node)
53
72
 
54
73
  topmost_plus_node = find_topmost_plus_node(node)
74
+ parts = collect_parts(topmost_plus_node)
75
+ return unless parts[0..-2].any? { |receiver_node| offensive_for_mode?(receiver_node) }
55
76
 
56
- parts = []
57
- collect_parts(topmost_plus_node, parts)
77
+ register_offense(topmost_plus_node, parts)
78
+ end
79
+
80
+ private
58
81
 
82
+ def register_offense(topmost_plus_node, parts)
59
83
  add_offense(topmost_plus_node) do |corrector|
60
84
  correctable_parts = parts.none? { |part| uncorrectable?(part) }
61
85
  if correctable_parts && !corrected_ancestor?(topmost_plus_node)
@@ -67,7 +91,10 @@ module RuboCop
67
91
  end
68
92
  end
69
93
 
70
- private
94
+ def offensive_for_mode?(receiver_node)
95
+ mode = cop_config['Mode'].to_sym
96
+ mode == :aggressive || mode == :conservative && receiver_node.str_type?
97
+ end
71
98
 
72
99
  def line_end_concatenation?(node)
73
100
  # If the concatenation happens at the end of the line,
@@ -87,7 +114,7 @@ module RuboCop
87
114
  current
88
115
  end
89
116
 
90
- def collect_parts(node, parts)
117
+ def collect_parts(node, parts = [])
91
118
  return unless node
92
119
 
93
120
  if plus_node?(node)
@@ -87,10 +87,10 @@ module RuboCop
87
87
  def message(_node)
88
88
  if style == :single_quotes
89
89
  "Prefer single-quoted strings when you don't need string " \
90
- 'interpolation or special symbols.'
90
+ 'interpolation or special symbols.'
91
91
  else
92
92
  'Prefer double-quoted strings unless you need single quotes to ' \
93
- 'avoid extra backslashes for escaping.'
93
+ 'avoid extra backslashes for escaping.'
94
94
  end
95
95
  end
96
96
 
@@ -21,7 +21,7 @@ module RuboCop
21
21
  extend AutoCorrector
22
22
 
23
23
  MSG = 'Replace this and assignments at lines %<x_line>d '\
24
- 'and %<y_line>d with `%<replacement>s`.'
24
+ 'and %<y_line>d with `%<replacement>s`.'
25
25
 
26
26
  SIMPLE_ASSIGNMENT_TYPES = %i[lvasgn ivasgn cvasgn gvasgn casgn].to_set.freeze
27
27
 
@@ -21,7 +21,7 @@ module RuboCop
21
21
  extend AutoCorrector
22
22
 
23
23
  MSG = 'Use `%<receiver>s.unpack1(%<format>s)` instead of '\
24
- '`%<receiver>s.unpack(%<format>s)%<method>s`.'
24
+ '`%<receiver>s.unpack(%<format>s)%<method>s`.'
25
25
  RESTRICT_ON_SEND = %i[first [] slice at].freeze
26
26
 
27
27
  # @!method unpack_and_first_element?(node)
@@ -58,7 +58,7 @@ module RuboCop
58
58
 
59
59
  unless variable
60
60
  raise "Assigning to undeclared local variable \"#{name}\" " \
61
- "at #{node.source_range}, #{node.inspect}"
61
+ "at #{node.source_range}, #{node.inspect}"
62
62
  end
63
63
 
64
64
  variable.assign(node)
@@ -6,7 +6,9 @@ module RuboCop
6
6
  # cops it contains.
7
7
  class DirectiveComment
8
8
  # @api private
9
- REDUNDANT_COP = 'Lint/RedundantCopDisableDirective'
9
+ REDUNDANT_DIRECTIVE_COP_DEPARTMENT = 'Lint'
10
+ # @api private
11
+ REDUNDANT_DIRECTIVE_COP = "#{REDUNDANT_DIRECTIVE_COP_DEPARTMENT}/RedundantCopDisableDirective"
10
12
  # @api private
11
13
  COP_NAME_PATTERN = '([A-Z]\w+/)*(?:[A-Z]\w+)'
12
14
  # @api private
@@ -23,10 +25,11 @@ module RuboCop
23
25
  line.split(DIRECTIVE_COMMENT_REGEXP).first
24
26
  end
25
27
 
26
- attr_reader :comment, :mode, :cops
28
+ attr_reader :comment, :cop_registry, :mode, :cops
27
29
 
28
- def initialize(comment)
30
+ def initialize(comment, cop_registry = Cop::Registry.global)
29
31
  @comment = comment
32
+ @cop_registry = cop_registry
30
33
  @mode, @cops = match_captures
31
34
  end
32
35
 
@@ -68,6 +71,11 @@ module RuboCop
68
71
  !disabled? && all_cops?
69
72
  end
70
73
 
74
+ # Checks if this directive disables all cops
75
+ def disabled_all?
76
+ disabled? && all_cops?
77
+ end
78
+
71
79
  # Checks if all cops specified in this directive
72
80
  def all_cops?
73
81
  cops == 'all'
@@ -78,6 +86,26 @@ module RuboCop
78
86
  @cop_names ||= all_cops? ? all_cop_names : parsed_cop_names
79
87
  end
80
88
 
89
+ # Returns array of specified in this directive department names
90
+ # when all department disabled
91
+ def department_names
92
+ splitted_cops_string.select { |cop| department?(cop) }
93
+ end
94
+
95
+ # Checks if directive departments include cop
96
+ def in_directive_department?(cop)
97
+ department_names.any? { |department| cop.start_with?(department) }
98
+ end
99
+
100
+ # Checks if cop department has already used in directive comment
101
+ def overridden_by_department?(cop)
102
+ in_directive_department?(cop) && splitted_cops_string.include?(cop)
103
+ end
104
+
105
+ def directive_count
106
+ splitted_cops_string.count
107
+ end
108
+
81
109
  # Returns line number for directive
82
110
  def line_number
83
111
  comment.loc.expression.line
@@ -85,12 +113,32 @@ module RuboCop
85
113
 
86
114
  private
87
115
 
88
- def parsed_cop_names
116
+ def splitted_cops_string
89
117
  (cops || '').split(/,\s*/)
90
118
  end
91
119
 
120
+ def parsed_cop_names
121
+ splitted_cops_string.map do |name|
122
+ department?(name) ? cop_names_for_department(name) : name
123
+ end.flatten
124
+ end
125
+
126
+ def department?(name)
127
+ cop_registry.department?(name)
128
+ end
129
+
92
130
  def all_cop_names
93
- Cop::Registry.global.names - [REDUNDANT_COP]
131
+ exclude_redundant_directive_cop(cop_registry.names)
132
+ end
133
+
134
+ def cop_names_for_department(department)
135
+ names = cop_registry.names_for_department(department)
136
+ has_redundant_directive_cop = department == REDUNDANT_DIRECTIVE_COP_DEPARTMENT
137
+ has_redundant_directive_cop ? exclude_redundant_directive_cop(names) : names
138
+ end
139
+
140
+ def exclude_redundant_directive_cop(cops)
141
+ cops - [REDUNDANT_DIRECTIVE_COP]
94
142
  end
95
143
  end
96
144
  end