rubocop 0.70.0 → 0.75.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -10
- data/bin/console +1 -0
- data/config/default.yml +91 -494
- data/lib/rubocop.rb +16 -54
- data/lib/rubocop/ast/builder.rb +2 -0
- data/lib/rubocop/ast/node.rb +9 -15
- data/lib/rubocop/ast/node/float_node.rb +12 -0
- data/lib/rubocop/ast/node/int_node.rb +12 -0
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +4 -4
- data/lib/rubocop/ast/node/mixin/numeric_node.rb +21 -0
- data/lib/rubocop/ast/node/resbody_node.rb +1 -6
- data/lib/rubocop/ast/traversal.rb +3 -3
- data/lib/rubocop/cached_data.rb +1 -1
- data/lib/rubocop/comment_config.rb +3 -2
- data/lib/rubocop/config.rb +21 -508
- data/lib/rubocop/config_loader.rb +22 -4
- data/lib/rubocop/config_loader_resolver.rb +2 -8
- data/lib/rubocop/config_obsoletion.rb +213 -0
- data/lib/rubocop/config_validator.rb +239 -0
- data/lib/rubocop/cop/autocorrect_logic.rb +71 -1
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
- data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
- data/lib/rubocop/cop/commissioner.rb +3 -9
- data/lib/rubocop/cop/cop.rb +39 -12
- data/lib/rubocop/cop/corrector.rb +2 -3
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +43 -17
- data/lib/rubocop/cop/correctors/empty_line_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +2 -2
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +1 -1
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +55 -0
- data/lib/rubocop/cop/generator.rb +4 -4
- 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/node_destructuring.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -2
- data/lib/rubocop/cop/layout/block_alignment.rb +3 -3
- data/lib/rubocop/cop/layout/class_structure.rb +2 -2
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +3 -1
- data/lib/rubocop/cop/layout/extra_spacing.rb +14 -59
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +4 -0
- data/lib/rubocop/cop/layout/indent_assignment.rb +9 -1
- data/lib/rubocop/cop/layout/indent_first_argument.rb +7 -3
- data/lib/rubocop/cop/layout/indent_first_parameter.rb +7 -3
- data/lib/rubocop/cop/layout/indent_heredoc.rb +4 -4
- data/lib/rubocop/cop/layout/indentation_consistency.rb +13 -12
- data/lib/rubocop/cop/layout/indentation_width.rb +28 -10
- data/lib/rubocop/cop/layout/leading_comment_space.rb +28 -0
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +24 -2
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +2 -0
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +18 -4
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +5 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +42 -23
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +21 -2
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +24 -40
- data/lib/rubocop/cop/layout/tab.rb +10 -22
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +17 -4
- data/lib/rubocop/cop/lint/big_decimal_new.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +4 -6
- data/lib/rubocop/cop/lint/duplicate_methods.rb +3 -3
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +4 -4
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +57 -1
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +11 -37
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
- data/lib/rubocop/cop/lint/inherit_exception.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +7 -8
- data/lib/rubocop/cop/lint/multiple_compare.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +3 -3
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
- data/lib/rubocop/cop/lint/number_conversion.rb +4 -4
- data/lib/rubocop/cop/lint/rand_one.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_with_object.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +5 -5
- data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
- data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +91 -0
- data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +6 -6
- data/lib/rubocop/cop/lint/unified_integer.rb +1 -1
- data/lib/rubocop/cop/lint/unneeded_cop_disable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/unneeded_require_statement.rb +1 -1
- data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +7 -2
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +1 -1
- data/lib/rubocop/cop/lint/uri_regexp.rb +2 -2
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +6 -6
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/message_annotator.rb +16 -7
- data/lib/rubocop/cop/metrics/class_length.rb +1 -1
- data/lib/rubocop/cop/metrics/line_length.rb +6 -0
- data/lib/rubocop/cop/metrics/module_length.rb +1 -1
- data/lib/rubocop/cop/metrics/parameter_lists.rb +1 -1
- data/lib/rubocop/cop/migration/department_name.rb +44 -0
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/def_node.rb +1 -1
- data/lib/rubocop/cop/mixin/documentation_comment.rb +0 -2
- data/lib/rubocop/cop/mixin/empty_parameter.rb +1 -1
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +4 -4
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_alignment.rb +4 -0
- data/lib/rubocop/cop/mixin/interpolation.rb +27 -0
- data/lib/rubocop/cop/mixin/method_complexity.rb +1 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +3 -3
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +87 -0
- data/lib/rubocop/cop/mixin/safe_mode.rb +2 -0
- data/lib/rubocop/cop/mixin/surrounding_space.rb +7 -5
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +2 -2
- data/lib/rubocop/cop/naming/method_name.rb +12 -1
- data/lib/rubocop/cop/naming/predicate_name.rb +1 -1
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +20 -22
- 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/security/eval.rb +1 -1
- data/lib/rubocop/cop/security/json_load.rb +1 -1
- data/lib/rubocop/cop/security/marshal_load.rb +1 -1
- data/lib/rubocop/cop/security/open.rb +1 -1
- data/lib/rubocop/cop/security/yaml_load.rb +1 -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/block_delimiters.rb +2 -1
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +29 -10
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
- data/lib/rubocop/cop/style/commented_keyword.rb +16 -30
- data/lib/rubocop/cop/style/conditional_assignment.rb +8 -9
- data/lib/rubocop/cop/style/constant_visibility.rb +14 -3
- data/lib/rubocop/cop/style/date_time.rb +3 -3
- data/lib/rubocop/cop/style/dir.rb +1 -1
- data/lib/rubocop/cop/style/documentation_method.rb +1 -1
- data/lib/rubocop/cop/style/double_cop_disable_directive.rb +55 -0
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +1 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +2 -2
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -3
- data/lib/rubocop/cop/style/float_division.rb +94 -0
- data/lib/rubocop/cop/style/format_string.rb +13 -9
- data/lib/rubocop/cop/style/format_string_token.rb +10 -40
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +18 -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_inside_else.rb +42 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +51 -15
- data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +2 -2
- data/lib/rubocop/cop/style/lambda.rb +0 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +12 -6
- data/lib/rubocop/cop/style/min_max.rb +1 -1
- data/lib/rubocop/cop/style/mixin_usage.rb +12 -2
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +55 -0
- data/lib/rubocop/cop/style/multiple_comparison.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +3 -3
- data/lib/rubocop/cop/style/nested_modifier.rb +18 -2
- data/lib/rubocop/cop/style/numeric_predicate.rb +3 -3
- data/lib/rubocop/cop/style/option_hash.rb +1 -1
- data/lib/rubocop/cop/style/or_assignment.rb +8 -3
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +15 -1
- data/lib/rubocop/cop/style/random_with_offset.rb +6 -6
- data/lib/rubocop/cop/style/redundant_conditional.rb +2 -2
- data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +15 -6
- data/lib/rubocop/cop/style/redundant_self.rb +18 -1
- data/lib/rubocop/cop/style/redundant_sort_by.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +24 -0
- data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +11 -2
- data/lib/rubocop/cop/style/sample.rb +1 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +8 -1
- data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
- data/lib/rubocop/cop/style/string_hash_keys.rb +2 -2
- data/lib/rubocop/cop/style/strip.rb +1 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +3 -3
- data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
- data/lib/rubocop/cop/style/ternary_parentheses.rb +32 -3
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -0
- data/lib/rubocop/cop/style/trailing_method_end_statement.rb +4 -6
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_sort.rb +1 -1
- data/lib/rubocop/cop/style/unpack_first.rb +1 -1
- data/lib/rubocop/cop/style/variable_interpolation.rb +6 -16
- data/lib/rubocop/cop/style/word_array.rb +2 -2
- data/lib/rubocop/cop/style/zero_length_predicate.rb +6 -6
- data/lib/rubocop/cop/team.rb +15 -14
- data/lib/rubocop/cop/utils/format_string.rb +128 -0
- data/lib/rubocop/cop/variable_force/variable.rb +15 -2
- data/lib/rubocop/core_ext/string.rb +0 -24
- data/lib/rubocop/error.rb +23 -0
- data/lib/rubocop/formatter/emacs_style_formatter.rb +8 -5
- data/lib/rubocop/formatter/formatter_set.rb +2 -1
- data/lib/rubocop/formatter/pacman_formatter.rb +80 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +9 -1
- data/lib/rubocop/formatter/tap_formatter.rb +9 -1
- data/lib/rubocop/magic_comment.rb +4 -0
- data/lib/rubocop/node_pattern.rb +86 -7
- data/lib/rubocop/options.rb +18 -2
- data/lib/rubocop/path_util.rb +1 -1
- data/lib/rubocop/processed_source.rb +9 -1
- data/lib/rubocop/rspec/cop_helper.rb +0 -1
- data/lib/rubocop/rspec/expect_offense.rb +4 -1
- data/lib/rubocop/rspec/shared_contexts.rb +12 -17
- data/lib/rubocop/rspec/support.rb +0 -1
- data/lib/rubocop/runner.rb +20 -15
- data/lib/rubocop/target_finder.rb +6 -4
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop/yaml_duplication_checker.rb +8 -2
- metadata +16 -70
- data/lib/rubocop/cop/mixin/ignored_method_patterns.rb +0 -19
- data/lib/rubocop/cop/mixin/target_rails_version.rb +0 -16
- data/lib/rubocop/cop/rails/action_filter.rb +0 -117
- data/lib/rubocop/cop/rails/active_record_aliases.rb +0 -48
- data/lib/rubocop/cop/rails/active_record_override.rb +0 -82
- data/lib/rubocop/cop/rails/active_support_aliases.rb +0 -69
- data/lib/rubocop/cop/rails/application_job.rb +0 -40
- data/lib/rubocop/cop/rails/application_record.rb +0 -40
- data/lib/rubocop/cop/rails/assert_not.rb +0 -44
- data/lib/rubocop/cop/rails/belongs_to.rb +0 -102
- data/lib/rubocop/cop/rails/blank.rb +0 -164
- data/lib/rubocop/cop/rails/bulk_change_table.rb +0 -289
- data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +0 -91
- data/lib/rubocop/cop/rails/date.rb +0 -161
- data/lib/rubocop/cop/rails/delegate.rb +0 -132
- data/lib/rubocop/cop/rails/delegate_allow_blank.rb +0 -37
- data/lib/rubocop/cop/rails/dynamic_find_by.rb +0 -91
- data/lib/rubocop/cop/rails/enum_uniqueness.rb +0 -45
- data/lib/rubocop/cop/rails/environment_comparison.rb +0 -68
- data/lib/rubocop/cop/rails/exit.rb +0 -67
- data/lib/rubocop/cop/rails/file_path.rb +0 -108
- data/lib/rubocop/cop/rails/find_by.rb +0 -55
- data/lib/rubocop/cop/rails/find_each.rb +0 -51
- data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +0 -25
- data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +0 -106
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +0 -117
- data/lib/rubocop/cop/rails/http_status.rb +0 -179
- data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +0 -94
- data/lib/rubocop/cop/rails/inverse_of.rb +0 -246
- data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +0 -175
- data/lib/rubocop/cop/rails/link_to_blank.rb +0 -98
- data/lib/rubocop/cop/rails/not_null_column.rb +0 -67
- data/lib/rubocop/cop/rails/output.rb +0 -49
- data/lib/rubocop/cop/rails/output_safety.rb +0 -99
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +0 -107
- data/lib/rubocop/cop/rails/presence.rb +0 -124
- data/lib/rubocop/cop/rails/present.rb +0 -153
- data/lib/rubocop/cop/rails/read_write_attribute.rb +0 -74
- data/lib/rubocop/cop/rails/redundant_allow_nil.rb +0 -111
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +0 -136
- data/lib/rubocop/cop/rails/reflection_class_name.rb +0 -37
- data/lib/rubocop/cop/rails/refute_methods.rb +0 -76
- data/lib/rubocop/cop/rails/relative_date_constant.rb +0 -93
- data/lib/rubocop/cop/rails/request_referer.rb +0 -56
- data/lib/rubocop/cop/rails/reversible_migration.rb +0 -286
- data/lib/rubocop/cop/rails/safe_navigation.rb +0 -87
- data/lib/rubocop/cop/rails/save_bang.rb +0 -316
- data/lib/rubocop/cop/rails/scope_args.rb +0 -29
- data/lib/rubocop/cop/rails/skips_model_validations.rb +0 -87
- data/lib/rubocop/cop/rails/time_zone.rb +0 -238
- data/lib/rubocop/cop/rails/uniq_before_pluck.rb +0 -105
- data/lib/rubocop/cop/rails/unknown_env.rb +0 -63
- data/lib/rubocop/cop/rails/validation.rb +0 -109
- data/lib/rubocop/rspec/shared_examples.rb +0 -59
data/lib/rubocop.rb
CHANGED
@@ -27,6 +27,7 @@ require_relative 'rubocop/ast/node/mixin/conditional_node'
|
|
27
27
|
require_relative 'rubocop/ast/node/mixin/hash_element_node'
|
28
28
|
require_relative 'rubocop/ast/node/mixin/method_dispatch_node'
|
29
29
|
require_relative 'rubocop/ast/node/mixin/modifier_node'
|
30
|
+
require_relative 'rubocop/ast/node/mixin/numeric_node'
|
30
31
|
require_relative 'rubocop/ast/node/mixin/parameterized_node'
|
31
32
|
require_relative 'rubocop/ast/node/mixin/predicate_operator_node'
|
32
33
|
require_relative 'rubocop/ast/node/mixin/basic_literal_node'
|
@@ -42,8 +43,10 @@ require_relative 'rubocop/ast/node/def_node'
|
|
42
43
|
require_relative 'rubocop/ast/node/defined_node'
|
43
44
|
require_relative 'rubocop/ast/node/ensure_node'
|
44
45
|
require_relative 'rubocop/ast/node/for_node'
|
46
|
+
require_relative 'rubocop/ast/node/float_node'
|
45
47
|
require_relative 'rubocop/ast/node/hash_node'
|
46
48
|
require_relative 'rubocop/ast/node/if_node'
|
49
|
+
require_relative 'rubocop/ast/node/int_node'
|
47
50
|
require_relative 'rubocop/ast/node/keyword_splat_node'
|
48
51
|
require_relative 'rubocop/ast/node/module_node'
|
49
52
|
require_relative 'rubocop/ast/node/or_node'
|
@@ -117,8 +120,8 @@ require_relative 'rubocop/cop/mixin/frozen_string_literal'
|
|
117
120
|
require_relative 'rubocop/cop/mixin/hash_alignment'
|
118
121
|
require_relative 'rubocop/cop/mixin/ignored_pattern'
|
119
122
|
require_relative 'rubocop/cop/mixin/ignored_methods'
|
120
|
-
require_relative 'rubocop/cop/mixin/ignored_method_patterns'
|
121
123
|
require_relative 'rubocop/cop/mixin/integer_node'
|
124
|
+
require_relative 'rubocop/cop/mixin/interpolation'
|
122
125
|
require_relative 'rubocop/cop/mixin/match_range'
|
123
126
|
require_relative 'rubocop/cop/mixin/method_complexity'
|
124
127
|
require_relative 'rubocop/cop/mixin/method_preference'
|
@@ -148,13 +151,16 @@ require_relative 'rubocop/cop/mixin/statement_modifier'
|
|
148
151
|
require_relative 'rubocop/cop/mixin/string_help'
|
149
152
|
require_relative 'rubocop/cop/mixin/string_literals_help'
|
150
153
|
require_relative 'rubocop/cop/mixin/target_ruby_version'
|
151
|
-
require_relative 'rubocop/cop/mixin/target_rails_version'
|
152
154
|
require_relative 'rubocop/cop/mixin/too_many_lines'
|
153
155
|
require_relative 'rubocop/cop/mixin/trailing_body'
|
154
156
|
require_relative 'rubocop/cop/mixin/trailing_comma'
|
155
157
|
require_relative 'rubocop/cop/mixin/uncommunicative_name'
|
156
158
|
require_relative 'rubocop/cop/mixin/unused_argument'
|
157
159
|
|
160
|
+
require_relative 'rubocop/cop/utils/format_string'
|
161
|
+
|
162
|
+
require_relative 'rubocop/cop/migration/department_name'
|
163
|
+
|
158
164
|
require_relative 'rubocop/cop/correctors/alignment_corrector'
|
159
165
|
require_relative 'rubocop/cop/correctors/condition_corrector'
|
160
166
|
require_relative 'rubocop/cop/correctors/each_to_for_corrector'
|
@@ -179,6 +185,7 @@ require_relative 'rubocop/cop/bundler/ordered_gems'
|
|
179
185
|
require_relative 'rubocop/cop/gemspec/duplicated_assignment'
|
180
186
|
require_relative 'rubocop/cop/gemspec/ordered_dependencies'
|
181
187
|
require_relative 'rubocop/cop/gemspec/required_ruby_version'
|
188
|
+
require_relative 'rubocop/cop/gemspec/ruby_version_globals_usage'
|
182
189
|
|
183
190
|
require_relative 'rubocop/cop/layout/access_modifier_indentation'
|
184
191
|
require_relative 'rubocop/cop/layout/align_arguments'
|
@@ -325,6 +332,7 @@ require_relative 'rubocop/cop/lint/safe_navigation_consistency'
|
|
325
332
|
require_relative 'rubocop/cop/lint/safe_navigation_chain'
|
326
333
|
require_relative 'rubocop/cop/lint/safe_navigation_with_empty'
|
327
334
|
require_relative 'rubocop/cop/lint/script_permission'
|
335
|
+
require_relative 'rubocop/cop/lint/send_with_mixin_argument'
|
328
336
|
require_relative 'rubocop/cop/lint/shadowed_argument'
|
329
337
|
require_relative 'rubocop/cop/lint/shadowed_exception'
|
330
338
|
require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
|
@@ -411,6 +419,7 @@ require_relative 'rubocop/cop/style/def_with_parentheses'
|
|
411
419
|
require_relative 'rubocop/cop/style/dir'
|
412
420
|
require_relative 'rubocop/cop/style/documentation_method'
|
413
421
|
require_relative 'rubocop/cop/style/documentation'
|
422
|
+
require_relative 'rubocop/cop/style/double_cop_disable_directive'
|
414
423
|
require_relative 'rubocop/cop/style/double_negation'
|
415
424
|
require_relative 'rubocop/cop/style/each_for_simple_loop'
|
416
425
|
require_relative 'rubocop/cop/style/each_with_object'
|
@@ -425,6 +434,7 @@ require_relative 'rubocop/cop/style/end_block'
|
|
425
434
|
require_relative 'rubocop/cop/style/eval_with_location'
|
426
435
|
require_relative 'rubocop/cop/style/even_odd'
|
427
436
|
require_relative 'rubocop/cop/style/expand_path_arguments'
|
437
|
+
require_relative 'rubocop/cop/style/float_division'
|
428
438
|
require_relative 'rubocop/cop/style/for'
|
429
439
|
require_relative 'rubocop/cop/style/format_string'
|
430
440
|
require_relative 'rubocop/cop/style/format_string_token'
|
@@ -462,6 +472,7 @@ require_relative 'rubocop/cop/style/multiline_if_modifier'
|
|
462
472
|
require_relative 'rubocop/cop/style/multiline_method_signature'
|
463
473
|
require_relative 'rubocop/cop/style/multiline_memoization'
|
464
474
|
require_relative 'rubocop/cop/style/multiline_ternary_operator'
|
475
|
+
require_relative 'rubocop/cop/style/multiline_when_then'
|
465
476
|
require_relative 'rubocop/cop/style/multiple_comparison'
|
466
477
|
require_relative 'rubocop/cop/style/mutable_constant'
|
467
478
|
require_relative 'rubocop/cop/style/negated_if'
|
@@ -547,58 +558,6 @@ require_relative 'rubocop/cop/style/word_array'
|
|
547
558
|
require_relative 'rubocop/cop/style/yoda_condition'
|
548
559
|
require_relative 'rubocop/cop/style/zero_length_predicate'
|
549
560
|
|
550
|
-
require_relative 'rubocop/cop/rails/action_filter'
|
551
|
-
require_relative 'rubocop/cop/rails/active_record_aliases'
|
552
|
-
require_relative 'rubocop/cop/rails/active_record_override'
|
553
|
-
require_relative 'rubocop/cop/rails/active_support_aliases'
|
554
|
-
require_relative 'rubocop/cop/rails/application_job'
|
555
|
-
require_relative 'rubocop/cop/rails/application_record'
|
556
|
-
require_relative 'rubocop/cop/rails/assert_not'
|
557
|
-
require_relative 'rubocop/cop/rails/belongs_to'
|
558
|
-
require_relative 'rubocop/cop/rails/blank'
|
559
|
-
require_relative 'rubocop/cop/rails/bulk_change_table'
|
560
|
-
require_relative 'rubocop/cop/rails/create_table_with_timestamps'
|
561
|
-
require_relative 'rubocop/cop/rails/date'
|
562
|
-
require_relative 'rubocop/cop/rails/delegate'
|
563
|
-
require_relative 'rubocop/cop/rails/delegate_allow_blank'
|
564
|
-
require_relative 'rubocop/cop/rails/dynamic_find_by'
|
565
|
-
require_relative 'rubocop/cop/rails/enum_uniqueness'
|
566
|
-
require_relative 'rubocop/cop/rails/environment_comparison'
|
567
|
-
require_relative 'rubocop/cop/rails/exit'
|
568
|
-
require_relative 'rubocop/cop/rails/file_path'
|
569
|
-
require_relative 'rubocop/cop/rails/find_by'
|
570
|
-
require_relative 'rubocop/cop/rails/find_each'
|
571
|
-
require_relative 'rubocop/cop/rails/has_and_belongs_to_many'
|
572
|
-
require_relative 'rubocop/cop/rails/has_many_or_has_one_dependent'
|
573
|
-
require_relative 'rubocop/cop/rails/http_positional_arguments'
|
574
|
-
require_relative 'rubocop/cop/rails/http_status'
|
575
|
-
require_relative 'rubocop/cop/rails/ignored_skip_action_filter_option'
|
576
|
-
require_relative 'rubocop/cop/rails/inverse_of'
|
577
|
-
require_relative 'rubocop/cop/rails/lexically_scoped_action_filter'
|
578
|
-
require_relative 'rubocop/cop/rails/link_to_blank'
|
579
|
-
require_relative 'rubocop/cop/rails/not_null_column'
|
580
|
-
require_relative 'rubocop/cop/rails/output'
|
581
|
-
require_relative 'rubocop/cop/rails/output_safety'
|
582
|
-
require_relative 'rubocop/cop/rails/pluralization_grammar'
|
583
|
-
require_relative 'rubocop/cop/rails/presence'
|
584
|
-
require_relative 'rubocop/cop/rails/present'
|
585
|
-
require_relative 'rubocop/cop/rails/read_write_attribute'
|
586
|
-
require_relative 'rubocop/cop/rails/redundant_allow_nil'
|
587
|
-
require_relative 'rubocop/cop/rails/redundant_receiver_in_with_options'
|
588
|
-
require_relative 'rubocop/cop/rails/reflection_class_name'
|
589
|
-
require_relative 'rubocop/cop/rails/refute_methods'
|
590
|
-
require_relative 'rubocop/cop/rails/relative_date_constant'
|
591
|
-
require_relative 'rubocop/cop/rails/request_referer'
|
592
|
-
require_relative 'rubocop/cop/rails/reversible_migration'
|
593
|
-
require_relative 'rubocop/cop/rails/safe_navigation'
|
594
|
-
require_relative 'rubocop/cop/rails/save_bang'
|
595
|
-
require_relative 'rubocop/cop/rails/scope_args'
|
596
|
-
require_relative 'rubocop/cop/rails/skips_model_validations'
|
597
|
-
require_relative 'rubocop/cop/rails/time_zone'
|
598
|
-
require_relative 'rubocop/cop/rails/uniq_before_pluck'
|
599
|
-
require_relative 'rubocop/cop/rails/unknown_env'
|
600
|
-
require_relative 'rubocop/cop/rails/validation'
|
601
|
-
|
602
561
|
require_relative 'rubocop/cop/security/eval'
|
603
562
|
require_relative 'rubocop/cop/security/json_load'
|
604
563
|
require_relative 'rubocop/cop/security/marshal_load'
|
@@ -623,6 +582,7 @@ require_relative 'rubocop/formatter/progress_formatter'
|
|
623
582
|
require_relative 'rubocop/formatter/quiet_formatter'
|
624
583
|
require_relative 'rubocop/formatter/tap_formatter'
|
625
584
|
require_relative 'rubocop/formatter/worst_offenders_formatter'
|
585
|
+
require_relative 'rubocop/formatter/pacman_formatter'
|
626
586
|
# relies on progress formatter
|
627
587
|
require_relative 'rubocop/formatter/auto_gen_config_formatter'
|
628
588
|
|
@@ -632,7 +592,9 @@ require_relative 'rubocop/cached_data'
|
|
632
592
|
require_relative 'rubocop/config'
|
633
593
|
require_relative 'rubocop/config_loader_resolver'
|
634
594
|
require_relative 'rubocop/config_loader'
|
595
|
+
require_relative 'rubocop/config_obsoletion'
|
635
596
|
require_relative 'rubocop/config_store'
|
597
|
+
require_relative 'rubocop/config_validator'
|
636
598
|
require_relative 'rubocop/target_finder'
|
637
599
|
require_relative 'rubocop/token'
|
638
600
|
require_relative 'rubocop/comment_config'
|
data/lib/rubocop/ast/builder.rb
CHANGED
data/lib/rubocop/ast/node.rb
CHANGED
@@ -302,12 +302,10 @@ module RuboCop
|
|
302
302
|
|
303
303
|
## Destructuring
|
304
304
|
|
305
|
-
def_node_matcher :receiver,
|
305
|
+
def_node_matcher :receiver, <<~PATTERN
|
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
|
@@ -321,7 +319,7 @@ module RuboCop
|
|
321
319
|
end
|
322
320
|
end
|
323
321
|
|
324
|
-
def_node_matcher :defined_module0,
|
322
|
+
def_node_matcher :defined_module0, <<~PATTERN
|
325
323
|
{(class (const $_ $_) ...)
|
326
324
|
(module (const $_ $_) ...)
|
327
325
|
(casgn $_ $_ (send (const nil? {:Class :Module}) :new ...))
|
@@ -367,7 +365,7 @@ module RuboCop
|
|
367
365
|
end
|
368
366
|
|
369
367
|
# Some cops treat the shovel operator as a kind of assignment.
|
370
|
-
def_node_matcher :assignment_or_similar?,
|
368
|
+
def_node_matcher :assignment_or_similar?, <<~PATTERN
|
371
369
|
{assignment? (send _recv :<< ...)}
|
372
370
|
PATTERN
|
373
371
|
|
@@ -405,7 +403,7 @@ module RuboCop
|
|
405
403
|
receiver.send(recursive_kind) &&
|
406
404
|
arguments.all?(&recursive_kind)
|
407
405
|
when :begin, :pair, *OPERATOR_KEYWORDS, *COMPOSITE_LITERALS
|
408
|
-
children.all?(&recursive_kind)
|
406
|
+
children.compact.all?(&recursive_kind)
|
409
407
|
else
|
410
408
|
send(kind_filter)
|
411
409
|
end
|
@@ -479,11 +477,11 @@ module RuboCop
|
|
479
477
|
irange_type? || erange_type?
|
480
478
|
end
|
481
479
|
|
482
|
-
def_node_matcher :guard_clause?,
|
483
|
-
[{(send nil? {:raise :fail} ...) return break next} single_line?]
|
480
|
+
def_node_matcher :guard_clause?, <<~PATTERN
|
481
|
+
[${(send nil? {:raise :fail} ...) return break next} single_line?]
|
484
482
|
PATTERN
|
485
483
|
|
486
|
-
def_node_matcher :proc?,
|
484
|
+
def_node_matcher :proc?, <<~PATTERN
|
487
485
|
{(block (send nil? :proc) ...)
|
488
486
|
(block (send (const nil? :Proc) :new) ...)
|
489
487
|
(send (const nil? :Proc) :new)}
|
@@ -492,15 +490,11 @@ module RuboCop
|
|
492
490
|
def_node_matcher :lambda?, '(block (send nil? :lambda) ...)'
|
493
491
|
def_node_matcher :lambda_or_proc?, '{lambda? proc?}'
|
494
492
|
|
495
|
-
def_node_matcher :class_constructor?,
|
493
|
+
def_node_matcher :class_constructor?, <<~PATTERN
|
496
494
|
{ (send (const nil? {:Class :Module}) :new ...)
|
497
495
|
(block (send (const nil? {:Class :Module}) :new ...) ...)}
|
498
496
|
PATTERN
|
499
497
|
|
500
|
-
def_node_matcher :module_definition?, <<-PATTERN
|
501
|
-
{class module (casgn _ _ class_constructor?)}
|
502
|
-
PATTERN
|
503
|
-
|
504
498
|
# Some expressions are evaluated for their value, some for their side
|
505
499
|
# effects, and some for both
|
506
500
|
# If we know that an expression is useful only for its side effects, that
|
@@ -638,7 +632,7 @@ module RuboCop
|
|
638
632
|
end
|
639
633
|
end
|
640
634
|
|
641
|
-
def_node_matcher :new_class_or_module_block?,
|
635
|
+
def_node_matcher :new_class_or_module_block?, <<~PATTERN
|
642
636
|
^(casgn _ _ (block (send (const _ {:Class :Module}) :new) ...))
|
643
637
|
PATTERN
|
644
638
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module AST
|
5
|
+
# A node extension for `float` nodes. This will be used in place of a plain
|
6
|
+
# node when the builder constructs the AST, making its methods available to
|
7
|
+
# all `float` nodes within RuboCop.
|
8
|
+
class FloatNode < Node
|
9
|
+
include NumericNode
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module AST
|
5
|
+
# A node extension for `int` nodes. This will be used in place of a plain
|
6
|
+
# node when the builder constructs the AST, making its methods available to
|
7
|
+
# all `int` nodes within RuboCop.
|
8
|
+
class IntNode < Node
|
9
|
+
include NumericNode
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -220,7 +220,7 @@ module RuboCop
|
|
220
220
|
|
221
221
|
private
|
222
222
|
|
223
|
-
def_node_matcher :macro_scope?,
|
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?
|
@@ -245,15 +245,15 @@ module RuboCop
|
|
245
245
|
node.parent.nil?
|
246
246
|
end
|
247
247
|
|
248
|
-
def_node_matcher :adjacent_def_modifier?,
|
248
|
+
def_node_matcher :adjacent_def_modifier?, <<~PATTERN
|
249
249
|
(send nil? _ ({def defs} ...))
|
250
250
|
PATTERN
|
251
251
|
|
252
|
-
def_node_matcher :bare_access_modifier_declaration?,
|
252
|
+
def_node_matcher :bare_access_modifier_declaration?, <<~PATTERN
|
253
253
|
(send nil? {:public :protected :private :module_function})
|
254
254
|
PATTERN
|
255
255
|
|
256
|
-
def_node_matcher :non_bare_access_modifier_declaration?,
|
256
|
+
def_node_matcher :non_bare_access_modifier_declaration?, <<~PATTERN
|
257
257
|
(send nil? {:public :protected :private :module_function} _)
|
258
258
|
PATTERN
|
259
259
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module AST
|
5
|
+
# Common functionality for primitive numeric nodes: `int`, `float`, ...
|
6
|
+
module NumericNode
|
7
|
+
SIGN_REGEX = /\A[+-]/.freeze
|
8
|
+
|
9
|
+
# Checks whether this is literal has a sign.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
#
|
13
|
+
# +42
|
14
|
+
#
|
15
|
+
# @return [Boolean] whether this literal has a sign.
|
16
|
+
def sign?
|
17
|
+
source.match(SIGN_REGEX)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -17,12 +17,7 @@ module RuboCop
|
|
17
17
|
#
|
18
18
|
# @return [Node, nil] The exception variable of the `resbody`.
|
19
19
|
def exception_variable
|
20
|
-
|
21
|
-
return variable if variable
|
22
|
-
|
23
|
-
# When resbody is an implicit rescue (i.e. `rescue e` style),
|
24
|
-
# the exception variable is descendants[1].
|
25
|
-
descendants[1]
|
20
|
+
node_parts[1]
|
26
21
|
end
|
27
22
|
end
|
28
23
|
end
|
@@ -35,7 +35,7 @@ module RuboCop
|
|
35
35
|
end
|
36
36
|
|
37
37
|
ONE_CHILD_NODE.each do |type|
|
38
|
-
module_eval(
|
38
|
+
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
39
39
|
def on_#{type}(node)
|
40
40
|
if (child = node.children[0])
|
41
41
|
send(:"on_\#{child.type}", child)
|
@@ -45,7 +45,7 @@ module RuboCop
|
|
45
45
|
end
|
46
46
|
|
47
47
|
MANY_CHILD_NODES.each do |type|
|
48
|
-
module_eval(
|
48
|
+
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
49
49
|
def on_#{type}(node)
|
50
50
|
node.children.each { |child| send(:"on_\#{child.type}", child) }
|
51
51
|
nil
|
@@ -55,7 +55,7 @@ module RuboCop
|
|
55
55
|
|
56
56
|
SECOND_CHILD_ONLY.each do |type|
|
57
57
|
# Guard clause is for nodes nested within mlhs
|
58
|
-
module_eval(
|
58
|
+
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
59
59
|
def on_#{type}(node)
|
60
60
|
if (child = node.children[1])
|
61
61
|
send(:"on_\#{child.type}", child)
|
data/lib/rubocop/cached_data.rb
CHANGED
@@ -38,7 +38,7 @@ module RuboCop
|
|
38
38
|
def message(offense)
|
39
39
|
# JSON.dump will fail if the offense message contains text which is not
|
40
40
|
# valid UTF-8
|
41
|
-
offense.message.scrub
|
41
|
+
offense.message.dup.force_encoding(::Encoding::UTF_8).scrub
|
42
42
|
end
|
43
43
|
|
44
44
|
# Restore an offense object loaded from a JSON file.
|
@@ -11,7 +11,8 @@ module RuboCop
|
|
11
11
|
COPS_PATTERN = "(all|#{COP_NAMES_PATTERN})"
|
12
12
|
|
13
13
|
COMMENT_DIRECTIVE_REGEXP = Regexp.new(
|
14
|
-
('# rubocop : ((?:
|
14
|
+
('# rubocop : ((?:disable|enable|todo))\b ' + COPS_PATTERN)
|
15
|
+
.gsub(' ', '\s*')
|
15
16
|
)
|
16
17
|
|
17
18
|
CopAnalysis = Struct.new(:line_ranges, :start_line_number)
|
@@ -141,7 +142,7 @@ module RuboCop
|
|
141
142
|
cop_names =
|
142
143
|
cops_string == 'all' ? all_cop_names : cops_string.split(/,\s*/)
|
143
144
|
|
144
|
-
disabled = (switch
|
145
|
+
disabled = %w[disable todo].include?(switch)
|
145
146
|
|
146
147
|
[cop_names, disabled]
|
147
148
|
end
|
data/lib/rubocop/config.rb
CHANGED
@@ -8,227 +8,12 @@ module RuboCop
|
|
8
8
|
# file from which it was read. Several different Configs can be used
|
9
9
|
# during a run of the rubocop program, if files in several
|
10
10
|
# directories are inspected.
|
11
|
-
|
12
|
-
# rubocop:disable Metrics/ClassLength
|
13
11
|
class Config
|
14
12
|
include PathUtil
|
15
13
|
include FileFinder
|
14
|
+
extend Forwardable
|
16
15
|
|
17
|
-
COMMON_PARAMS = %w[Exclude Include Severity inherit_mode
|
18
|
-
AutoCorrect StyleGuide Details].freeze
|
19
|
-
INTERNAL_PARAMS = %w[Description StyleGuide VersionAdded
|
20
|
-
VersionChanged Reference Safe SafeAutoCorrect].freeze
|
21
|
-
|
22
|
-
# 2.3 is the oldest officially supported Ruby version.
|
23
|
-
DEFAULT_RUBY_VERSION = 2.3
|
24
|
-
KNOWN_RUBIES = [2.3, 2.4, 2.5, 2.6].freeze
|
25
|
-
OBSOLETE_RUBIES = {
|
26
|
-
1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69'
|
27
|
-
}.freeze
|
28
|
-
RUBY_VERSION_FILENAME = '.ruby-version'
|
29
16
|
DEFAULT_RAILS_VERSION = 5.0
|
30
|
-
OBSOLETE_COPS = {
|
31
|
-
'Style/FlipFlop' =>
|
32
|
-
'The `Style/FlipFlop` cop has been moved to `Lint/FlipFlop`.',
|
33
|
-
'Style/TrailingComma' =>
|
34
|
-
'The `Style/TrailingComma` cop no longer exists. Please use ' \
|
35
|
-
'`Style/TrailingCommaInArguments`, ' \
|
36
|
-
'`Style/TrailingCommaInArrayLiteral`, and/or ' \
|
37
|
-
'`Style/TrailingCommaInHashLiteral` instead.',
|
38
|
-
'Style/TrailingCommaInLiteral' =>
|
39
|
-
'The `Style/TrailingCommaInLiteral` cop no longer exists. Please use ' \
|
40
|
-
'`Style/TrailingCommaInArrayLiteral` and/or ' \
|
41
|
-
'`Style/TrailingCommaInHashLiteral` instead.',
|
42
|
-
'Rails/DefaultScope' =>
|
43
|
-
'The `Rails/DefaultScope` cop no longer exists.',
|
44
|
-
'Lint/InvalidCharacterLiteral' =>
|
45
|
-
'The `Lint/InvalidCharacterLiteral` cop has been removed since it ' \
|
46
|
-
'was never being actually triggered.',
|
47
|
-
'Style/SingleSpaceBeforeFirstArg' =>
|
48
|
-
'The `Style/SingleSpaceBeforeFirstArg` cop has been renamed to ' \
|
49
|
-
'`Layout/SpaceBeforeFirstArg`.',
|
50
|
-
'Lint/RescueWithoutErrorClass' =>
|
51
|
-
'The `Lint/RescueWithoutErrorClass` cop has been replaced by ' \
|
52
|
-
'`Style/RescueStandardError`.',
|
53
|
-
'Lint/SpaceBeforeFirstArg' =>
|
54
|
-
'The `Lint/SpaceBeforeFirstArg` cop has been removed, since it was a ' \
|
55
|
-
'duplicate of `Layout/SpaceBeforeFirstArg`. Please use ' \
|
56
|
-
'`Layout/SpaceBeforeFirstArg` instead.',
|
57
|
-
'Layout/FirstParameterIndentation' =>
|
58
|
-
'The `Layout/FirstParameterIndentation` cop has been renamed to ' \
|
59
|
-
'`Layout/IndentFirstArgument`.',
|
60
|
-
'Layout/IndentArray' =>
|
61
|
-
'The `Layout/IndentArray` cop has been renamed to ' \
|
62
|
-
'`Layout/IndentFirstArrayElement`.',
|
63
|
-
'Layout/IndentHash' =>
|
64
|
-
'The `Layout/IndentHash` cop has been renamed to ' \
|
65
|
-
'`Layout/IndentFirstHashElement`.',
|
66
|
-
'Layout/SpaceAfterControlKeyword' =>
|
67
|
-
'The `Layout/SpaceAfterControlKeyword` cop has been removed. Please ' \
|
68
|
-
'use `Layout/SpaceAroundKeyword` instead.',
|
69
|
-
'Layout/SpaceBeforeModifierKeyword' =>
|
70
|
-
'The `Layout/SpaceBeforeModifierKeyword` cop has been removed. ' \
|
71
|
-
'Please use `Layout/SpaceAroundKeyword` instead.',
|
72
|
-
'Style/SpaceAfterControlKeyword' =>
|
73
|
-
'The `Style/SpaceAfterControlKeyword` cop has been removed. Please ' \
|
74
|
-
'use `Layout/SpaceAroundKeyword` instead.',
|
75
|
-
'Style/SpaceBeforeModifierKeyword' =>
|
76
|
-
'The `Style/SpaceBeforeModifierKeyword` cop has been removed. Please ' \
|
77
|
-
'use `Layout/SpaceAroundKeyword` instead.',
|
78
|
-
'Style/MethodCallParentheses' =>
|
79
|
-
'The `Style/MethodCallParentheses` cop has been renamed to ' \
|
80
|
-
'`Style/MethodCallWithoutArgsParentheses`.',
|
81
|
-
'Lint/Eval' =>
|
82
|
-
'The `Lint/Eval` cop has been renamed to `Security/Eval`.',
|
83
|
-
'Style/DeprecatedHashMethods' =>
|
84
|
-
'The `Style/DeprecatedHashMethods` cop has been renamed to ' \
|
85
|
-
'`Style/PreferredHashMethods`.',
|
86
|
-
'Style/AccessorMethodName' =>
|
87
|
-
'The `Style/AccessorMethodName` cop has been moved to ' \
|
88
|
-
'`Naming/AccessorMethodName`.',
|
89
|
-
'Style/AsciiIdentifiers' =>
|
90
|
-
'The `Style/AsciiIdentifiers` cop has been moved to ' \
|
91
|
-
'`Naming/AccessorMethodName`.',
|
92
|
-
'Style/OpMethod' =>
|
93
|
-
'The `Style/OpMethod` cop has been renamed and moved to ' \
|
94
|
-
'`Naming/BinaryOperatorParameterName`.',
|
95
|
-
'Style/ClassAndModuleCamelCase' =>
|
96
|
-
'The `Style/ClassAndModuleCamelCase` cop has been renamed to ' \
|
97
|
-
'`Naming/ClassAndModuleCamelCase`.',
|
98
|
-
'Style/ConstantName' =>
|
99
|
-
'The `Style/ConstantName` cop has been renamed to ' \
|
100
|
-
'`Naming/ConstantName`.',
|
101
|
-
'Style/FileName' =>
|
102
|
-
'The `Style/FileName` cop has been renamed to `Naming/FileName`.',
|
103
|
-
'Style/MethodName' =>
|
104
|
-
'The `Style/MethodName` cop has been renamed to ' \
|
105
|
-
'`Naming/MethodName`.',
|
106
|
-
'Style/PredicateName' =>
|
107
|
-
'The `Style/PredicateName` cop has been renamed to ' \
|
108
|
-
'`Naming/PredicateName`.',
|
109
|
-
'Style/VariableName' =>
|
110
|
-
'The `Style/VariableName` cop has been renamed to ' \
|
111
|
-
'`Naming/VariableName`.',
|
112
|
-
'Style/VariableNumber' =>
|
113
|
-
'The `Style/VariableNumber` cop has been renamed to ' \
|
114
|
-
'`Naming/VariableNumber`.',
|
115
|
-
'Lint/BlockAlignment' =>
|
116
|
-
'The `Lint/BlockAlignment` cop has been renamed to ' \
|
117
|
-
'`Layout/BlockAlignment`.',
|
118
|
-
'Lint/EndAlignment' =>
|
119
|
-
'The `Lint/EndAlignment` cop has been renamed to ' \
|
120
|
-
'`Layout/EndAlignment`.',
|
121
|
-
'Lint/DefEndAlignment' =>
|
122
|
-
'The `Lint/DefEndAlignment` cop has been renamed to ' \
|
123
|
-
'`Layout/DefEndAlignment`.',
|
124
|
-
'Style/MethodMissing' =>
|
125
|
-
'The `Style/MethodMissing` cop has been split into ' \
|
126
|
-
'`Style/MethodMissingSuper` and `Style/MissingRespondToMissing`.'
|
127
|
-
}.freeze
|
128
|
-
|
129
|
-
OBSOLETE_PARAMETERS = [
|
130
|
-
{
|
131
|
-
cop: 'Layout/SpaceAroundOperators',
|
132
|
-
parameter: 'MultiSpaceAllowedForOperators',
|
133
|
-
alternative: 'If your intention was to allow extra spaces ' \
|
134
|
-
'for alignment, please use AllowForAlignment: ' \
|
135
|
-
'true instead.'
|
136
|
-
},
|
137
|
-
{
|
138
|
-
cop: 'Style/Encoding',
|
139
|
-
parameter: 'EnforcedStyle',
|
140
|
-
alternative: 'Style/Encoding no longer supports styles. ' \
|
141
|
-
'The "never" behavior is always assumed.'
|
142
|
-
},
|
143
|
-
{
|
144
|
-
cop: 'Style/Encoding',
|
145
|
-
parameter: 'SupportedStyles',
|
146
|
-
alternative: 'Style/Encoding no longer supports styles. ' \
|
147
|
-
'The "never" behavior is always assumed.'
|
148
|
-
},
|
149
|
-
{
|
150
|
-
cop: 'Style/Encoding',
|
151
|
-
parameter: 'AutoCorrectEncodingComment',
|
152
|
-
alternative: 'Style/Encoding no longer supports styles. ' \
|
153
|
-
'The "never" behavior is always assumed.'
|
154
|
-
},
|
155
|
-
{
|
156
|
-
cop: 'Style/IfUnlessModifier',
|
157
|
-
parameter: 'MaxLineLength',
|
158
|
-
alternative:
|
159
|
-
'`Style/IfUnlessModifier: MaxLineLength` has been removed. Use ' \
|
160
|
-
'`Metrics/LineLength: Max` instead'
|
161
|
-
},
|
162
|
-
{
|
163
|
-
cop: 'Style/SpaceAroundOperators',
|
164
|
-
parameter: 'MultiSpaceAllowedForOperators',
|
165
|
-
alternative: 'If your intention was to allow extra spaces ' \
|
166
|
-
'for alignment, please use AllowForAlignment: ' \
|
167
|
-
'true instead.'
|
168
|
-
},
|
169
|
-
{
|
170
|
-
cop: 'Style/WhileUntilModifier',
|
171
|
-
parameter: 'MaxLineLength',
|
172
|
-
alternative:
|
173
|
-
'`Style/WhileUntilModifier: MaxLineLength` has been removed. Use ' \
|
174
|
-
'`Metrics/LineLength: Max` instead'
|
175
|
-
},
|
176
|
-
{
|
177
|
-
cop: 'AllCops',
|
178
|
-
parameter: 'RunRailsCops',
|
179
|
-
alternative: "Use the following configuration instead:\n" \
|
180
|
-
"Rails:\n Enabled: true"
|
181
|
-
},
|
182
|
-
{
|
183
|
-
cop: 'Layout/CaseIndentation',
|
184
|
-
parameter: 'IndentWhenRelativeTo',
|
185
|
-
alternative: '`IndentWhenRelativeTo` has been renamed to ' \
|
186
|
-
'`EnforcedStyle`'
|
187
|
-
},
|
188
|
-
{
|
189
|
-
cop: 'Lint/BlockAlignment',
|
190
|
-
parameter: 'AlignWith',
|
191
|
-
alternative: '`AlignWith` has been renamed to ' \
|
192
|
-
'`EnforcedStyleAlignWith`'
|
193
|
-
},
|
194
|
-
{
|
195
|
-
cop: 'Layout/BlockAlignment',
|
196
|
-
parameter: 'AlignWith',
|
197
|
-
alternative: '`AlignWith` has been renamed to ' \
|
198
|
-
'`EnforcedStyleAlignWith`'
|
199
|
-
},
|
200
|
-
{
|
201
|
-
cop: 'Lint/EndAlignment',
|
202
|
-
parameter: 'AlignWith',
|
203
|
-
alternative: '`AlignWith` has been renamed to ' \
|
204
|
-
'`EnforcedStyleAlignWith`'
|
205
|
-
},
|
206
|
-
{
|
207
|
-
cop: 'Layout/EndAlignment',
|
208
|
-
parameter: 'AlignWith',
|
209
|
-
alternative: '`AlignWith` has been renamed to ' \
|
210
|
-
'`EnforcedStyleAlignWith`'
|
211
|
-
},
|
212
|
-
{
|
213
|
-
cop: 'Lint/DefEndAlignment',
|
214
|
-
parameter: 'AlignWith',
|
215
|
-
alternative: '`AlignWith` has been renamed to ' \
|
216
|
-
'`EnforcedStyleAlignWith`'
|
217
|
-
},
|
218
|
-
{
|
219
|
-
cop: 'Layout/DefEndAlignment',
|
220
|
-
parameter: 'AlignWith',
|
221
|
-
alternative: '`AlignWith` has been renamed to ' \
|
222
|
-
'`EnforcedStyleAlignWith`'
|
223
|
-
},
|
224
|
-
{
|
225
|
-
cop: 'Rails/UniqBeforePluck',
|
226
|
-
parameter: 'EnforcedMode',
|
227
|
-
alternative: '`EnforcedMode` has been renamed to ' \
|
228
|
-
'`EnforcedStyle`'
|
229
|
-
}
|
230
|
-
].freeze
|
231
|
-
|
232
17
|
attr_reader :loaded_path
|
233
18
|
|
234
19
|
def initialize(hash = {}, loaded_path = nil)
|
@@ -240,6 +25,7 @@ module RuboCop
|
|
240
25
|
h[cop] = cop_options
|
241
26
|
end
|
242
27
|
@hash = hash
|
28
|
+
@validator = ConfigValidator.new(self)
|
243
29
|
end
|
244
30
|
|
245
31
|
def self.create(hash, path)
|
@@ -250,54 +36,14 @@ module RuboCop
|
|
250
36
|
deprecation_check do |deprecation_message|
|
251
37
|
warn("#{loaded_path} - #{deprecation_message}")
|
252
38
|
end
|
253
|
-
validate
|
39
|
+
@validator.validate
|
254
40
|
make_excludes_absolute
|
255
41
|
self
|
256
42
|
end
|
257
43
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
def []=(key, value)
|
263
|
-
@hash[key] = value
|
264
|
-
end
|
265
|
-
|
266
|
-
def delete(key)
|
267
|
-
@hash.delete(key)
|
268
|
-
end
|
269
|
-
|
270
|
-
def each(&block)
|
271
|
-
@hash.each(&block)
|
272
|
-
end
|
273
|
-
|
274
|
-
def key?(key)
|
275
|
-
@hash.key?(key)
|
276
|
-
end
|
277
|
-
|
278
|
-
def keys
|
279
|
-
@hash.keys
|
280
|
-
end
|
281
|
-
|
282
|
-
def each_key(&block)
|
283
|
-
@hash.each_key(&block)
|
284
|
-
end
|
285
|
-
|
286
|
-
def map(&block)
|
287
|
-
@hash.map(&block)
|
288
|
-
end
|
289
|
-
|
290
|
-
def merge(other_hash)
|
291
|
-
@hash.merge(other_hash)
|
292
|
-
end
|
293
|
-
|
294
|
-
def to_h
|
295
|
-
@hash
|
296
|
-
end
|
297
|
-
|
298
|
-
def to_hash
|
299
|
-
@hash
|
300
|
-
end
|
44
|
+
def_delegators :@hash, :[], :[]=, :delete, :each, :key?, :keys, :each_key,
|
45
|
+
:map, :merge, :to_h, :to_hash
|
46
|
+
def_delegators :@validator, :validate, :target_ruby_version
|
301
47
|
|
302
48
|
def to_s
|
303
49
|
@to_s ||= @hash.to_s
|
@@ -309,7 +55,7 @@ module RuboCop
|
|
309
55
|
|
310
56
|
def make_excludes_absolute
|
311
57
|
each_key do |key|
|
312
|
-
validate_section_presence(key)
|
58
|
+
@validator.validate_section_presence(key)
|
313
59
|
next unless self[key]['Exclude']
|
314
60
|
|
315
61
|
self[key]['Exclude'].map! do |exclude_elem|
|
@@ -350,27 +96,12 @@ module RuboCop
|
|
350
96
|
@for_cop[cop.respond_to?(:cop_name) ? cop.cop_name : cop]
|
351
97
|
end
|
352
98
|
|
353
|
-
def
|
354
|
-
@
|
99
|
+
def for_department(department_name)
|
100
|
+
@for_cop[department_name]
|
355
101
|
end
|
356
102
|
|
357
|
-
def
|
358
|
-
|
359
|
-
base_config_path = File.expand_path(File.join(ConfigLoader::RUBOCOP_HOME,
|
360
|
-
'config'))
|
361
|
-
return if File.expand_path(loaded_path).start_with?(base_config_path)
|
362
|
-
|
363
|
-
valid_cop_names, invalid_cop_names = keys.partition do |key|
|
364
|
-
ConfigLoader.default_configuration.key?(key)
|
365
|
-
end
|
366
|
-
|
367
|
-
reject_obsolete_cops_and_parameters
|
368
|
-
warn_about_unrecognized_cops(invalid_cop_names)
|
369
|
-
check_target_ruby
|
370
|
-
validate_parameter_names(valid_cop_names)
|
371
|
-
validate_enforced_styles(valid_cop_names)
|
372
|
-
validate_syntax_cop
|
373
|
-
reject_mutually_exclusive_defaults
|
103
|
+
def for_all_cops
|
104
|
+
@for_all_cops ||= self['AllCops'] || {}
|
374
105
|
end
|
375
106
|
|
376
107
|
def file_to_include?(file)
|
@@ -451,26 +182,6 @@ module RuboCop
|
|
451
182
|
end
|
452
183
|
end
|
453
184
|
|
454
|
-
def target_ruby_version
|
455
|
-
@target_ruby_version ||= begin
|
456
|
-
if for_all_cops['TargetRubyVersion']
|
457
|
-
@target_ruby_version_source = :rubocop_yml
|
458
|
-
|
459
|
-
for_all_cops['TargetRubyVersion'].to_f
|
460
|
-
elsif target_ruby_version_from_version_file
|
461
|
-
@target_ruby_version_source = :ruby_version_file
|
462
|
-
|
463
|
-
target_ruby_version_from_version_file
|
464
|
-
elsif target_ruby_version_from_bundler_lock_file
|
465
|
-
@target_ruby_version_source = :bundler_lock_file
|
466
|
-
|
467
|
-
target_ruby_version_from_bundler_lock_file
|
468
|
-
else
|
469
|
-
DEFAULT_RUBY_VERSION
|
470
|
-
end
|
471
|
-
end
|
472
|
-
end
|
473
|
-
|
474
185
|
def target_rails_version
|
475
186
|
@target_rails_version ||=
|
476
187
|
if for_all_cops['TargetRailsVersion']
|
@@ -482,195 +193,22 @@ module RuboCop
|
|
482
193
|
end
|
483
194
|
end
|
484
195
|
|
485
|
-
|
486
|
-
|
487
|
-
def warn_about_unrecognized_cops(invalid_cop_names)
|
488
|
-
invalid_cop_names.each do |name|
|
489
|
-
# There could be a custom cop with this name. If so, don't warn
|
490
|
-
next if Cop::Cop.registry.contains_cop_matching?([name])
|
491
|
-
|
492
|
-
# Special case for inherit_mode, which is a directive that we keep in
|
493
|
-
# the configuration (even though it's not a cop), because it's easier
|
494
|
-
# to do so than to pass the value around to various methods.
|
495
|
-
next if name == 'inherit_mode'
|
496
|
-
|
497
|
-
warn Rainbow("Warning: unrecognized cop #{name} found in " \
|
498
|
-
"#{smart_loaded_path}").yellow
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
def validate_syntax_cop
|
503
|
-
syntax_config = self['Lint/Syntax']
|
504
|
-
default_config = ConfigLoader.default_configuration['Lint/Syntax']
|
505
|
-
|
506
|
-
return unless syntax_config &&
|
507
|
-
default_config.merge(syntax_config) != default_config
|
508
|
-
|
509
|
-
raise ValidationError,
|
510
|
-
"configuration for Syntax cop found in #{smart_loaded_path}\n" \
|
511
|
-
'It\'s not possible to disable this cop.'
|
512
|
-
end
|
513
|
-
|
514
|
-
def validate_section_presence(name)
|
515
|
-
return unless key?(name) && self[name].nil?
|
516
|
-
|
517
|
-
raise ValidationError,
|
518
|
-
"empty section #{name} found in #{smart_loaded_path}"
|
519
|
-
end
|
520
|
-
|
521
|
-
def validate_parameter_names(valid_cop_names)
|
522
|
-
valid_cop_names.each do |name|
|
523
|
-
validate_section_presence(name)
|
524
|
-
default_config = ConfigLoader.default_configuration[name]
|
525
|
-
|
526
|
-
self[name].each_key do |param|
|
527
|
-
next if COMMON_PARAMS.include?(param) || default_config.key?(param)
|
528
|
-
|
529
|
-
message =
|
530
|
-
"Warning: #{name} does not support #{param} parameter.\n\n" \
|
531
|
-
"Supported parameters are:\n\n" \
|
532
|
-
" - #{(default_config.keys - INTERNAL_PARAMS).join("\n - ")}\n"
|
533
|
-
|
534
|
-
warn Rainbow(message).yellow.to_s
|
535
|
-
end
|
536
|
-
end
|
537
|
-
end
|
538
|
-
|
539
|
-
def validate_enforced_styles(valid_cop_names)
|
540
|
-
valid_cop_names.each do |name|
|
541
|
-
styles = self[name].select { |key, _| key.start_with?('Enforced') }
|
542
|
-
|
543
|
-
styles.each do |style_name, style|
|
544
|
-
supported_key = RuboCop::Cop::Util.to_supported_styles(style_name)
|
545
|
-
valid = ConfigLoader.default_configuration[name][supported_key]
|
546
|
-
|
547
|
-
next unless valid
|
548
|
-
next if valid.include?(style)
|
549
|
-
next if validate_support_and_has_list(name, style, valid)
|
550
|
-
|
551
|
-
msg = "invalid #{style_name} '#{style}' for #{name} found in " \
|
552
|
-
"#{smart_loaded_path}\n" \
|
553
|
-
"Valid choices are: #{valid.join(', ')}"
|
554
|
-
raise ValidationError, msg
|
555
|
-
end
|
556
|
-
end
|
557
|
-
end
|
558
|
-
|
559
|
-
def validate_support_and_has_list(name, formats, valid)
|
560
|
-
ConfigLoader.default_configuration[name]['AllowMultipleStyles'] &&
|
561
|
-
formats.is_a?(Array) &&
|
562
|
-
formats.all? { |format| valid.include?(format) }
|
563
|
-
end
|
564
|
-
|
565
|
-
def reject_obsolete_cops_and_parameters
|
566
|
-
messages = [
|
567
|
-
obsolete_cops,
|
568
|
-
obsolete_parameters
|
569
|
-
].flatten.compact
|
570
|
-
return if messages.empty?
|
571
|
-
|
572
|
-
raise ValidationError, messages.join("\n")
|
573
|
-
end
|
574
|
-
|
575
|
-
def obsolete_parameters
|
576
|
-
OBSOLETE_PARAMETERS.map do |params|
|
577
|
-
obsolete_parameter_message(params[:cop], params[:parameter],
|
578
|
-
params[:alternative])
|
579
|
-
end
|
580
|
-
end
|
581
|
-
|
582
|
-
def obsolete_parameter_message(cop, parameter, alternative)
|
583
|
-
return unless self[cop]&.key?(parameter)
|
584
|
-
|
585
|
-
"obsolete parameter #{parameter} (for #{cop}) " \
|
586
|
-
"found in #{smart_loaded_path}" \
|
587
|
-
"\n#{alternative}"
|
588
|
-
end
|
589
|
-
|
590
|
-
def obsolete_cops
|
591
|
-
OBSOLETE_COPS.map do |cop_name, message|
|
592
|
-
next unless key?(cop_name) || key?(Cop::Badge.parse(cop_name).cop_name)
|
593
|
-
|
594
|
-
message + "\n(obsolete configuration found in #{smart_loaded_path}," \
|
595
|
-
' please update it)'
|
596
|
-
end
|
196
|
+
def smart_loaded_path
|
197
|
+
PathUtil.smart_path(@loaded_path)
|
597
198
|
end
|
598
199
|
|
599
|
-
def
|
600
|
-
return
|
601
|
-
|
602
|
-
msg = if OBSOLETE_RUBIES.include?(target_ruby_version)
|
603
|
-
"Unsupported Ruby version #{target_ruby_version} found in " \
|
604
|
-
"#{target_ruby_source}. #{target_ruby_version}-compatible " \
|
605
|
-
'analysis was dropped after version ' \
|
606
|
-
"#{OBSOLETE_RUBIES[target_ruby_version]}."
|
607
|
-
else
|
608
|
-
"Unknown Ruby version #{target_ruby_version.inspect} found in " \
|
609
|
-
"#{target_ruby_source}."
|
610
|
-
end
|
611
|
-
|
612
|
-
msg += "\nSupported versions: #{KNOWN_RUBIES.join(', ')}"
|
613
|
-
|
614
|
-
raise ValidationError, msg
|
615
|
-
end
|
200
|
+
def bundler_lock_file_path
|
201
|
+
return nil unless loaded_path
|
616
202
|
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
when :bundler_lock_file
|
622
|
-
"`#{bundler_lock_file_path}`"
|
623
|
-
when :rubocop_yml
|
624
|
-
"`TargetRubyVersion` parameter (in #{smart_loaded_path})"
|
203
|
+
base_path = base_dir_for_path_parameters
|
204
|
+
['gems.locked', 'Gemfile.lock'].each do |file_name|
|
205
|
+
path = find_file_upwards(file_name, base_path)
|
206
|
+
return path if path
|
625
207
|
end
|
208
|
+
nil
|
626
209
|
end
|
627
210
|
|
628
|
-
|
629
|
-
@ruby_version_file ||=
|
630
|
-
find_file_upwards(RUBY_VERSION_FILENAME, base_dir_for_path_parameters)
|
631
|
-
end
|
632
|
-
|
633
|
-
def target_ruby_version_from_version_file
|
634
|
-
file = ruby_version_file
|
635
|
-
return unless file && File.file?(file)
|
636
|
-
|
637
|
-
@target_ruby_version_from_version_file ||=
|
638
|
-
File.read(file).match(/\A(ruby-)?(?<version>\d+\.\d+)/) do |md|
|
639
|
-
md[:version].to_f
|
640
|
-
end
|
641
|
-
end
|
642
|
-
|
643
|
-
def target_ruby_version_from_bundler_lock_file
|
644
|
-
@target_ruby_version_from_bundler_lock_file ||=
|
645
|
-
read_ruby_version_from_bundler_lock_file
|
646
|
-
end
|
647
|
-
|
648
|
-
def read_ruby_version_from_bundler_lock_file
|
649
|
-
lock_file_path = bundler_lock_file_path
|
650
|
-
return nil unless lock_file_path
|
651
|
-
|
652
|
-
in_ruby_section = false
|
653
|
-
File.foreach(lock_file_path) do |line|
|
654
|
-
# If ruby is in Gemfile.lock or gems.lock, there should be two lines
|
655
|
-
# towards the bottom of the file that look like:
|
656
|
-
# RUBY VERSION
|
657
|
-
# ruby W.X.YpZ
|
658
|
-
# We ultimately want to match the "ruby W.X.Y.pZ" line, but there's
|
659
|
-
# extra logic to make sure we only start looking once we've seen the
|
660
|
-
# "RUBY VERSION" line.
|
661
|
-
in_ruby_section ||= line.match(/^\s*RUBY\s*VERSION\s*$/)
|
662
|
-
next unless in_ruby_section
|
663
|
-
|
664
|
-
# We currently only allow this feature to work with MRI ruby. If jruby
|
665
|
-
# (or something else) is used by the project, it's lock file will have a
|
666
|
-
# line that looks like:
|
667
|
-
# RUBY VERSION
|
668
|
-
# ruby W.X.YpZ (jruby x.x.x.x)
|
669
|
-
# The regex won't match in this situation.
|
670
|
-
result = line.match(/^\s*ruby\s+(\d+\.\d+)[p.\d]*\s*$/)
|
671
|
-
return result.captures.first.to_f if result
|
672
|
-
end
|
673
|
-
end
|
211
|
+
private
|
674
212
|
|
675
213
|
def target_rails_version_from_bundler_lock_file
|
676
214
|
@target_rails_version_from_bundler_lock_file ||=
|
@@ -689,26 +227,6 @@ module RuboCop
|
|
689
227
|
end
|
690
228
|
end
|
691
229
|
|
692
|
-
def bundler_lock_file_path
|
693
|
-
return nil unless loaded_path
|
694
|
-
|
695
|
-
base_path = base_dir_for_path_parameters
|
696
|
-
['gems.locked', 'Gemfile.lock'].each do |file_name|
|
697
|
-
path = find_file_upwards(file_name, base_path)
|
698
|
-
return path if path
|
699
|
-
end
|
700
|
-
nil
|
701
|
-
end
|
702
|
-
|
703
|
-
def reject_mutually_exclusive_defaults
|
704
|
-
disabled_by_default = for_all_cops['DisabledByDefault']
|
705
|
-
enabled_by_default = for_all_cops['EnabledByDefault']
|
706
|
-
return unless disabled_by_default && enabled_by_default
|
707
|
-
|
708
|
-
msg = 'Cops cannot be both enabled by default and disabled by default'
|
709
|
-
raise ValidationError, msg
|
710
|
-
end
|
711
|
-
|
712
230
|
def enable_cop?(qualified_cop_name, cop_options)
|
713
231
|
cop_department, cop_name = qualified_cop_name.split('/')
|
714
232
|
department = cop_name.nil?
|
@@ -722,10 +240,5 @@ module RuboCop
|
|
722
240
|
|
723
241
|
cop_options.fetch('Enabled') { !for_all_cops['DisabledByDefault'] }
|
724
242
|
end
|
725
|
-
|
726
|
-
def smart_loaded_path
|
727
|
-
PathUtil.smart_path(@loaded_path)
|
728
|
-
end
|
729
243
|
end
|
730
|
-
# rubocop:enable Metrics/ClassLength
|
731
244
|
end
|