rubocop 0.73.0 → 0.77.0
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.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/bin/console +1 -0
- data/config/default.yml +332 -295
- data/lib/rubocop.rb +46 -30
- data/lib/rubocop/ast/builder.rb +1 -0
- data/lib/rubocop/ast/node.rb +6 -8
- data/lib/rubocop/ast/node/block_node.rb +2 -0
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +1 -12
- data/lib/rubocop/ast/node/return_node.rb +24 -0
- data/lib/rubocop/cli.rb +11 -227
- data/lib/rubocop/cli/command.rb +21 -0
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +105 -0
- data/lib/rubocop/cli/command/base.rb +33 -0
- data/lib/rubocop/cli/command/execute_runner.rb +76 -0
- data/lib/rubocop/cli/command/init_dotfile.rb +45 -0
- data/lib/rubocop/cli/command/show_cops.rb +73 -0
- data/lib/rubocop/cli/command/version.rb +17 -0
- data/lib/rubocop/cli/environment.rb +21 -0
- data/lib/rubocop/comment_config.rb +5 -4
- data/lib/rubocop/config.rb +28 -537
- data/lib/rubocop/config_loader.rb +21 -3
- data/lib/rubocop/config_loader_resolver.rb +4 -3
- data/lib/rubocop/config_obsoletion.rb +275 -0
- data/lib/rubocop/config_validator.rb +246 -0
- data/lib/rubocop/cop/autocorrect_logic.rb +2 -2
- data/lib/rubocop/cop/bundler/gem_comment.rb +4 -4
- data/lib/rubocop/cop/commissioner.rb +15 -7
- data/lib/rubocop/cop/cop.rb +33 -9
- data/lib/rubocop/cop/corrector.rb +8 -7
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +43 -17
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/space_corrector.rb +1 -2
- data/lib/rubocop/cop/generator.rb +3 -3
- data/lib/rubocop/cop/generator/configuration_injector.rb +9 -4
- data/lib/rubocop/cop/generator/require_file_injector.rb +1 -1
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +59 -0
- data/lib/rubocop/cop/layout/{align_arguments.rb → argument_alignment.rb} +1 -1
- data/lib/rubocop/cop/layout/{align_array.rb → array_alignment.rb} +1 -1
- data/lib/rubocop/cop/layout/{indent_assignment.rb → assignment_indentation.rb} +11 -2
- data/lib/rubocop/cop/layout/block_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/comment_indentation.rb +10 -13
- data/lib/rubocop/cop/layout/empty_comment.rb +7 -16
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +22 -7
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +2 -2
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +2 -2
- data/lib/rubocop/cop/layout/end_of_line.rb +8 -3
- data/lib/rubocop/cop/layout/extra_spacing.rb +15 -60
- data/lib/rubocop/cop/layout/{indent_first_argument.rb → first_argument_indentation.rb} +12 -10
- data/lib/rubocop/cop/layout/{indent_first_array_element.rb → first_array_element_indentation.rb} +4 -4
- data/lib/rubocop/cop/layout/{indent_first_hash_element.rb → first_hash_element_indentation.rb} +4 -4
- data/lib/rubocop/cop/layout/{indent_first_parameter.rb → first_parameter_indentation.rb} +3 -3
- data/lib/rubocop/cop/layout/{align_hash.rb → hash_alignment.rb} +8 -4
- data/lib/rubocop/cop/layout/{indent_heredoc.rb → heredoc_indentation.rb} +2 -2
- data/lib/rubocop/cop/layout/indentation_width.rb +19 -5
- data/lib/rubocop/cop/layout/{leading_blank_lines.rb → leading_empty_lines.rb} +1 -1
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +24 -2
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +1 -1
- data/lib/rubocop/cop/layout/{align_parameters.rb → parameter_alignment.rb} +1 -1
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +2 -0
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +5 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +12 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +43 -24
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +9 -7
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +8 -5
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +7 -0
- data/lib/rubocop/cop/layout/space_inside_parens.rb +6 -6
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +24 -40
- data/lib/rubocop/cop/layout/{trailing_blank_lines.rb → trailing_empty_lines.rb} +1 -1
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +18 -2
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +17 -4
- data/lib/rubocop/cop/lint/debugger.rb +1 -3
- data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +1 -1
- data/lib/rubocop/cop/lint/{duplicated_key.rb → duplicate_hash_key.rb} +1 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +4 -4
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +61 -4
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +10 -36
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +7 -8
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +2 -2
- data/lib/rubocop/cop/lint/{multiple_compare.rb → multiple_comparison.rb} +1 -1
- data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/{unneeded_cop_disable_directive.rb → redundant_cop_disable_directive.rb} +24 -24
- data/lib/rubocop/cop/lint/{unneeded_cop_enable_directive.rb → redundant_cop_enable_directive.rb} +6 -8
- data/lib/rubocop/cop/lint/{unneeded_require_statement.rb → redundant_require_statement.rb} +1 -1
- data/lib/rubocop/cop/lint/{unneeded_splat_expansion.rb → redundant_splat_expansion.rb} +12 -7
- data/lib/rubocop/cop/lint/{string_conversion_in_interpolation.rb → redundant_string_coercion.rb} +7 -7
- data/lib/rubocop/cop/lint/redundant_with_index.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +5 -6
- data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +91 -0
- data/lib/rubocop/cop/lint/{handle_exceptions.rb → suppressed_exception.rb} +1 -1
- data/lib/rubocop/cop/lint/unused_block_argument.rb +22 -6
- data/lib/rubocop/cop/lint/unused_method_argument.rb +23 -5
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +57 -23
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +7 -26
- data/lib/rubocop/cop/message_annotator.rb +16 -7
- data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
- data/lib/rubocop/cop/metrics/line_length.rb +48 -42
- data/lib/rubocop/cop/metrics/method_length.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +23 -6
- data/lib/rubocop/cop/migration/department_name.rb +44 -0
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/documentation_comment.rb +0 -2
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/{hash_alignment.rb → hash_alignment_styles.rb} +1 -1
- data/lib/rubocop/cop/mixin/interpolation.rb +27 -0
- data/lib/rubocop/cop/mixin/method_complexity.rb +2 -1
- data/lib/rubocop/cop/mixin/nil_methods.rb +4 -4
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +87 -0
- data/lib/rubocop/cop/mixin/statement_modifier.rb +5 -2
- data/lib/rubocop/cop/mixin/surrounding_space.rb +7 -5
- data/lib/rubocop/cop/mixin/trailing_comma.rb +8 -6
- data/lib/rubocop/cop/naming/{uncommunicative_block_param_name.rb → block_parameter_name.rb} +3 -3
- data/lib/rubocop/cop/naming/file_name.rb +12 -5
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +5 -5
- data/lib/rubocop/cop/naming/method_name.rb +12 -1
- data/lib/rubocop/cop/naming/{uncommunicative_method_param_name.rb → method_parameter_name.rb} +3 -3
- data/lib/rubocop/cop/naming/predicate_name.rb +6 -6
- data/lib/rubocop/cop/naming/variable_name.rb +1 -0
- data/lib/rubocop/cop/offense.rb +18 -7
- data/lib/rubocop/cop/registry.rb +22 -1
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -0
- data/lib/rubocop/cop/style/alias.rb +1 -1
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/attr.rb +2 -2
- data/lib/rubocop/cop/style/block_delimiters.rb +2 -1
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +35 -16
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +5 -5
- data/lib/rubocop/cop/style/commented_keyword.rb +16 -30
- data/lib/rubocop/cop/style/conditional_assignment.rb +5 -7
- data/lib/rubocop/cop/style/constant_visibility.rb +13 -2
- data/lib/rubocop/cop/style/copyright.rb +11 -7
- data/lib/rubocop/cop/style/documentation_method.rb +44 -0
- data/lib/rubocop/cop/style/double_cop_disable_directive.rb +10 -4
- data/lib/rubocop/cop/style/empty_case_condition.rb +2 -2
- data/lib/rubocop/cop/style/empty_literal.rb +2 -2
- data/lib/rubocop/cop/style/empty_method.rb +5 -5
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/expand_path_arguments.rb +1 -1
- data/lib/rubocop/cop/style/format_string.rb +10 -7
- data/lib/rubocop/cop/style/format_string_token.rb +19 -68
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +28 -33
- data/lib/rubocop/cop/style/guard_clause.rb +39 -10
- data/lib/rubocop/cop/style/hash_syntax.rb +2 -2
- data/lib/rubocop/cop/style/if_unless_modifier.rb +58 -15
- data/lib/rubocop/cop/style/infinite_loop.rb +5 -4
- data/lib/rubocop/cop/style/inverse_methods.rb +19 -13
- data/lib/rubocop/cop/style/ip_addresses.rb +4 -4
- data/lib/rubocop/cop/style/lambda.rb +0 -2
- data/lib/rubocop/cop/style/line_end_concatenation.rb +14 -10
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +25 -25
- data/lib/rubocop/cop/style/method_def_parentheses.rb +17 -9
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/mixin_usage.rb +11 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +1 -1
- data/lib/rubocop/cop/style/nested_modifier.rb +22 -4
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +5 -5
- data/lib/rubocop/cop/style/next.rb +5 -5
- data/lib/rubocop/cop/style/non_nil_check.rb +21 -9
- data/lib/rubocop/cop/style/numeric_literals.rb +7 -3
- data/lib/rubocop/cop/style/option_hash.rb +3 -3
- data/lib/rubocop/cop/style/or_assignment.rb +6 -1
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +14 -0
- data/lib/rubocop/cop/style/{unneeded_capital_w.rb → redundant_capital_w.rb} +1 -1
- data/lib/rubocop/cop/style/{unneeded_condition.rb → redundant_condition.rb} +3 -3
- data/lib/rubocop/cop/style/{unneeded_interpolation.rb → redundant_interpolation.rb} +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +16 -7
- data/lib/rubocop/cop/style/{unneeded_percent_q.rb → redundant_percent_q.rb} +1 -1
- data/lib/rubocop/cop/style/redundant_return.rb +39 -29
- data/lib/rubocop/cop/style/redundant_self.rb +18 -1
- data/lib/rubocop/cop/style/{unneeded_sort.rb → redundant_sort.rb} +5 -5
- data/lib/rubocop/cop/style/rescue_modifier.rb +24 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +23 -3
- data/lib/rubocop/cop/style/semicolon.rb +13 -2
- data/lib/rubocop/cop/style/single_line_methods.rb +8 -1
- data/lib/rubocop/cop/style/special_global_vars.rb +5 -7
- data/lib/rubocop/cop/style/ternary_parentheses.rb +19 -0
- data/lib/rubocop/cop/style/trailing_method_end_statement.rb +4 -6
- data/lib/rubocop/cop/style/trivial_accessors.rb +5 -5
- data/lib/rubocop/cop/style/variable_interpolation.rb +6 -16
- data/lib/rubocop/cop/team.rb +5 -0
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/utils/format_string.rb +120 -0
- data/lib/rubocop/cop/variable_force.rb +7 -5
- data/lib/rubocop/cop/variable_force/variable.rb +15 -2
- data/lib/rubocop/core_ext/string.rb +0 -24
- data/lib/rubocop/formatter/clang_style_formatter.rb +9 -6
- data/lib/rubocop/formatter/emacs_style_formatter.rb +22 -9
- data/lib/rubocop/formatter/file_list_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +16 -15
- data/lib/rubocop/formatter/pacman_formatter.rb +80 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +16 -4
- data/lib/rubocop/formatter/tap_formatter.rb +18 -7
- data/lib/rubocop/magic_comment.rb +4 -0
- data/lib/rubocop/node_pattern.rb +3 -1
- data/lib/rubocop/options.rb +17 -22
- data/lib/rubocop/path_util.rb +1 -1
- data/lib/rubocop/processed_source.rb +5 -1
- data/lib/rubocop/rake_task.rb +1 -0
- data/lib/rubocop/result_cache.rb +22 -8
- data/lib/rubocop/rspec/expect_offense.rb +4 -1
- data/lib/rubocop/runner.rb +55 -32
- data/lib/rubocop/target_finder.rb +12 -6
- data/lib/rubocop/version.rb +1 -1
- metadata +47 -32
- data/lib/rubocop/cop/mixin/ignored_method_patterns.rb +0 -19
- data/lib/rubocop/cop/mixin/safe_mode.rb +0 -22
data/lib/rubocop.rb
CHANGED
@@ -55,6 +55,7 @@ require_relative 'rubocop/ast/node/range_node'
|
|
55
55
|
require_relative 'rubocop/ast/node/regexp_node'
|
56
56
|
require_relative 'rubocop/ast/node/resbody_node'
|
57
57
|
require_relative 'rubocop/ast/node/retry_node'
|
58
|
+
require_relative 'rubocop/ast/node/return_node'
|
58
59
|
require_relative 'rubocop/ast/node/self_class_node'
|
59
60
|
require_relative 'rubocop/ast/node/send_node'
|
60
61
|
require_relative 'rubocop/ast/node/str_node'
|
@@ -117,11 +118,11 @@ require_relative 'rubocop/cop/mixin/end_keyword_alignment'
|
|
117
118
|
require_relative 'rubocop/cop/mixin/enforce_superclass'
|
118
119
|
require_relative 'rubocop/cop/mixin/first_element_line_break'
|
119
120
|
require_relative 'rubocop/cop/mixin/frozen_string_literal'
|
120
|
-
require_relative 'rubocop/cop/mixin/
|
121
|
+
require_relative 'rubocop/cop/mixin/hash_alignment_styles'
|
121
122
|
require_relative 'rubocop/cop/mixin/ignored_pattern'
|
122
123
|
require_relative 'rubocop/cop/mixin/ignored_methods'
|
123
|
-
require_relative 'rubocop/cop/mixin/ignored_method_patterns'
|
124
124
|
require_relative 'rubocop/cop/mixin/integer_node'
|
125
|
+
require_relative 'rubocop/cop/mixin/interpolation'
|
125
126
|
require_relative 'rubocop/cop/mixin/match_range'
|
126
127
|
require_relative 'rubocop/cop/mixin/method_complexity'
|
127
128
|
require_relative 'rubocop/cop/mixin/method_preference'
|
@@ -143,7 +144,6 @@ require_relative 'rubocop/cop/mixin/preceding_following_alignment'
|
|
143
144
|
require_relative 'rubocop/cop/mixin/preferred_delimiters'
|
144
145
|
require_relative 'rubocop/cop/mixin/rescue_node'
|
145
146
|
require_relative 'rubocop/cop/mixin/safe_assignment'
|
146
|
-
require_relative 'rubocop/cop/mixin/safe_mode'
|
147
147
|
require_relative 'rubocop/cop/mixin/space_after_punctuation'
|
148
148
|
require_relative 'rubocop/cop/mixin/space_before_punctuation'
|
149
149
|
require_relative 'rubocop/cop/mixin/surrounding_space'
|
@@ -157,6 +157,10 @@ require_relative 'rubocop/cop/mixin/trailing_comma'
|
|
157
157
|
require_relative 'rubocop/cop/mixin/uncommunicative_name'
|
158
158
|
require_relative 'rubocop/cop/mixin/unused_argument'
|
159
159
|
|
160
|
+
require_relative 'rubocop/cop/utils/format_string'
|
161
|
+
|
162
|
+
require_relative 'rubocop/cop/migration/department_name'
|
163
|
+
|
160
164
|
require_relative 'rubocop/cop/correctors/alignment_corrector'
|
161
165
|
require_relative 'rubocop/cop/correctors/condition_corrector'
|
162
166
|
require_relative 'rubocop/cop/correctors/each_to_for_corrector'
|
@@ -184,10 +188,9 @@ require_relative 'rubocop/cop/gemspec/required_ruby_version'
|
|
184
188
|
require_relative 'rubocop/cop/gemspec/ruby_version_globals_usage'
|
185
189
|
|
186
190
|
require_relative 'rubocop/cop/layout/access_modifier_indentation'
|
187
|
-
require_relative 'rubocop/cop/layout/
|
188
|
-
require_relative 'rubocop/cop/layout/
|
189
|
-
require_relative 'rubocop/cop/layout/
|
190
|
-
require_relative 'rubocop/cop/layout/align_parameters'
|
191
|
+
require_relative 'rubocop/cop/layout/argument_alignment'
|
192
|
+
require_relative 'rubocop/cop/layout/array_alignment'
|
193
|
+
require_relative 'rubocop/cop/layout/assignment_indentation'
|
191
194
|
require_relative 'rubocop/cop/layout/block_alignment'
|
192
195
|
require_relative 'rubocop/cop/layout/block_end_newline'
|
193
196
|
require_relative 'rubocop/cop/layout/case_indentation'
|
@@ -215,22 +218,22 @@ require_relative 'rubocop/cop/layout/empty_lines'
|
|
215
218
|
require_relative 'rubocop/cop/layout/end_alignment'
|
216
219
|
require_relative 'rubocop/cop/layout/end_of_line'
|
217
220
|
require_relative 'rubocop/cop/layout/extra_spacing'
|
221
|
+
require_relative 'rubocop/cop/layout/first_argument_indentation'
|
222
|
+
require_relative 'rubocop/cop/layout/first_array_element_indentation'
|
218
223
|
require_relative 'rubocop/cop/layout/first_array_element_line_break'
|
224
|
+
require_relative 'rubocop/cop/layout/first_hash_element_indentation'
|
219
225
|
require_relative 'rubocop/cop/layout/first_hash_element_line_break'
|
220
226
|
require_relative 'rubocop/cop/layout/first_method_argument_line_break'
|
221
227
|
require_relative 'rubocop/cop/layout/first_method_parameter_line_break'
|
228
|
+
require_relative 'rubocop/cop/layout/first_parameter_indentation'
|
229
|
+
require_relative 'rubocop/cop/layout/hash_alignment'
|
222
230
|
require_relative 'rubocop/cop/layout/heredoc_argument_closing_parenthesis'
|
223
|
-
require_relative 'rubocop/cop/layout/
|
231
|
+
require_relative 'rubocop/cop/layout/heredoc_indentation'
|
224
232
|
require_relative 'rubocop/cop/layout/indentation_consistency'
|
225
233
|
require_relative 'rubocop/cop/layout/indentation_width'
|
226
|
-
require_relative 'rubocop/cop/layout/indent_first_argument'
|
227
|
-
require_relative 'rubocop/cop/layout/indent_first_array_element'
|
228
|
-
require_relative 'rubocop/cop/layout/indent_first_hash_element'
|
229
|
-
require_relative 'rubocop/cop/layout/indent_first_parameter'
|
230
|
-
require_relative 'rubocop/cop/layout/indent_heredoc'
|
231
234
|
require_relative 'rubocop/cop/layout/initial_indentation'
|
232
|
-
require_relative 'rubocop/cop/layout/leading_blank_lines'
|
233
235
|
require_relative 'rubocop/cop/layout/leading_comment_space'
|
236
|
+
require_relative 'rubocop/cop/layout/leading_empty_lines'
|
234
237
|
require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
|
235
238
|
require_relative 'rubocop/cop/layout/multiline_array_line_breaks'
|
236
239
|
require_relative 'rubocop/cop/layout/multiline_assignment_layout'
|
@@ -242,6 +245,7 @@ require_relative 'rubocop/cop/layout/multiline_method_call_brace_layout'
|
|
242
245
|
require_relative 'rubocop/cop/layout/multiline_method_call_indentation'
|
243
246
|
require_relative 'rubocop/cop/layout/multiline_method_definition_brace_layout'
|
244
247
|
require_relative 'rubocop/cop/layout/multiline_operation_indentation'
|
248
|
+
require_relative 'rubocop/cop/layout/parameter_alignment'
|
245
249
|
require_relative 'rubocop/cop/layout/rescue_ensure_alignment'
|
246
250
|
require_relative 'rubocop/cop/layout/space_after_colon'
|
247
251
|
require_relative 'rubocop/cop/layout/space_after_comma'
|
@@ -268,7 +272,7 @@ require_relative 'rubocop/cop/layout/space_inside_range_literal'
|
|
268
272
|
require_relative 'rubocop/cop/layout/space_inside_reference_brackets'
|
269
273
|
require_relative 'rubocop/cop/layout/space_inside_string_interpolation'
|
270
274
|
require_relative 'rubocop/cop/layout/tab'
|
271
|
-
require_relative 'rubocop/cop/layout/
|
275
|
+
require_relative 'rubocop/cop/layout/trailing_empty_lines'
|
272
276
|
require_relative 'rubocop/cop/layout/trailing_whitespace'
|
273
277
|
|
274
278
|
require_relative 'rubocop/cop/lint/ambiguous_block_association'
|
@@ -282,8 +286,8 @@ require_relative 'rubocop/cop/lint/debugger'
|
|
282
286
|
require_relative 'rubocop/cop/lint/deprecated_class_methods'
|
283
287
|
require_relative 'rubocop/cop/lint/disjunctive_assignment_in_constructor'
|
284
288
|
require_relative 'rubocop/cop/lint/duplicate_case_condition'
|
289
|
+
require_relative 'rubocop/cop/lint/duplicate_hash_key'
|
285
290
|
require_relative 'rubocop/cop/lint/duplicate_methods'
|
286
|
-
require_relative 'rubocop/cop/lint/duplicated_key'
|
287
291
|
require_relative 'rubocop/cop/lint/each_with_object_argument'
|
288
292
|
require_relative 'rubocop/cop/lint/else_layout'
|
289
293
|
require_relative 'rubocop/cop/lint/empty_ensure'
|
@@ -296,7 +300,6 @@ require_relative 'rubocop/cop/lint/erb_new_arguments'
|
|
296
300
|
require_relative 'rubocop/cop/lint/flip_flop'
|
297
301
|
require_relative 'rubocop/cop/lint/float_out_of_range'
|
298
302
|
require_relative 'rubocop/cop/lint/format_parameter_mismatch'
|
299
|
-
require_relative 'rubocop/cop/lint/handle_exceptions'
|
300
303
|
require_relative 'rubocop/cop/lint/heredoc_method_call_position'
|
301
304
|
require_relative 'rubocop/cop/lint/implicit_string_concatenation'
|
302
305
|
require_relative 'rubocop/cop/lint/inherit_exception'
|
@@ -306,7 +309,7 @@ require_relative 'rubocop/cop/lint/literal_as_condition'
|
|
306
309
|
require_relative 'rubocop/cop/lint/literal_in_interpolation'
|
307
310
|
require_relative 'rubocop/cop/lint/loop'
|
308
311
|
require_relative 'rubocop/cop/lint/missing_cop_enable_directive'
|
309
|
-
require_relative 'rubocop/cop/lint/
|
312
|
+
require_relative 'rubocop/cop/lint/multiple_comparison'
|
310
313
|
require_relative 'rubocop/cop/lint/nested_method_definition'
|
311
314
|
require_relative 'rubocop/cop/lint/nested_percent_literal'
|
312
315
|
require_relative 'rubocop/cop/lint/next_without_accumulator'
|
@@ -317,6 +320,11 @@ require_relative 'rubocop/cop/lint/parentheses_as_grouped_expression'
|
|
317
320
|
require_relative 'rubocop/cop/lint/percent_string_array'
|
318
321
|
require_relative 'rubocop/cop/lint/percent_symbol_array'
|
319
322
|
require_relative 'rubocop/cop/lint/rand_one'
|
323
|
+
require_relative 'rubocop/cop/lint/redundant_cop_disable_directive'
|
324
|
+
require_relative 'rubocop/cop/lint/redundant_cop_enable_directive'
|
325
|
+
require_relative 'rubocop/cop/lint/redundant_require_statement'
|
326
|
+
require_relative 'rubocop/cop/lint/redundant_splat_expansion'
|
327
|
+
require_relative 'rubocop/cop/lint/redundant_string_coercion'
|
320
328
|
require_relative 'rubocop/cop/lint/redundant_with_index'
|
321
329
|
require_relative 'rubocop/cop/lint/redundant_with_object'
|
322
330
|
require_relative 'rubocop/cop/lint/regexp_as_condition'
|
@@ -328,18 +336,15 @@ require_relative 'rubocop/cop/lint/safe_navigation_consistency'
|
|
328
336
|
require_relative 'rubocop/cop/lint/safe_navigation_chain'
|
329
337
|
require_relative 'rubocop/cop/lint/safe_navigation_with_empty'
|
330
338
|
require_relative 'rubocop/cop/lint/script_permission'
|
339
|
+
require_relative 'rubocop/cop/lint/send_with_mixin_argument'
|
331
340
|
require_relative 'rubocop/cop/lint/shadowed_argument'
|
332
341
|
require_relative 'rubocop/cop/lint/shadowed_exception'
|
333
342
|
require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
|
334
|
-
require_relative 'rubocop/cop/lint/
|
343
|
+
require_relative 'rubocop/cop/lint/suppressed_exception'
|
335
344
|
require_relative 'rubocop/cop/lint/syntax'
|
336
345
|
require_relative 'rubocop/cop/lint/to_json'
|
337
346
|
require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
|
338
347
|
require_relative 'rubocop/cop/lint/unified_integer'
|
339
|
-
require_relative 'rubocop/cop/lint/unneeded_cop_disable_directive'
|
340
|
-
require_relative 'rubocop/cop/lint/unneeded_cop_enable_directive'
|
341
|
-
require_relative 'rubocop/cop/lint/unneeded_require_statement'
|
342
|
-
require_relative 'rubocop/cop/lint/unneeded_splat_expansion'
|
343
348
|
require_relative 'rubocop/cop/lint/unreachable_code'
|
344
349
|
require_relative 'rubocop/cop/lint/unused_block_argument'
|
345
350
|
require_relative 'rubocop/cop/lint/unused_method_argument'
|
@@ -367,6 +372,7 @@ require_relative 'rubocop/cop/metrics/perceived_complexity'
|
|
367
372
|
|
368
373
|
require_relative 'rubocop/cop/naming/accessor_method_name'
|
369
374
|
require_relative 'rubocop/cop/naming/ascii_identifiers'
|
375
|
+
require_relative 'rubocop/cop/naming/block_parameter_name'
|
370
376
|
require_relative 'rubocop/cop/naming/class_and_module_camel_case'
|
371
377
|
require_relative 'rubocop/cop/naming/constant_name'
|
372
378
|
require_relative 'rubocop/cop/naming/file_name'
|
@@ -374,11 +380,10 @@ require_relative 'rubocop/cop/naming/heredoc_delimiter_case'
|
|
374
380
|
require_relative 'rubocop/cop/naming/heredoc_delimiter_naming'
|
375
381
|
require_relative 'rubocop/cop/naming/memoized_instance_variable_name'
|
376
382
|
require_relative 'rubocop/cop/naming/method_name'
|
383
|
+
require_relative 'rubocop/cop/naming/method_parameter_name'
|
377
384
|
require_relative 'rubocop/cop/naming/binary_operator_parameter_name'
|
378
385
|
require_relative 'rubocop/cop/naming/predicate_name'
|
379
386
|
require_relative 'rubocop/cop/naming/rescued_exceptions_variable_name'
|
380
|
-
require_relative 'rubocop/cop/naming/uncommunicative_block_param_name'
|
381
|
-
require_relative 'rubocop/cop/naming/uncommunicative_method_param_name'
|
382
387
|
require_relative 'rubocop/cop/naming/variable_name'
|
383
388
|
require_relative 'rubocop/cop/naming/variable_number'
|
384
389
|
|
@@ -497,12 +502,17 @@ require_relative 'rubocop/cop/style/proc'
|
|
497
502
|
require_relative 'rubocop/cop/style/raise_args'
|
498
503
|
require_relative 'rubocop/cop/style/random_with_offset'
|
499
504
|
require_relative 'rubocop/cop/style/redundant_begin'
|
505
|
+
require_relative 'rubocop/cop/style/redundant_capital_w'
|
506
|
+
require_relative 'rubocop/cop/style/redundant_condition'
|
500
507
|
require_relative 'rubocop/cop/style/redundant_conditional'
|
501
508
|
require_relative 'rubocop/cop/style/redundant_exception'
|
502
509
|
require_relative 'rubocop/cop/style/redundant_freeze'
|
510
|
+
require_relative 'rubocop/cop/style/redundant_interpolation'
|
503
511
|
require_relative 'rubocop/cop/style/redundant_parentheses'
|
512
|
+
require_relative 'rubocop/cop/style/redundant_percent_q'
|
504
513
|
require_relative 'rubocop/cop/style/redundant_return'
|
505
514
|
require_relative 'rubocop/cop/style/redundant_self'
|
515
|
+
require_relative 'rubocop/cop/style/redundant_sort'
|
506
516
|
require_relative 'rubocop/cop/style/redundant_sort_by'
|
507
517
|
require_relative 'rubocop/cop/style/regexp_literal'
|
508
518
|
require_relative 'rubocop/cop/style/rescue_modifier'
|
@@ -539,11 +549,6 @@ require_relative 'rubocop/cop/style/trailing_method_end_statement'
|
|
539
549
|
require_relative 'rubocop/cop/style/trailing_underscore_variable'
|
540
550
|
require_relative 'rubocop/cop/style/trivial_accessors'
|
541
551
|
require_relative 'rubocop/cop/style/unless_else'
|
542
|
-
require_relative 'rubocop/cop/style/unneeded_capital_w'
|
543
|
-
require_relative 'rubocop/cop/style/unneeded_condition'
|
544
|
-
require_relative 'rubocop/cop/style/unneeded_interpolation'
|
545
|
-
require_relative 'rubocop/cop/style/unneeded_percent_q'
|
546
|
-
require_relative 'rubocop/cop/style/unneeded_sort'
|
547
552
|
require_relative 'rubocop/cop/style/unpack_first'
|
548
553
|
require_relative 'rubocop/cop/style/variable_interpolation'
|
549
554
|
require_relative 'rubocop/cop/style/when_then'
|
@@ -577,6 +582,7 @@ require_relative 'rubocop/formatter/progress_formatter'
|
|
577
582
|
require_relative 'rubocop/formatter/quiet_formatter'
|
578
583
|
require_relative 'rubocop/formatter/tap_formatter'
|
579
584
|
require_relative 'rubocop/formatter/worst_offenders_formatter'
|
585
|
+
require_relative 'rubocop/formatter/pacman_formatter'
|
580
586
|
# relies on progress formatter
|
581
587
|
require_relative 'rubocop/formatter/auto_gen_config_formatter'
|
582
588
|
|
@@ -586,7 +592,9 @@ require_relative 'rubocop/cached_data'
|
|
586
592
|
require_relative 'rubocop/config'
|
587
593
|
require_relative 'rubocop/config_loader_resolver'
|
588
594
|
require_relative 'rubocop/config_loader'
|
595
|
+
require_relative 'rubocop/config_obsoletion'
|
589
596
|
require_relative 'rubocop/config_store'
|
597
|
+
require_relative 'rubocop/config_validator'
|
590
598
|
require_relative 'rubocop/target_finder'
|
591
599
|
require_relative 'rubocop/token'
|
592
600
|
require_relative 'rubocop/comment_config'
|
@@ -595,6 +603,14 @@ require_relative 'rubocop/processed_source'
|
|
595
603
|
require_relative 'rubocop/result_cache'
|
596
604
|
require_relative 'rubocop/runner'
|
597
605
|
require_relative 'rubocop/cli'
|
606
|
+
require_relative 'rubocop/cli/command'
|
607
|
+
require_relative 'rubocop/cli/environment'
|
608
|
+
require_relative 'rubocop/cli/command/base'
|
609
|
+
require_relative 'rubocop/cli/command/auto_genenerate_config'
|
610
|
+
require_relative 'rubocop/cli/command/execute_runner'
|
611
|
+
require_relative 'rubocop/cli/command/init_dotfile'
|
612
|
+
require_relative 'rubocop/cli/command/show_cops'
|
613
|
+
require_relative 'rubocop/cli/command/version'
|
598
614
|
require_relative 'rubocop/options'
|
599
615
|
require_relative 'rubocop/remote_config'
|
600
616
|
require_relative 'rubocop/yaml_duplication_checker'
|
data/lib/rubocop/ast/builder.rb
CHANGED
data/lib/rubocop/ast/node.rb
CHANGED
@@ -306,8 +306,6 @@ module RuboCop
|
|
306
306
|
{(send $_ ...) (block (send $_ ...) ...)}
|
307
307
|
PATTERN
|
308
308
|
|
309
|
-
# Note: for masgn, #asgn_rhs will be an array node
|
310
|
-
def_node_matcher :asgn_rhs, '[assignment? (... $_)]'
|
311
309
|
def_node_matcher :str_content, '(str $_)'
|
312
310
|
|
313
311
|
def const_name
|
@@ -471,6 +469,10 @@ module RuboCop
|
|
471
469
|
parent&.send_type? && parent.arguments.include?(self)
|
472
470
|
end
|
473
471
|
|
472
|
+
def boolean_type?
|
473
|
+
true_type? || false_type?
|
474
|
+
end
|
475
|
+
|
474
476
|
def numeric_type?
|
475
477
|
int_type? || float_type?
|
476
478
|
end
|
@@ -480,7 +482,7 @@ module RuboCop
|
|
480
482
|
end
|
481
483
|
|
482
484
|
def_node_matcher :guard_clause?, <<~PATTERN
|
483
|
-
[{(send nil? {:raise :fail} ...) return break next} single_line?]
|
485
|
+
[${(send nil? {:raise :fail} ...) return break next} single_line?]
|
484
486
|
PATTERN
|
485
487
|
|
486
488
|
def_node_matcher :proc?, <<~PATTERN
|
@@ -497,10 +499,6 @@ module RuboCop
|
|
497
499
|
(block (send (const nil? {:Class :Module}) :new ...) ...)}
|
498
500
|
PATTERN
|
499
501
|
|
500
|
-
def_node_matcher :module_definition?, <<~PATTERN
|
501
|
-
{class module (casgn _ _ class_constructor?)}
|
502
|
-
PATTERN
|
503
|
-
|
504
502
|
# Some expressions are evaluated for their value, some for their side
|
505
503
|
# effects, and some for both
|
506
504
|
# If we know that an expression is useful only for its side effects, that
|
@@ -626,7 +624,7 @@ module RuboCop
|
|
626
624
|
end
|
627
625
|
|
628
626
|
def parent_module_name_for_block(ancestor)
|
629
|
-
if ancestor.
|
627
|
+
if ancestor.method?(:class_eval)
|
630
628
|
# `class_eval` with no receiver applies to whatever module or class
|
631
629
|
# we are currently in
|
632
630
|
return unless (receiver = ancestor.receiver)
|
@@ -9,6 +9,8 @@ module RuboCop
|
|
9
9
|
# A `block` node is essentially a method send with a block. Parser nests
|
10
10
|
# the `send` node inside the `block` node.
|
11
11
|
class BlockNode < Node
|
12
|
+
include MethodIdentifierPredicates
|
13
|
+
|
12
14
|
VOID_CONTEXT_METHODS = %i[each tap].freeze
|
13
15
|
|
14
16
|
# The `send` node associated with this block.
|
@@ -222,22 +222,11 @@ module RuboCop
|
|
222
222
|
|
223
223
|
def_node_matcher :macro_scope?, <<~PATTERN
|
224
224
|
{^{({sclass class module block} ...) class_constructor?}
|
225
|
-
|
225
|
+
^^{({sclass class module block} ... ({begin if} ...)) class_constructor?}
|
226
226
|
^#macro_kwbegin_wrapper?
|
227
227
|
#root_node?}
|
228
228
|
PATTERN
|
229
229
|
|
230
|
-
def_node_matcher :wrapped_macro_scope?, <<~PATTERN
|
231
|
-
{({sclass class module block} ... ({begin if} ...)) class_constructor?}
|
232
|
-
PATTERN
|
233
|
-
|
234
|
-
def ascend_macro_scope?(ancestor)
|
235
|
-
return true if wrapped_macro_scope?(ancestor)
|
236
|
-
return false if root_node?(ancestor)
|
237
|
-
|
238
|
-
ascend_macro_scope?(ancestor.parent)
|
239
|
-
end
|
240
|
-
|
241
230
|
# Check if a node's parent is a kwbegin wrapper within a macro scope
|
242
231
|
#
|
243
232
|
# @param parent [Node] parent of the node being checked
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module AST
|
5
|
+
# A node extension for `return` nodes. This will be used in place of a
|
6
|
+
# plain node when the builder constructs the AST, making its methods
|
7
|
+
# available to all `return` nodes within RuboCop.
|
8
|
+
class ReturnNode < Node
|
9
|
+
include MethodDispatchNode
|
10
|
+
include ParameterizedNode
|
11
|
+
|
12
|
+
# Returns the arguments of the `return`.
|
13
|
+
#
|
14
|
+
# @return [Array] The arguments of the `return`.
|
15
|
+
def arguments
|
16
|
+
if node_parts.one? && node_parts.first.begin_type?
|
17
|
+
node_parts.first.children
|
18
|
+
else
|
19
|
+
node_parts
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/rubocop/cli.rb
CHANGED
@@ -1,20 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/ClassLength
|
4
3
|
module RuboCop
|
5
4
|
# The CLI is a class responsible of handling all the command line interface
|
6
5
|
# logic.
|
7
6
|
class CLI
|
8
|
-
include Formatter::TextUtil
|
9
|
-
|
10
|
-
PHASE_1 = 'Phase 1 of 2: run Metrics/LineLength cop'
|
11
|
-
PHASE_2 = 'Phase 2 of 2: run all cops'
|
12
|
-
|
13
|
-
PHASE_1_OVERRIDDEN = '(skipped because the default Metrics/LineLength:Max' \
|
14
|
-
' is overridden)'
|
15
|
-
PHASE_1_DISABLED = '(skipped because Metrics/LineLength is ' \
|
16
|
-
'disabled)'
|
17
|
-
|
18
7
|
STATUS_SUCCESS = 0
|
19
8
|
STATUS_OFFENSES = 1
|
20
9
|
STATUS_ERROR = 2
|
@@ -41,14 +30,15 @@ module RuboCop
|
|
41
30
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
42
31
|
def run(args = ARGV)
|
43
32
|
@options, paths = Options.new.parse(args)
|
33
|
+
@env = Environment.new(@options, @config_store, paths)
|
44
34
|
|
45
35
|
if @options[:init]
|
46
|
-
|
36
|
+
run_command(:init)
|
47
37
|
else
|
48
38
|
validate_options_vs_config
|
49
39
|
act_on_options
|
50
40
|
apply_default_formatter
|
51
|
-
execute_runners
|
41
|
+
execute_runners
|
52
42
|
end
|
53
43
|
rescue ConfigNotFoundError, IncorrectCopNameError, OptionArgumentError => e
|
54
44
|
warn e.message
|
@@ -71,110 +61,18 @@ module RuboCop
|
|
71
61
|
|
72
62
|
private
|
73
63
|
|
74
|
-
def
|
75
|
-
|
76
|
-
reset_config_and_auto_gen_file
|
77
|
-
line_length_contents = maybe_run_line_length_cop(paths)
|
78
|
-
run_all_cops_auto_gen_config(line_length_contents, paths)
|
79
|
-
else
|
80
|
-
execute_runner(paths)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def maybe_run_line_length_cop(paths)
|
85
|
-
if !line_length_enabled?(@config_store.for(Dir.pwd))
|
86
|
-
puts Rainbow("#{PHASE_1} #{PHASE_1_DISABLED}").yellow
|
87
|
-
''
|
88
|
-
elsif !same_max_line_length?(
|
89
|
-
@config_store.for(Dir.pwd), ConfigLoader.default_configuration
|
90
|
-
)
|
91
|
-
puts Rainbow("#{PHASE_1} #{PHASE_1_OVERRIDDEN}").yellow
|
92
|
-
''
|
93
|
-
else
|
94
|
-
run_line_length_cop_auto_gen_config(paths)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def line_length_enabled?(config)
|
99
|
-
line_length_cop(config)['Enabled']
|
100
|
-
end
|
101
|
-
|
102
|
-
def same_max_line_length?(config1, config2)
|
103
|
-
max_line_length(config1) == max_line_length(config2)
|
104
|
-
end
|
105
|
-
|
106
|
-
def max_line_length(config)
|
107
|
-
line_length_cop(config)['Max']
|
108
|
-
end
|
109
|
-
|
110
|
-
def line_length_cop(config)
|
111
|
-
config.for_cop('Metrics/LineLength')
|
64
|
+
def run_command(name)
|
65
|
+
@env.run(name)
|
112
66
|
end
|
113
67
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
puts Rainbow(PHASE_1).yellow
|
118
|
-
@options[:only] = ['Metrics/LineLength']
|
119
|
-
execute_runner(paths)
|
120
|
-
@options.delete(:only)
|
121
|
-
@config_store = ConfigStore.new
|
122
|
-
# Save the todo configuration of the LineLength cop.
|
123
|
-
IO.read(ConfigLoader::AUTO_GENERATED_FILE)
|
124
|
-
.lines
|
125
|
-
.drop_while { |line| line.start_with?('#') }
|
126
|
-
.join
|
127
|
-
end
|
128
|
-
|
129
|
-
def run_all_cops_auto_gen_config(line_length_contents, paths)
|
130
|
-
puts Rainbow(PHASE_2).yellow
|
131
|
-
result = execute_runner(paths)
|
132
|
-
# This run was made with the current maximum length allowed, so append
|
133
|
-
# the saved setting for LineLength.
|
134
|
-
File.open(ConfigLoader::AUTO_GENERATED_FILE, 'a') do |f|
|
135
|
-
f.write(line_length_contents)
|
136
|
-
end
|
137
|
-
result
|
138
|
-
end
|
139
|
-
|
140
|
-
def init_dotfile
|
141
|
-
path = File.expand_path(ConfigLoader::DOTFILE)
|
142
|
-
|
143
|
-
if File.exist?(ConfigLoader::DOTFILE)
|
144
|
-
warn Rainbow("#{ConfigLoader::DOTFILE} already exists at #{path}").red
|
145
|
-
|
146
|
-
STATUS_ERROR
|
68
|
+
def execute_runners
|
69
|
+
if @options[:auto_gen_config]
|
70
|
+
run_command(:auto_gen_config)
|
147
71
|
else
|
148
|
-
|
149
|
-
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
150
|
-
# configuration file. It makes it possible to enable/disable
|
151
|
-
# certain cops (checks) and to alter their behavior if they accept
|
152
|
-
# any parameters. The file can be placed either in your home
|
153
|
-
# directory or in some project directory.
|
154
|
-
#
|
155
|
-
# RuboCop will start looking for the configuration file in the directory
|
156
|
-
# where the inspected file is and continue its way up to the root directory.
|
157
|
-
#
|
158
|
-
# See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
|
159
|
-
DESC
|
160
|
-
|
161
|
-
File.open(ConfigLoader::DOTFILE, 'w') do |f|
|
162
|
-
f.write(description)
|
163
|
-
end
|
164
|
-
|
165
|
-
puts "Writing new #{ConfigLoader::DOTFILE} to #{path}"
|
166
|
-
|
167
|
-
STATUS_SUCCESS
|
72
|
+
run_command(:execute_runner)
|
168
73
|
end
|
169
74
|
end
|
170
75
|
|
171
|
-
def reset_config_and_auto_gen_file
|
172
|
-
@config_store = ConfigStore.new
|
173
|
-
@config_store.options_config = @options[:config] if @options[:config]
|
174
|
-
File.open(ConfigLoader::AUTO_GENERATED_FILE, 'w') {}
|
175
|
-
ConfigLoader.add_inheritance_from_auto_generated_file
|
176
|
-
end
|
177
|
-
|
178
76
|
def validate_options_vs_config
|
179
77
|
if @options[:parallel] &&
|
180
78
|
!@config_store.for(Dir.pwd).for_all_cops['UseCache']
|
@@ -204,31 +102,11 @@ module RuboCop
|
|
204
102
|
end
|
205
103
|
end
|
206
104
|
|
207
|
-
def execute_runner(paths)
|
208
|
-
runner = Runner.new(@options, @config_store)
|
209
|
-
|
210
|
-
all_passed = runner.run(paths)
|
211
|
-
display_warning_summary(runner.warnings)
|
212
|
-
display_error_summary(runner.errors)
|
213
|
-
maybe_print_corrected_source
|
214
|
-
|
215
|
-
all_pass_or_excluded = all_passed || @options[:auto_gen_config]
|
216
|
-
|
217
|
-
if runner.aborting?
|
218
|
-
STATUS_INTERRUPTED
|
219
|
-
elsif all_pass_or_excluded && runner.errors.empty?
|
220
|
-
STATUS_SUCCESS
|
221
|
-
else
|
222
|
-
STATUS_OFFENSES
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
105
|
def handle_exiting_options
|
227
106
|
return unless Options::EXITING_OPTIONS.any? { |o| @options.key? o }
|
228
107
|
|
229
|
-
|
230
|
-
|
231
|
-
print_available_cops if @options[:show_cops]
|
108
|
+
run_command(:version) if @options[:version] || @options[:verbose_version]
|
109
|
+
run_command(:show_cops) if @options[:show_cops]
|
232
110
|
raise Finished
|
233
111
|
end
|
234
112
|
|
@@ -244,100 +122,6 @@ module RuboCop
|
|
244
122
|
end
|
245
123
|
[[formatter, @options[:output_path]]]
|
246
124
|
end
|
247
|
-
|
248
|
-
return unless @options[:auto_gen_config]
|
249
|
-
|
250
|
-
@options[:formatters] << [Formatter::DisabledConfigFormatter,
|
251
|
-
ConfigLoader::AUTO_GENERATED_FILE]
|
252
|
-
end
|
253
|
-
|
254
|
-
def print_available_cops
|
255
|
-
# Load the configs so the require()s are done for custom cops
|
256
|
-
@config_store.for(Dir.pwd)
|
257
|
-
registry = Cop::Cop.registry
|
258
|
-
show_all = @options[:show_cops].empty?
|
259
|
-
|
260
|
-
if show_all
|
261
|
-
puts "# Available cops (#{registry.length}) + config for #{Dir.pwd}: "
|
262
|
-
end
|
263
|
-
|
264
|
-
registry.departments.sort!.each do |department|
|
265
|
-
print_cops_of_department(registry, department, show_all)
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
def print_cops_of_department(registry, department, show_all)
|
270
|
-
selected_cops = if show_all
|
271
|
-
cops_of_department(registry, department)
|
272
|
-
else
|
273
|
-
selected_cops_of_department(registry, department)
|
274
|
-
end
|
275
|
-
|
276
|
-
puts "# Department '#{department}' (#{selected_cops.length}):" if show_all
|
277
|
-
|
278
|
-
print_cop_details(selected_cops)
|
279
|
-
end
|
280
|
-
|
281
|
-
def print_cop_details(cops)
|
282
|
-
cops.each do |cop|
|
283
|
-
puts '# Supports --auto-correct' if cop.new.support_autocorrect?
|
284
|
-
puts "#{cop.cop_name}:"
|
285
|
-
puts config_lines(cop)
|
286
|
-
puts
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
def selected_cops_of_department(cops, department)
|
291
|
-
cops_of_department(cops, department).select do |cop|
|
292
|
-
@options[:show_cops].include?(cop.cop_name)
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
def cops_of_department(cops, department)
|
297
|
-
cops.with_department(department).sort!
|
298
|
-
end
|
299
|
-
|
300
|
-
def config_lines(cop)
|
301
|
-
cnf = @config_store.for(Dir.pwd).for_cop(cop)
|
302
|
-
cnf.to_yaml.lines.to_a.drop(1).map { |line| ' ' + line }
|
303
|
-
end
|
304
|
-
|
305
|
-
def display_warning_summary(warnings)
|
306
|
-
return if warnings.empty?
|
307
|
-
|
308
|
-
warn Rainbow("\n#{pluralize(warnings.size, 'warning')}:").yellow
|
309
|
-
|
310
|
-
warnings.each { |warning| warn warning }
|
311
|
-
end
|
312
|
-
|
313
|
-
def display_error_summary(errors)
|
314
|
-
return if errors.empty?
|
315
|
-
|
316
|
-
warn Rainbow("\n#{pluralize(errors.size, 'error')} occurred:").red
|
317
|
-
|
318
|
-
errors.each { |error| warn error }
|
319
|
-
|
320
|
-
warn <<~WARNING
|
321
|
-
Errors are usually caused by RuboCop bugs.
|
322
|
-
Please, report your problems to RuboCop's issue tracker.
|
323
|
-
#{Gem.loaded_specs['rubocop'].metadata['bug_tracker_uri']}
|
324
|
-
|
325
|
-
Mention the following information in the issue report:
|
326
|
-
#{RuboCop::Version.version(true)}
|
327
|
-
WARNING
|
328
|
-
end
|
329
|
-
|
330
|
-
def maybe_print_corrected_source
|
331
|
-
# If we are asked to autocorrect source code read from stdin, the only
|
332
|
-
# reasonable place to write it is to stdout
|
333
|
-
# Unfortunately, we also write other information to stdout
|
334
|
-
# So a delimiter is needed for tools to easily identify where the
|
335
|
-
# autocorrected source begins
|
336
|
-
return unless @options[:stdin] && @options[:auto_correct]
|
337
|
-
|
338
|
-
puts '=' * 20
|
339
|
-
print @options[:stdin]
|
340
125
|
end
|
341
126
|
end
|
342
127
|
end
|
343
|
-
# rubocop:enable Metrics/ClassLength
|