rubocop 0.93.1 → 1.6.1

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 (199) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -16
  3. data/config/default.yml +276 -82
  4. data/config/obsoletion.yml +196 -0
  5. data/exe/rubocop +1 -1
  6. data/lib/rubocop.rb +31 -2
  7. data/lib/rubocop/cli.rb +5 -1
  8. data/lib/rubocop/cli/command/auto_genenerate_config.rb +1 -1
  9. data/lib/rubocop/cli/command/execute_runner.rb +26 -11
  10. data/lib/rubocop/cli/command/suggest_extensions.rb +80 -0
  11. data/lib/rubocop/cli/command/version.rb +1 -1
  12. data/lib/rubocop/comment_config.rb +1 -1
  13. data/lib/rubocop/config.rb +4 -0
  14. data/lib/rubocop/config_loader.rb +34 -8
  15. data/lib/rubocop/config_loader_resolver.rb +12 -6
  16. data/lib/rubocop/config_obsoletion.rb +65 -247
  17. data/lib/rubocop/config_obsoletion/changed_enforced_styles.rb +33 -0
  18. data/lib/rubocop/config_obsoletion/changed_parameter.rb +21 -0
  19. data/lib/rubocop/config_obsoletion/cop_rule.rb +34 -0
  20. data/lib/rubocop/config_obsoletion/extracted_cop.rb +44 -0
  21. data/lib/rubocop/config_obsoletion/parameter_rule.rb +44 -0
  22. data/lib/rubocop/config_obsoletion/removed_cop.rb +41 -0
  23. data/lib/rubocop/config_obsoletion/renamed_cop.rb +34 -0
  24. data/lib/rubocop/config_obsoletion/rule.rb +41 -0
  25. data/lib/rubocop/config_obsoletion/split_cop.rb +27 -0
  26. data/lib/rubocop/config_regeneration.rb +1 -1
  27. data/lib/rubocop/config_validator.rb +25 -10
  28. data/lib/rubocop/cop/autocorrect_logic.rb +21 -6
  29. data/lib/rubocop/cop/badge.rb +9 -24
  30. data/lib/rubocop/cop/base.rb +33 -16
  31. data/lib/rubocop/cop/bundler/duplicated_gem.rb +26 -6
  32. data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
  33. data/lib/rubocop/cop/commissioner.rb +37 -23
  34. data/lib/rubocop/cop/cop.rb +2 -2
  35. data/lib/rubocop/cop/corrector.rb +3 -1
  36. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
  37. data/lib/rubocop/cop/correctors/string_literal_corrector.rb +6 -8
  38. data/lib/rubocop/cop/force.rb +1 -1
  39. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +3 -3
  40. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +4 -5
  41. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +1 -1
  42. data/lib/rubocop/cop/generator.rb +3 -10
  43. data/lib/rubocop/cop/generator/configuration_injector.rb +1 -1
  44. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +1 -1
  45. data/lib/rubocop/cop/layout/block_alignment.rb +3 -4
  46. data/lib/rubocop/cop/layout/class_structure.rb +22 -3
  47. data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
  48. data/lib/rubocop/cop/layout/else_alignment.rb +15 -2
  49. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +80 -10
  50. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -0
  51. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +6 -1
  52. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -1
  53. data/lib/rubocop/cop/layout/end_alignment.rb +3 -3
  54. data/lib/rubocop/cop/layout/end_of_line.rb +5 -5
  55. data/lib/rubocop/cop/layout/extra_spacing.rb +1 -2
  56. data/lib/rubocop/cop/layout/first_argument_indentation.rb +7 -2
  57. data/lib/rubocop/cop/layout/hash_alignment.rb +4 -4
  58. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +12 -0
  59. data/lib/rubocop/cop/layout/line_length.rb +10 -13
  60. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +7 -3
  61. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +24 -18
  62. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
  63. data/lib/rubocop/cop/layout/space_around_operators.rb +4 -1
  64. data/lib/rubocop/cop/layout/space_inside_parens.rb +35 -13
  65. data/lib/rubocop/cop/layout/trailing_whitespace.rb +37 -13
  66. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +2 -1
  67. data/lib/rubocop/cop/lint/constant_definition_in_block.rb +26 -2
  68. data/lib/rubocop/cop/lint/debugger.rb +17 -28
  69. data/lib/rubocop/cop/lint/duplicate_branch.rb +93 -0
  70. data/lib/rubocop/cop/lint/duplicate_case_condition.rb +2 -12
  71. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +77 -0
  72. data/lib/rubocop/cop/lint/else_layout.rb +29 -3
  73. data/lib/rubocop/cop/lint/empty_block.rb +82 -0
  74. data/lib/rubocop/cop/lint/empty_class.rb +93 -0
  75. data/lib/rubocop/cop/lint/flip_flop.rb +8 -2
  76. data/lib/rubocop/cop/lint/interpolation_check.rb +7 -2
  77. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +39 -7
  78. data/lib/rubocop/cop/lint/loop.rb +4 -4
  79. data/lib/rubocop/cop/lint/missing_super.rb +7 -4
  80. data/lib/rubocop/cop/lint/nested_percent_literal.rb +14 -0
  81. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +58 -0
  82. data/lib/rubocop/cop/lint/number_conversion.rb +46 -13
  83. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +27 -8
  84. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +19 -16
  85. data/lib/rubocop/cop/lint/shadowed_exception.rb +4 -5
  86. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +13 -0
  87. data/lib/rubocop/cop/lint/to_enum_arguments.rb +86 -0
  88. data/lib/rubocop/cop/lint/to_json.rb +1 -1
  89. data/lib/rubocop/cop/lint/unexpected_block_arity.rb +85 -0
  90. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +199 -0
  91. data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -2
  92. data/lib/rubocop/cop/lint/useless_method_definition.rb +2 -4
  93. data/lib/rubocop/cop/lint/useless_setter_call.rb +6 -1
  94. data/lib/rubocop/cop/metrics/abc_size.rb +25 -1
  95. data/lib/rubocop/cop/metrics/block_length.rb +13 -7
  96. data/lib/rubocop/cop/metrics/method_length.rb +7 -2
  97. data/lib/rubocop/cop/metrics/parameter_lists.rb +68 -2
  98. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +20 -10
  99. data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +146 -0
  100. data/lib/rubocop/cop/metrics/utils/repeated_csend_discount.rb +6 -1
  101. data/lib/rubocop/cop/migration/department_name.rb +1 -1
  102. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  103. data/lib/rubocop/cop/mixin/configurable_numbering.rb +4 -3
  104. data/lib/rubocop/cop/mixin/enforce_superclass.rb +9 -1
  105. data/lib/rubocop/cop/mixin/ignored_methods.rb +36 -3
  106. data/lib/rubocop/cop/mixin/line_length_help.rb +1 -1
  107. data/lib/rubocop/cop/mixin/method_complexity.rb +6 -0
  108. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
  109. data/lib/rubocop/cop/mixin/statement_modifier.rb +9 -4
  110. data/lib/rubocop/cop/mixin/string_help.rb +4 -1
  111. data/lib/rubocop/cop/mixin/visibility_help.rb +1 -3
  112. data/lib/rubocop/cop/naming/accessor_method_name.rb +15 -1
  113. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +12 -2
  114. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +11 -5
  115. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +67 -18
  116. data/lib/rubocop/cop/naming/predicate_name.rb +2 -1
  117. data/lib/rubocop/cop/naming/variable_number.rb +100 -8
  118. data/lib/rubocop/cop/offense.rb +3 -3
  119. data/lib/rubocop/cop/security/open.rb +12 -10
  120. data/lib/rubocop/cop/style/accessor_grouping.rb +1 -1
  121. data/lib/rubocop/cop/style/and_or.rb +11 -3
  122. data/lib/rubocop/cop/style/arguments_forwarding.rb +142 -0
  123. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +0 -4
  124. data/lib/rubocop/cop/style/case_like_if.rb +0 -4
  125. data/lib/rubocop/cop/style/character_literal.rb +10 -11
  126. data/lib/rubocop/cop/style/class_and_module_children.rb +8 -3
  127. data/lib/rubocop/cop/style/collection_compact.rb +91 -0
  128. data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +169 -0
  129. data/lib/rubocop/cop/style/documentation.rb +12 -1
  130. data/lib/rubocop/cop/style/double_negation.rb +6 -1
  131. data/lib/rubocop/cop/style/float_division.rb +44 -1
  132. data/lib/rubocop/cop/style/format_string.rb +8 -3
  133. data/lib/rubocop/cop/style/format_string_token.rb +47 -2
  134. data/lib/rubocop/cop/style/hash_syntax.rb +3 -3
  135. data/lib/rubocop/cop/style/identical_conditional_branches.rb +7 -2
  136. data/lib/rubocop/cop/style/if_inside_else.rb +37 -1
  137. data/lib/rubocop/cop/style/if_unless_modifier.rb +11 -3
  138. data/lib/rubocop/cop/style/if_with_semicolon.rb +39 -4
  139. data/lib/rubocop/cop/style/infinite_loop.rb +4 -0
  140. data/lib/rubocop/cop/style/ip_addresses.rb +1 -1
  141. data/lib/rubocop/cop/style/keyword_parameters_order.rb +12 -0
  142. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +10 -13
  143. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +8 -13
  144. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +7 -11
  145. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +11 -2
  146. data/lib/rubocop/cop/style/mixin_grouping.rb +0 -4
  147. data/lib/rubocop/cop/style/multiple_comparison.rb +55 -7
  148. data/lib/rubocop/cop/style/negated_if_else_condition.rb +106 -0
  149. data/lib/rubocop/cop/style/nil_lambda.rb +52 -0
  150. data/lib/rubocop/cop/style/numeric_literals.rb +14 -11
  151. data/lib/rubocop/cop/style/perl_backrefs.rb +86 -9
  152. data/lib/rubocop/cop/style/raise_args.rb +21 -6
  153. data/lib/rubocop/cop/style/redundant_argument.rb +88 -0
  154. data/lib/rubocop/cop/style/redundant_condition.rb +2 -1
  155. data/lib/rubocop/cop/style/redundant_parentheses.rb +4 -0
  156. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +7 -1
  157. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +24 -8
  158. data/lib/rubocop/cop/style/redundant_self.rb +3 -0
  159. data/lib/rubocop/cop/style/safe_navigation.rb +16 -4
  160. data/lib/rubocop/cop/style/semicolon.rb +3 -0
  161. data/lib/rubocop/cop/style/single_line_block_params.rb +30 -7
  162. data/lib/rubocop/cop/style/sole_nested_conditional.rb +65 -3
  163. data/lib/rubocop/cop/style/special_global_vars.rb +1 -13
  164. data/lib/rubocop/cop/style/static_class.rb +97 -0
  165. data/lib/rubocop/cop/style/string_concatenation.rb +39 -2
  166. data/lib/rubocop/cop/style/string_literals.rb +14 -8
  167. data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +4 -3
  168. data/lib/rubocop/cop/style/swap_values.rb +108 -0
  169. data/lib/rubocop/cop/style/symbol_proc.rb +5 -3
  170. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +3 -1
  171. data/lib/rubocop/cop/style/while_until_modifier.rb +9 -0
  172. data/lib/rubocop/cop/team.rb +6 -1
  173. data/lib/rubocop/cop/util.rb +6 -2
  174. data/lib/rubocop/cop/variable_force/branch.rb +1 -1
  175. data/lib/rubocop/cop/variable_force/scope.rb +1 -1
  176. data/lib/rubocop/core_ext/hash.rb +20 -0
  177. data/lib/rubocop/ext/regexp_node.rb +36 -11
  178. data/lib/rubocop/ext/regexp_parser.rb +95 -0
  179. data/lib/rubocop/formatter/disabled_config_formatter.rb +21 -6
  180. data/lib/rubocop/formatter/emacs_style_formatter.rb +2 -0
  181. data/lib/rubocop/formatter/formatter_set.rb +2 -1
  182. data/lib/rubocop/formatter/git_hub_actions_formatter.rb +47 -0
  183. data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
  184. data/lib/rubocop/formatter/simple_text_formatter.rb +2 -0
  185. data/lib/rubocop/formatter/tap_formatter.rb +2 -0
  186. data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -1
  187. data/lib/rubocop/lockfile.rb +40 -0
  188. data/lib/rubocop/magic_comment.rb +2 -2
  189. data/lib/rubocop/options.rb +11 -1
  190. data/lib/rubocop/rake_task.rb +2 -2
  191. data/lib/rubocop/rspec/shared_contexts.rb +4 -0
  192. data/lib/rubocop/runner.rb +1 -1
  193. data/lib/rubocop/target_finder.rb +1 -1
  194. data/lib/rubocop/target_ruby.rb +65 -1
  195. data/lib/rubocop/version.rb +56 -6
  196. metadata +50 -9
  197. data/bin/console +0 -10
  198. data/bin/rubocop-profile +0 -32
  199. data/bin/setup +0 -7
@@ -0,0 +1,196 @@
1
+ # Configuration of obsolete/deprecated cops used by `ConfigObsoletion`
2
+
3
+ # Cops that were renamed
4
+ renamed:
5
+ Layout/AlignArguments: Layout/ArgumentAlignment
6
+ Layout/AlignArray: Layout/ArrayAlignment
7
+ Layout/AlignHash: Layout/HashAlignment
8
+ Layout/AlignParameters: Layout/ParameterAlignment
9
+ Layout/IndentArray: Layout/FirstArrayElementIndentation
10
+ Layout/IndentAssignment: Layout/AssignmentIndentation
11
+ Layout/IndentFirstArgument: Layout/FirstArgumentIndentation
12
+ Layout/IndentFirstArrayElement: Layout/FirstArrayElementIndentation
13
+ Layout/IndentFirstHashElement: Layout/FirstHashElementIndentation
14
+ Layout/IndentFirstParameter: Layout/FirstParameterIndentation
15
+ Layout/IndentHash: Layout/FirstHashElementIndentation
16
+ Layout/IndentHeredoc: Layout/HeredocIndentation
17
+ Layout/LeadingBlankLines: Layout/LeadingEmptyLines
18
+ Layout/Tab: Layout/IndentationStyle
19
+ Layout/TrailingBlankLines: Layout/TrailingEmptyLines
20
+ Lint/BlockAlignment: Layout/BlockAlignment
21
+ Lint/DefEndAlignment: Layout/DefEndAlignment
22
+ Lint/DuplicatedKey: Lint/DuplicateHashKey
23
+ Lint/EndAlignment: Layout/EndAlignment
24
+ Lint/EndInMethod: Style/EndBlock
25
+ Lint/Eval: Security/Eval
26
+ Lint/HandleExceptions: Lint/SuppressedException
27
+ Lint/MultipleCompare: Lint/MultipleComparison
28
+ Lint/StringConversionInInterpolation: Lint/RedundantStringCoercion
29
+ Lint/UnneededCopDisableDirective: Lint/RedundantCopDisableDirective
30
+ Lint/UnneededCopEnableDirective: Lint/RedundantCopEnableDirective
31
+ Lint/UnneededRequireStatement: Lint/RedundantRequireStatement
32
+ Lint/UnneededSplatExpansion: Lint/RedundantSplatExpansion
33
+ Metrics/LineLength: Layout/LineLength
34
+ Naming/UncommunicativeBlockParamName: Naming/BlockParameterName
35
+ Naming/UncommunicativeMethodParamName: Naming/MethodParameterName
36
+ Style/AccessorMethodName: Naming/AccessorMethodName
37
+ Style/AsciiIdentifiers: Naming/AsciiIdentifiers
38
+ Style/ClassAndModuleCamelCase: Naming/ClassAndModuleCamelCase
39
+ Style/ConstantName: Naming/ConstantName
40
+ Style/DeprecatedHashMethods: Style/PreferredHashMethods
41
+ Style/FileName: Naming/FileName
42
+ Style/FlipFlop: Lint/FlipFlop
43
+ Style/MethodCallParentheses: Style/MethodCallWithoutArgsParentheses
44
+ Style/MethodName: Naming/MethodName
45
+ Style/OpMethod: Naming/BinaryOperatorParameterName
46
+ Style/PredicateName: Naming/PredicateName
47
+ Style/SingleSpaceBeforeFirstArg: Layout/SpaceBeforeFirstArg
48
+ Style/UnneededCapitalW: Style/RedundantCapitalW
49
+ Style/UnneededCondition: Style/RedundantCondition
50
+ Style/UnneededInterpolation: Style/RedundantInterpolation
51
+ Style/UnneededPercentQ: Style/RedundantPercentQ
52
+ Style/UnneededSort: Style/RedundantSort
53
+ Style/VariableName: Naming/VariableName
54
+ Style/VariableNumber: Naming/VariableNumber
55
+
56
+ # Cops that were removed
57
+ removed:
58
+ Layout/SpaceAfterControlKeyword:
59
+ alternatives: Layout/SpaceAroundKeyword
60
+ Layout/SpaceBeforeModifierKeyword:
61
+ alternatives: Layout/SpaceAroundKeyword
62
+ Lint/InvalidCharacterLiteral:
63
+ reason: it was never being actually triggered
64
+ Lint/RescueWithoutErrorClass:
65
+ alternatives: Style/RescueStandardError
66
+ Lint/SpaceBeforeFirstArg:
67
+ reason: >
68
+ it was a duplicate of `Layout/SpaceBeforeFirstArg`. Please use
69
+ `Layout/SpaceBeforeFirstArg` instead
70
+ Lint/UselessComparison:
71
+ reason: >
72
+ it has been superseded by
73
+ `Lint/BinaryOperatorWithIdenticalOperands`. Please use
74
+ `Lint/BinaryOperatorWithIdenticalOperands` instead
75
+ Style/BracesAroundHashParameters: true
76
+ Style/MethodMissingSuper:
77
+ reason: >
78
+ it has been superseded by `Lint/MissingSuper`. Please use
79
+ `Lint/MissingSuper` instead
80
+ Style/SpaceAfterControlKeyword:
81
+ alternatives: Layout/SpaceAroundKeyword
82
+ Style/SpaceBeforeModifierKeyword:
83
+ alternatives: Layout/SpaceAroundKeyword
84
+ Style/TrailingComma:
85
+ alternatives:
86
+ - Style/TrailingCommaInArguments
87
+ - Style/TrailingCommaInArrayLiteral
88
+ - Style/TrailingCommaInHashLiteral
89
+ Style/TrailingCommaInLiteral:
90
+ alternatives:
91
+ - Style/TrailingCommaInArrayLiteral
92
+ - Style/TrailingCommaInHashLiteral
93
+
94
+ # Cops split into multiple other cops
95
+ split:
96
+ Style/MethodMissing:
97
+ alternatives:
98
+ - Style/MethodMissingSuper
99
+ - Style/MissingRespondToMissing
100
+
101
+ # Cops that were extracted into a different gem
102
+ extracted:
103
+ Performance/*: rubocop-performance
104
+ Rails/*: rubocop-rails
105
+
106
+ # Cop parameters that have been changed
107
+ # Can be treated as a warning instead of a failure with `severity: warning`
108
+ changed_parameters:
109
+ - cops:
110
+ - Layout/SpaceAroundOperators
111
+ - Style/SpaceAroundOperators
112
+ parameters: MultiSpaceAllowedForOperators
113
+ reason: >
114
+ If your intention was to allow extra spaces for alignment, please
115
+ use `AllowForAlignment: true` instead.
116
+ - cops: Style/Encoding
117
+ parameters:
118
+ - EnforcedStyle
119
+ - SupportedStyles
120
+ - AutoCorrectEncodingComment
121
+ reason: '`Style/Encoding` no longer supports styles. The "never" behavior is always assumed.'
122
+ - cops: Style/IfUnlessModifier
123
+ parameters: MaxLineLength
124
+ reason: >
125
+ `Style/IfUnlessModifier: MaxLineLength` has been removed.
126
+ Use `Layout/LineLength: Max` instead
127
+ - cops: Style/WhileUntilModifier
128
+ parameters: MaxLineLength
129
+ reason: >
130
+ `Style/WhileUntilModifier: MaxLineLength` has been removed.
131
+ Use `Layout/LineLength: Max` instead
132
+ - cops: AllCops
133
+ parameters: RunRailsCops
134
+ reason: |-
135
+ Use the following configuration instead:
136
+ Rails:
137
+ Enabled: true
138
+ - cops: Layout/CaseIndentation
139
+ parameters: IndentWhenRelativeTo
140
+ alternative: EnforcedStyle
141
+ - cops:
142
+ - Lint/BlockAlignment
143
+ - Layout/BlockAlignment
144
+ - Lint/EndAlignment
145
+ - Layout/EndAlignment
146
+ - Lint/DefEndAlignment
147
+ - Layout/DefEndAlignment
148
+ parameters: AlignWith
149
+ alternative: EnforcedStyleAlignWith
150
+ - cops: Rails/UniqBeforePluck
151
+ parameters: EnforcedMode
152
+ alternative: EnforcedStyle
153
+ - cops: Style/MethodCallWithArgsParentheses
154
+ parameters: IgnoredMethodPatterns
155
+ alternative: IgnoredPatterns
156
+ - cops:
157
+ - Performance/Count
158
+ - Performance/Detect
159
+ parameters: SafeMode
160
+ reason: "`SafeMode` has been removed. Use `SafeAutoCorrect` instead."
161
+ - cops: Bundler/GemComment
162
+ parameters: Whitelist
163
+ alternative: IgnoredGems
164
+ - cops:
165
+ - Lint/SafeNavigationChain
166
+ - Lint/SafeNavigationConsistency
167
+ - Style/NestedParenthesizedCalls
168
+ - Style/SafeNavigation
169
+ - Style/TrivialAccessors
170
+ parameters: Whitelist
171
+ alternative: AllowedMethods
172
+ - cops: Style/IpAddresses
173
+ parameters: Whitelist
174
+ alternative: AllowedAddresses
175
+ - cops: Naming/HeredocDelimiterNaming
176
+ parameters: Blacklist
177
+ alternative: ForbiddenDelimiters
178
+ - cops: Naming/PredicateName
179
+ parameters: NamePrefixBlacklist
180
+ alternative: ForbiddenPrefixes
181
+ - cops: Naming/PredicateName
182
+ parameters: NameWhitelist
183
+ alternative: AllowedMethods
184
+ - cops:
185
+ - Metrics/BlockLength
186
+ - Metrics/MethodLength
187
+ parameters: ExcludedMethods
188
+ alternative: IgnoredMethods
189
+ severity: warning
190
+
191
+ # Enforced styles that have been removed or replaced
192
+ changed_enforced_styles:
193
+ - cops: Layout/IndentationConsistency
194
+ parameters: EnforcedStyle
195
+ value: rails
196
+ alternative: indented_internal_methods
@@ -13,5 +13,5 @@ time = Benchmark.realtime do
13
13
  result = cli.run
14
14
  end
15
15
 
16
- puts "Finished in #{time} seconds" if cli.options[:debug]
16
+ puts "Finished in #{time} seconds" if cli.options[:debug] || cli.options[:display_time]
17
17
  exit result
@@ -15,8 +15,10 @@ require 'rubocop-ast'
15
15
 
16
16
  require_relative 'rubocop/ast_aliases'
17
17
  require_relative 'rubocop/ext/regexp_node'
18
+ require_relative 'rubocop/ext/regexp_parser'
18
19
 
19
20
  require_relative 'rubocop/core_ext/string'
21
+ require_relative 'rubocop/core_ext/hash'
20
22
  require_relative 'rubocop/ext/processed_source'
21
23
 
22
24
  require_relative 'rubocop/path_util'
@@ -87,6 +89,7 @@ require_relative 'rubocop/cop/mixin/interpolation'
87
89
  require_relative 'rubocop/cop/mixin/line_length_help'
88
90
  require_relative 'rubocop/cop/mixin/match_range'
89
91
  require_relative 'rubocop/cop/metrics/utils/repeated_csend_discount'
92
+ require_relative 'rubocop/cop/metrics/utils/repeated_attribute_discount'
90
93
  require_relative 'rubocop/cop/mixin/method_complexity'
91
94
  require_relative 'rubocop/cop/mixin/method_preference'
92
95
  require_relative 'rubocop/cop/mixin/min_body_length'
@@ -258,14 +261,18 @@ require_relative 'rubocop/cop/lint/debugger'
258
261
  require_relative 'rubocop/cop/lint/deprecated_class_methods'
259
262
  require_relative 'rubocop/cop/lint/deprecated_open_ssl_constant'
260
263
  require_relative 'rubocop/cop/lint/disjunctive_assignment_in_constructor'
264
+ require_relative 'rubocop/cop/lint/duplicate_branch'
261
265
  require_relative 'rubocop/cop/lint/duplicate_case_condition'
262
266
  require_relative 'rubocop/cop/lint/duplicate_elsif_condition'
263
267
  require_relative 'rubocop/cop/lint/duplicate_hash_key'
264
268
  require_relative 'rubocop/cop/lint/duplicate_methods'
269
+ require_relative 'rubocop/cop/lint/duplicate_regexp_character_class_element'
265
270
  require_relative 'rubocop/cop/lint/duplicate_require'
266
271
  require_relative 'rubocop/cop/lint/duplicate_rescue_exception'
267
272
  require_relative 'rubocop/cop/lint/each_with_object_argument'
268
273
  require_relative 'rubocop/cop/lint/else_layout'
274
+ require_relative 'rubocop/cop/lint/empty_block'
275
+ require_relative 'rubocop/cop/lint/empty_class'
269
276
  require_relative 'rubocop/cop/lint/empty_conditional_body'
270
277
  require_relative 'rubocop/cop/lint/empty_ensure'
271
278
  require_relative 'rubocop/cop/lint/empty_expression'
@@ -295,6 +302,7 @@ require_relative 'rubocop/cop/lint/multiple_comparison'
295
302
  require_relative 'rubocop/cop/lint/nested_method_definition'
296
303
  require_relative 'rubocop/cop/lint/nested_percent_literal'
297
304
  require_relative 'rubocop/cop/lint/next_without_accumulator'
305
+ require_relative 'rubocop/cop/lint/no_return_in_begin_end_blocks'
298
306
  require_relative 'rubocop/cop/lint/non_deterministic_require_order'
299
307
  require_relative 'rubocop/cop/lint/non_local_exit_from_iterator'
300
308
  require_relative 'rubocop/cop/lint/number_conversion'
@@ -330,11 +338,14 @@ require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
330
338
  require_relative 'rubocop/cop/lint/struct_new_override'
331
339
  require_relative 'rubocop/cop/lint/suppressed_exception'
332
340
  require_relative 'rubocop/cop/lint/syntax'
341
+ require_relative 'rubocop/cop/lint/to_enum_arguments'
333
342
  require_relative 'rubocop/cop/lint/to_json'
334
343
  require_relative 'rubocop/cop/lint/top_level_return_with_argument'
335
344
  require_relative 'rubocop/cop/lint/trailing_comma_in_attribute_declaration'
336
345
  require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
346
+ require_relative 'rubocop/cop/lint/unexpected_block_arity'
337
347
  require_relative 'rubocop/cop/lint/unified_integer'
348
+ require_relative 'rubocop/cop/lint/unmodified_reduce_accumulator'
338
349
  require_relative 'rubocop/cop/lint/unreachable_code'
339
350
  require_relative 'rubocop/cop/lint/unreachable_loop'
340
351
  require_relative 'rubocop/cop/lint/unused_block_argument'
@@ -384,6 +395,7 @@ require_relative 'rubocop/cop/style/access_modifier_declarations'
384
395
  require_relative 'rubocop/cop/style/accessor_grouping'
385
396
  require_relative 'rubocop/cop/style/alias'
386
397
  require_relative 'rubocop/cop/style/and_or'
398
+ require_relative 'rubocop/cop/style/arguments_forwarding'
387
399
  require_relative 'rubocop/cop/style/array_coercion'
388
400
  require_relative 'rubocop/cop/style/array_join'
389
401
  require_relative 'rubocop/cop/style/ascii_comments'
@@ -403,6 +415,7 @@ require_relative 'rubocop/cop/style/class_equality_comparison'
403
415
  require_relative 'rubocop/cop/style/class_methods'
404
416
  require_relative 'rubocop/cop/style/class_methods_definitions'
405
417
  require_relative 'rubocop/cop/style/class_vars'
418
+ require_relative 'rubocop/cop/style/collection_compact'
406
419
  require_relative 'rubocop/cop/style/collection_methods'
407
420
  require_relative 'rubocop/cop/style/colon_method_call'
408
421
  require_relative 'rubocop/cop/style/colon_method_definition'
@@ -419,6 +432,7 @@ require_relative 'rubocop/cop/style/dir'
419
432
  require_relative 'rubocop/cop/style/disable_cops_within_source_code_directive'
420
433
  require_relative 'rubocop/cop/style/documentation_method'
421
434
  require_relative 'rubocop/cop/style/documentation'
435
+ require_relative 'rubocop/cop/style/document_dynamic_eval_definition'
422
436
  require_relative 'rubocop/cop/style/double_cop_disable_directive'
423
437
  require_relative 'rubocop/cop/style/double_negation'
424
438
  require_relative 'rubocop/cop/style/each_for_simple_loop'
@@ -471,8 +485,7 @@ require_relative 'rubocop/cop/style/redundant_fetch_block'
471
485
  require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
472
486
  require_relative 'rubocop/cop/style/redundant_self_assignment'
473
487
  require_relative 'rubocop/cop/style/sole_nested_conditional'
474
- require_relative 'rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses'
475
- require_relative 'rubocop/cop/style/method_call_with_args_parentheses/require_parentheses'
488
+ require_relative 'rubocop/cop/style/static_class'
476
489
  require_relative 'rubocop/cop/style/method_called_on_do_end_block'
477
490
  require_relative 'rubocop/cop/style/method_def_parentheses'
478
491
  require_relative 'rubocop/cop/style/min_max'
@@ -491,6 +504,7 @@ require_relative 'rubocop/cop/style/multiline_when_then'
491
504
  require_relative 'rubocop/cop/style/multiple_comparison'
492
505
  require_relative 'rubocop/cop/style/mutable_constant'
493
506
  require_relative 'rubocop/cop/style/negated_if'
507
+ require_relative 'rubocop/cop/style/negated_if_else_condition'
494
508
  require_relative 'rubocop/cop/style/negated_unless'
495
509
  require_relative 'rubocop/cop/style/negated_while'
496
510
  require_relative 'rubocop/cop/style/nested_modifier'
@@ -498,6 +512,7 @@ require_relative 'rubocop/cop/style/nested_parenthesized_calls'
498
512
  require_relative 'rubocop/cop/style/nested_ternary_operator'
499
513
  require_relative 'rubocop/cop/style/next'
500
514
  require_relative 'rubocop/cop/style/nil_comparison'
515
+ require_relative 'rubocop/cop/style/nil_lambda'
501
516
  require_relative 'rubocop/cop/style/non_nil_check'
502
517
  require_relative 'rubocop/cop/style/not'
503
518
  require_relative 'rubocop/cop/style/numeric_literals'
@@ -517,6 +532,7 @@ require_relative 'rubocop/cop/style/preferred_hash_methods'
517
532
  require_relative 'rubocop/cop/style/proc'
518
533
  require_relative 'rubocop/cop/style/raise_args'
519
534
  require_relative 'rubocop/cop/style/random_with_offset'
535
+ require_relative 'rubocop/cop/style/redundant_argument'
520
536
  require_relative 'rubocop/cop/style/redundant_begin'
521
537
  require_relative 'rubocop/cop/style/redundant_capital_w'
522
538
  require_relative 'rubocop/cop/style/redundant_condition'
@@ -556,6 +572,7 @@ require_relative 'rubocop/cop/style/string_literals_in_interpolation'
556
572
  require_relative 'rubocop/cop/style/string_methods'
557
573
  require_relative 'rubocop/cop/style/strip'
558
574
  require_relative 'rubocop/cop/style/struct_inheritance'
575
+ require_relative 'rubocop/cop/style/swap_values'
559
576
  require_relative 'rubocop/cop/style/symbol_array'
560
577
  require_relative 'rubocop/cop/style/symbol_literal'
561
578
  require_relative 'rubocop/cop/style/symbol_proc'
@@ -596,6 +613,7 @@ require_relative 'rubocop/formatter/disabled_config_formatter'
596
613
  require_relative 'rubocop/formatter/emacs_style_formatter'
597
614
  require_relative 'rubocop/formatter/file_list_formatter'
598
615
  require_relative 'rubocop/formatter/fuubar_style_formatter'
616
+ require_relative 'rubocop/formatter/git_hub_actions_formatter'
599
617
  require_relative 'rubocop/formatter/html_formatter'
600
618
  require_relative 'rubocop/formatter/json_formatter'
601
619
  require_relative 'rubocop/formatter/junit_formatter'
@@ -614,9 +632,19 @@ require_relative 'rubocop/cached_data'
614
632
  require_relative 'rubocop/config'
615
633
  require_relative 'rubocop/config_loader_resolver'
616
634
  require_relative 'rubocop/config_loader'
635
+ require_relative 'rubocop/config_obsoletion/rule'
636
+ require_relative 'rubocop/config_obsoletion/cop_rule'
637
+ require_relative 'rubocop/config_obsoletion/parameter_rule'
638
+ require_relative 'rubocop/config_obsoletion/changed_enforced_styles'
639
+ require_relative 'rubocop/config_obsoletion/changed_parameter'
640
+ require_relative 'rubocop/config_obsoletion/extracted_cop'
641
+ require_relative 'rubocop/config_obsoletion/removed_cop'
642
+ require_relative 'rubocop/config_obsoletion/renamed_cop'
643
+ require_relative 'rubocop/config_obsoletion/split_cop'
617
644
  require_relative 'rubocop/config_obsoletion'
618
645
  require_relative 'rubocop/config_store'
619
646
  require_relative 'rubocop/config_validator'
647
+ require_relative 'rubocop/lockfile'
620
648
  require_relative 'rubocop/target_finder'
621
649
  require_relative 'rubocop/directive_comment'
622
650
  require_relative 'rubocop/comment_config'
@@ -631,6 +659,7 @@ require_relative 'rubocop/cli/command/auto_genenerate_config'
631
659
  require_relative 'rubocop/cli/command/execute_runner'
632
660
  require_relative 'rubocop/cli/command/init_dotfile'
633
661
  require_relative 'rubocop/cli/command/show_cops'
662
+ require_relative 'rubocop/cli/command/suggest_extensions'
634
663
  require_relative 'rubocop/cli/command/version'
635
664
  require_relative 'rubocop/config_regeneration'
636
665
  require_relative 'rubocop/options'
@@ -69,10 +69,14 @@ module RuboCop
69
69
  if @options[:auto_gen_config]
70
70
  run_command(:auto_gen_config)
71
71
  else
72
- run_command(:execute_runner)
72
+ run_command(:execute_runner).tap { suggest_extensions }
73
73
  end
74
74
  end
75
75
 
76
+ def suggest_extensions
77
+ run_command(:suggest_extensions)
78
+ end
79
+
76
80
  def validate_options_vs_config
77
81
  if @options[:parallel] &&
78
82
  !@config_store.for_pwd.for_all_cops['UseCache']
@@ -90,7 +90,7 @@ module RuboCop
90
90
  def reset_config_and_auto_gen_file
91
91
  @config_store = ConfigStore.new
92
92
  @config_store.options_config = @options[:config] if @options[:config]
93
- File.open(AUTO_GENERATED_FILE, 'w') {}
93
+ File.open(AUTO_GENERATED_FILE, 'w') {} # create or truncate if exists
94
94
  add_inheritance_from_auto_generated_file(@options[:config])
95
95
  end
96
96
 
@@ -22,12 +22,13 @@ module RuboCop
22
22
  def execute_runner(paths)
23
23
  runner = Runner.new(@options, @config_store)
24
24
 
25
- all_passed = runner.run(paths)
26
- display_warning_summary(runner.warnings)
27
- display_error_summary(runner.errors)
28
- maybe_print_corrected_source
25
+ all_pass_or_excluded = with_redirect do
26
+ all_passed = runner.run(paths)
27
+ display_summary(runner)
28
+ all_passed || @options[:auto_gen_config]
29
+ end
29
30
 
30
- all_pass_or_excluded = all_passed || @options[:auto_gen_config]
31
+ maybe_print_corrected_source
31
32
 
32
33
  if runner.aborting?
33
34
  STATUS_INTERRUPTED
@@ -38,6 +39,25 @@ module RuboCop
38
39
  end
39
40
  end
40
41
 
42
+ def with_redirect
43
+ if @options[:stderr]
44
+ orig_stdout = $stdout.dup
45
+ $stdout.reopen($stderr)
46
+
47
+ result = yield
48
+
49
+ $stdout.reopen(orig_stdout)
50
+ result
51
+ else
52
+ yield
53
+ end
54
+ end
55
+
56
+ def display_summary(runner)
57
+ display_warning_summary(runner.warnings)
58
+ display_error_summary(runner.errors)
59
+ end
60
+
41
61
  def display_warning_summary(warnings)
42
62
  return if warnings.empty?
43
63
 
@@ -69,14 +89,9 @@ module RuboCop
69
89
  # See: https://github.com/rubocop-hq/rubocop/issues/8673
70
90
  return if INTEGRATION_FORMATTERS.include?(@options[:format])
71
91
 
72
- # If we are asked to autocorrect source code read from stdin, the only
73
- # reasonable place to write it is to stdout
74
- # Unfortunately, we also write other information to stdout
75
- # So a delimiter is needed for tools to easily identify where the
76
- # autocorrected source begins
77
92
  return unless @options[:stdin] && @options[:auto_correct]
78
93
 
79
- puts '=' * 20
94
+ (@options[:stderr] ? $stderr : $stdout).puts '=' * 20
80
95
  print @options[:stdin]
81
96
  end
82
97
  end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ class CLI
5
+ module Command
6
+ # Suggest RuboCop extensions to install based on Gemfile dependencies.
7
+ # Only primary dependencies are evaluated, so if a dependency depends on a
8
+ # gem with an extension, it is not suggested. However, if an extension is
9
+ # a transitive dependency, it will not be suggested.
10
+ # @api private
11
+ class SuggestExtensions < Base
12
+ # Combination of short and long formatter names.
13
+ INCLUDED_FORMATTERS = %w[p progress fu fuubar pa pacman].freeze
14
+
15
+ self.command_name = :suggest_extensions
16
+
17
+ def run
18
+ return if skip? || extensions.none?
19
+
20
+ puts
21
+ puts 'Tip: Based on detected gems, the following '\
22
+ 'RuboCop extension libraries might be helpful:'
23
+
24
+ extensions.sort.each do |extension|
25
+ puts " * #{extension} (http://github.com/rubocop-hq/#{extension})"
26
+ end
27
+
28
+ puts
29
+ puts 'You can opt out of this message by adding the following to your config '\
30
+ '(see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions '\
31
+ 'for more options):'
32
+ puts ' AllCops:'
33
+ puts ' SuggestExtensions: false'
34
+
35
+ puts if @options[:display_time]
36
+ end
37
+
38
+ private
39
+
40
+ def skip?
41
+ # Disable outputting the notification:
42
+ # 1. On CI
43
+ # 2. When given RuboCop options that it doesn't make sense for
44
+ # 3. For all formatters except specified in `INCLUDED_FORMATTERS'`
45
+ ENV['CI'] ||
46
+ @options[:only] || @options[:debug] || @options[:list_target_files] || @options[:out] ||
47
+ !INCLUDED_FORMATTERS.include?(current_formatter)
48
+ end
49
+
50
+ def current_formatter
51
+ @options[:format] || @config_store.for_pwd.for_all_cops['DefaultFormatter'] || 'p'
52
+ end
53
+
54
+ def extensions
55
+ return [] unless lockfile.dependencies.any?
56
+
57
+ extensions = @config_store.for_pwd.for_all_cops['SuggestExtensions'] || {}
58
+ extensions.select { |_, v| (Array(v) & dependent_gems).any? }.keys - installed_gems
59
+ end
60
+
61
+ def lockfile
62
+ @lockfile ||= Lockfile.new
63
+ end
64
+
65
+ def dependent_gems
66
+ lockfile.dependencies.map(&:name)
67
+ end
68
+
69
+ def installed_gems
70
+ lockfile.gems.map(&:name)
71
+ end
72
+
73
+ def puts(*args)
74
+ output = (@options[:stderr] ? $stderr : $stdout)
75
+ output.puts(*args)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end