rubocop 0.89.1 → 0.93.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 +2 -2
- data/config/default.yml +160 -14
- data/lib/rubocop.rb +33 -5
- data/lib/rubocop/cached_data.rb +3 -1
- data/lib/rubocop/cli/command.rb +1 -0
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +1 -0
- data/lib/rubocop/cli/command/base.rb +1 -0
- data/lib/rubocop/cli/command/execute_runner.rb +9 -0
- data/lib/rubocop/cli/command/init_dotfile.rb +1 -0
- data/lib/rubocop/cli/command/show_cops.rb +1 -0
- data/lib/rubocop/cli/command/version.rb +1 -0
- data/lib/rubocop/cli/environment.rb +1 -0
- data/lib/rubocop/comment_config.rb +14 -5
- data/lib/rubocop/config_loader.rb +20 -9
- data/lib/rubocop/config_loader_resolver.rb +1 -0
- data/lib/rubocop/config_obsoletion.rb +1 -0
- data/lib/rubocop/config_regeneration.rb +33 -0
- data/lib/rubocop/config_store.rb +3 -3
- data/lib/rubocop/config_validator.rb +3 -0
- data/lib/rubocop/cop/base.rb +23 -0
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +5 -1
- data/lib/rubocop/cop/bundler/gem_comment.rb +8 -3
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +2 -0
- data/lib/rubocop/cop/commissioner.rb +47 -7
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +4 -4
- data/lib/rubocop/cop/correctors/condition_corrector.rb +3 -5
- data/lib/rubocop/cop/correctors/empty_line_corrector.rb +9 -10
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +4 -4
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +8 -3
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +5 -8
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +4 -9
- data/lib/rubocop/cop/correctors/punctuation_corrector.rb +8 -10
- data/lib/rubocop/cop/documentation.rb +22 -0
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +10 -10
- data/lib/rubocop/cop/generator.rb +2 -1
- data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -0
- data/lib/rubocop/cop/layout/array_alignment.rb +1 -0
- data/lib/rubocop/cop/layout/begin_end_alignment.rb +77 -0
- data/lib/rubocop/cop/layout/block_alignment.rb +23 -19
- data/lib/rubocop/cop/layout/case_indentation.rb +4 -7
- data/lib/rubocop/cop/layout/class_structure.rb +11 -10
- data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +4 -6
- data/lib/rubocop/cop/layout/condition_position.rb +13 -15
- data/lib/rubocop/cop/layout/def_end_alignment.rb +8 -5
- data/lib/rubocop/cop/layout/dot_position.rb +21 -20
- data/lib/rubocop/cop/layout/empty_comment.rb +30 -23
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +21 -18
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +13 -13
- data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +136 -0
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +21 -23
- data/lib/rubocop/cop/layout/empty_lines.rb +6 -7
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +17 -14
- data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +7 -8
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +5 -8
- data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +2 -5
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +2 -5
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +2 -5
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +3 -7
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +2 -5
- data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +2 -5
- data/lib/rubocop/cop/layout/end_alignment.rb +11 -17
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +2 -5
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +2 -5
- data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +4 -8
- data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +2 -5
- data/lib/rubocop/cop/layout/hash_alignment.rb +17 -20
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +15 -14
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +14 -11
- data/lib/rubocop/cop/layout/initial_indentation.rb +6 -7
- data/lib/rubocop/cop/layout/leading_comment_space.rb +11 -9
- data/lib/rubocop/cop/layout/leading_empty_lines.rb +6 -11
- data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +10 -14
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +21 -19
- data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +5 -9
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +2 -5
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +41 -22
- data/lib/rubocop/cop/layout/space_after_colon.rb +11 -7
- data/lib/rubocop/cop/layout/space_after_comma.rb +2 -5
- data/lib/rubocop/cop/layout/space_after_method_name.rb +5 -6
- data/lib/rubocop/cop/layout/space_after_not.rb +9 -11
- data/lib/rubocop/cop/layout/space_after_semicolon.rb +2 -5
- data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +17 -21
- data/lib/rubocop/cop/layout/space_around_keyword.rb +17 -18
- data/lib/rubocop/cop/layout/space_around_operators.rb +17 -16
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +23 -22
- data/lib/rubocop/cop/layout/space_before_comma.rb +3 -5
- data/lib/rubocop/cop/layout/space_before_comment.rb +10 -7
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +7 -7
- data/lib/rubocop/cop/layout/space_before_semicolon.rb +2 -5
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +9 -17
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +20 -23
- data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +3 -8
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +13 -16
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +19 -37
- data/lib/rubocop/cop/layout/space_inside_parens.rb +9 -14
- data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +5 -10
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +8 -17
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +16 -24
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +12 -13
- data/lib/rubocop/cop/layout/trailing_empty_lines.rb +10 -15
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +11 -11
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +2 -0
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +2 -0
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +15 -1
- data/lib/rubocop/cop/lint/big_decimal_new.rb +1 -2
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +1 -1
- data/lib/rubocop/cop/lint/boolean_symbol.rb +3 -0
- data/lib/rubocop/cop/lint/constant_definition_in_block.rb +74 -0
- data/lib/rubocop/cop/lint/constant_resolution.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +2 -3
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -3
- data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -4
- data/lib/rubocop/cop/lint/duplicate_require.rb +46 -0
- data/lib/rubocop/cop/lint/duplicate_rescue_exception.rb +2 -15
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -0
- data/lib/rubocop/cop/lint/empty_file.rb +50 -0
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +2 -0
- data/lib/rubocop/cop/lint/float_comparison.rb +2 -2
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +2 -2
- data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +37 -0
- data/lib/rubocop/cop/lint/identity_comparison.rb +51 -0
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +2 -5
- data/lib/rubocop/cop/lint/inherit_exception.rb +2 -2
- data/lib/rubocop/cop/lint/missing_super.rb +2 -2
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +3 -35
- data/lib/rubocop/cop/lint/multiple_comparison.rb +3 -1
- data/lib/rubocop/cop/lint/number_conversion.rb +1 -0
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +9 -20
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/percent_string_array.rb +8 -12
- data/lib/rubocop/cop/lint/raise_exception.rb +1 -0
- data/lib/rubocop/cop/lint/rand_one.rb +2 -1
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +22 -12
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +14 -4
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -0
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +45 -0
- data/lib/rubocop/cop/lint/rescue_type.rb +0 -1
- data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +3 -1
- data/lib/rubocop/cop/lint/shadowed_exception.rb +6 -6
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +4 -4
- data/lib/rubocop/cop/lint/struct_new_override.rb +1 -0
- data/lib/rubocop/cop/lint/to_json.rb +16 -5
- data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
- data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +57 -0
- data/lib/rubocop/cop/lint/unreachable_loop.rb +3 -6
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +3 -1
- data/lib/rubocop/cop/lint/uri_regexp.rb +2 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +3 -9
- data/lib/rubocop/cop/lint/useless_method_definition.rb +70 -0
- data/lib/rubocop/cop/lint/useless_times.rb +106 -0
- data/lib/rubocop/cop/metrics/block_length.rb +3 -1
- data/lib/rubocop/cop/metrics/class_length.rb +8 -6
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +27 -16
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -0
- data/lib/rubocop/cop/mixin/alignment.rb +3 -0
- data/lib/rubocop/cop/mixin/allowed_methods.rb +2 -0
- data/lib/rubocop/cop/mixin/annotation_comment.rb +5 -0
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +16 -7
- data/lib/rubocop/cop/mixin/comments_help.rb +48 -0
- data/lib/rubocop/cop/mixin/configurable_naming.rb +2 -2
- data/lib/rubocop/cop/mixin/configurable_numbering.rb +3 -3
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +8 -7
- data/lib/rubocop/cop/mixin/empty_parameter.rb +3 -1
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +12 -1
- data/lib/rubocop/cop/mixin/first_element_line_break.rb +3 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +27 -2
- data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +3 -1
- data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +12 -10
- data/lib/rubocop/cop/mixin/negative_conditional.rb +2 -2
- data/lib/rubocop/cop/mixin/percent_array.rb +14 -3
- data/lib/rubocop/cop/mixin/rescue_node.rb +11 -1
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +4 -3
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +4 -3
- data/lib/rubocop/cop/mixin/statement_modifier.rb +9 -3
- data/lib/rubocop/cop/mixin/surrounding_space.rb +8 -4
- data/lib/rubocop/cop/mixin/trailing_comma.rb +7 -7
- data/lib/rubocop/cop/mixin/visibility_help.rb +4 -16
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/file_name.rb +1 -1
- data/lib/rubocop/cop/offense.rb +16 -2
- data/lib/rubocop/cop/security/eval.rb +1 -0
- data/lib/rubocop/cop/security/json_load.rb +1 -0
- data/lib/rubocop/cop/security/marshal_load.rb +1 -0
- data/lib/rubocop/cop/security/open.rb +1 -0
- data/lib/rubocop/cop/security/yaml_load.rb +1 -0
- data/lib/rubocop/cop/severity.rb +0 -8
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +7 -11
- data/lib/rubocop/cop/style/accessor_grouping.rb +3 -0
- data/lib/rubocop/cop/style/alias.rb +2 -0
- data/lib/rubocop/cop/style/array_coercion.rb +4 -0
- data/lib/rubocop/cop/style/array_join.rb +1 -0
- data/lib/rubocop/cop/style/attr.rb +1 -0
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +2 -0
- data/lib/rubocop/cop/style/case_equality.rb +11 -3
- data/lib/rubocop/cop/style/case_like_if.rb +40 -8
- data/lib/rubocop/cop/style/class_and_module_children.rb +2 -0
- data/lib/rubocop/cop/style/class_check.rb +6 -9
- data/lib/rubocop/cop/style/class_equality_comparison.rb +49 -0
- data/lib/rubocop/cop/style/class_methods_definitions.rb +157 -0
- data/lib/rubocop/cop/style/class_vars.rb +1 -2
- data/lib/rubocop/cop/style/combinable_loops.rb +91 -0
- data/lib/rubocop/cop/style/comment_annotation.rb +6 -0
- data/lib/rubocop/cop/style/commented_keyword.rb +7 -8
- data/lib/rubocop/cop/style/conditional_assignment.rb +49 -60
- data/lib/rubocop/cop/style/date_time.rb +12 -1
- data/lib/rubocop/cop/style/dir.rb +1 -0
- data/lib/rubocop/cop/style/double_negation.rb +1 -0
- data/lib/rubocop/cop/style/empty_block_parameter.rb +9 -10
- data/lib/rubocop/cop/style/empty_lambda_parameter.rb +9 -10
- data/lib/rubocop/cop/style/empty_literal.rb +3 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -3
- data/lib/rubocop/cop/style/even_odd.rb +1 -0
- data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -2
- data/lib/rubocop/cop/style/explicit_block_argument.rb +7 -3
- data/lib/rubocop/cop/style/float_division.rb +2 -0
- data/lib/rubocop/cop/style/for.rb +0 -4
- data/lib/rubocop/cop/style/format_string.rb +1 -4
- data/lib/rubocop/cop/style/format_string_token.rb +1 -1
- data/lib/rubocop/cop/style/guard_clause.rb +1 -0
- data/lib/rubocop/cop/style/hash_as_last_array_item.rb +24 -5
- data/lib/rubocop/cop/style/hash_syntax.rb +6 -5
- data/lib/rubocop/cop/style/hash_transform_keys.rb +16 -9
- data/lib/rubocop/cop/style/hash_transform_values.rb +16 -9
- data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -6
- data/lib/rubocop/cop/style/implicit_runtime_error.rb +1 -0
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +53 -0
- data/lib/rubocop/cop/style/lambda_call.rb +3 -1
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +10 -1
- data/lib/rubocop/cop/style/method_def_parentheses.rb +0 -4
- data/lib/rubocop/cop/style/mixin_usage.rb +8 -27
- data/lib/rubocop/cop/style/multiline_block_chain.rb +2 -2
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +14 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +3 -2
- data/lib/rubocop/cop/style/negated_if.rb +6 -6
- data/lib/rubocop/cop/style/negated_unless.rb +6 -6
- data/lib/rubocop/cop/style/negated_while.rb +7 -15
- data/lib/rubocop/cop/style/nested_modifier.rb +10 -13
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +11 -11
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +16 -16
- data/lib/rubocop/cop/style/next.rb +10 -14
- data/lib/rubocop/cop/style/nil_comparison.rb +13 -11
- data/lib/rubocop/cop/style/non_nil_check.rb +34 -26
- data/lib/rubocop/cop/style/not.rb +20 -26
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +4 -9
- data/lib/rubocop/cop/style/numeric_predicate.rb +5 -14
- data/lib/rubocop/cop/style/one_line_conditional.rb +73 -23
- data/lib/rubocop/cop/style/option_hash.rb +1 -1
- data/lib/rubocop/cop/style/optional_arguments.rb +1 -1
- data/lib/rubocop/cop/style/optional_boolean_parameter.rb +12 -1
- data/lib/rubocop/cop/style/or_assignment.rb +13 -10
- data/lib/rubocop/cop/style/parallel_assignment.rb +14 -14
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +6 -6
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +13 -19
- data/lib/rubocop/cop/style/percent_q_literals.rb +8 -10
- data/lib/rubocop/cop/style/perl_backrefs.rb +8 -10
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +11 -14
- data/lib/rubocop/cop/style/proc.rb +6 -6
- data/lib/rubocop/cop/style/raise_args.rb +12 -24
- data/lib/rubocop/cop/style/random_with_offset.rb +19 -19
- data/lib/rubocop/cop/style/redundant_assignment.rb +8 -18
- data/lib/rubocop/cop/style/redundant_begin.rb +28 -12
- data/lib/rubocop/cop/style/redundant_capital_w.rb +6 -9
- data/lib/rubocop/cop/style/redundant_condition.rb +10 -7
- data/lib/rubocop/cop/style/redundant_conditional.rb +4 -5
- data/lib/rubocop/cop/style/redundant_exception.rb +1 -3
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +3 -12
- data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +9 -8
- data/lib/rubocop/cop/style/redundant_freeze.rb +5 -7
- data/lib/rubocop/cop/style/redundant_interpolation.rb +31 -25
- data/lib/rubocop/cop/style/redundant_parentheses.rb +21 -15
- data/lib/rubocop/cop/style/redundant_percent_q.rb +9 -11
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +44 -36
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +13 -29
- data/lib/rubocop/cop/style/redundant_return.rb +17 -17
- data/lib/rubocop/cop/style/redundant_self.rb +9 -11
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +116 -0
- data/lib/rubocop/cop/style/redundant_sort.rb +12 -29
- data/lib/rubocop/cop/style/redundant_sort_by.rb +5 -9
- data/lib/rubocop/cop/style/regexp_literal.rb +10 -21
- data/lib/rubocop/cop/style/rescue_modifier.rb +29 -9
- data/lib/rubocop/cop/style/rescue_standard_error.rb +20 -16
- data/lib/rubocop/cop/style/return_nil.rb +5 -5
- data/lib/rubocop/cop/style/safe_navigation.rb +18 -12
- data/lib/rubocop/cop/style/sample.rb +12 -14
- data/lib/rubocop/cop/style/self_assignment.rb +26 -22
- data/lib/rubocop/cop/style/semicolon.rb +6 -9
- data/lib/rubocop/cop/style/send.rb +4 -5
- data/lib/rubocop/cop/style/signal_exception.rb +23 -19
- data/lib/rubocop/cop/style/single_argument_dig.rb +1 -0
- data/lib/rubocop/cop/style/single_line_block_params.rb +4 -2
- data/lib/rubocop/cop/style/single_line_methods.rb +17 -16
- data/lib/rubocop/cop/style/slicing_with_range.rb +6 -8
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +66 -0
- data/lib/rubocop/cop/style/special_global_vars.rb +10 -15
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +17 -21
- data/lib/rubocop/cop/style/stderr_puts.rb +5 -6
- data/lib/rubocop/cop/style/string_concatenation.rb +17 -3
- data/lib/rubocop/cop/style/string_hash_keys.rb +6 -7
- data/lib/rubocop/cop/style/string_methods.rb +7 -17
- data/lib/rubocop/cop/style/strip.rb +9 -14
- data/lib/rubocop/cop/style/struct_inheritance.rb +3 -6
- data/lib/rubocop/cop/style/symbol_array.rb +5 -16
- data/lib/rubocop/cop/style/symbol_literal.rb +4 -6
- data/lib/rubocop/cop/style/symbol_proc.rb +14 -18
- data/lib/rubocop/cop/style/ternary_parentheses.rb +22 -22
- data/lib/rubocop/cop/style/trailing_body_on_class.rb +3 -6
- data/lib/rubocop/cop/style/trailing_body_on_method_definition.rb +4 -7
- data/lib/rubocop/cop/style/trailing_body_on_module.rb +3 -6
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +2 -5
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +2 -5
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +11 -9
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +2 -5
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +8 -17
- data/lib/rubocop/cop/style/trivial_accessors.rb +26 -30
- data/lib/rubocop/cop/style/unless_else.rb +5 -8
- data/lib/rubocop/cop/style/unpack_first.rb +5 -8
- data/lib/rubocop/cop/style/variable_interpolation.rb +7 -10
- data/lib/rubocop/cop/style/when_then.rb +4 -6
- data/lib/rubocop/cop/style/while_until_do.rb +6 -16
- data/lib/rubocop/cop/style/while_until_modifier.rb +6 -20
- data/lib/rubocop/cop/style/word_array.rb +5 -23
- data/lib/rubocop/cop/style/yoda_condition.rb +4 -15
- data/lib/rubocop/cop/style/zero_length_predicate.rb +12 -18
- data/lib/rubocop/cop/team.rb +1 -0
- data/lib/rubocop/cop/util.rb +1 -2
- data/lib/rubocop/cop/utils/format_string.rb +3 -5
- data/lib/rubocop/cop/variable_force.rb +2 -0
- data/lib/rubocop/cop/variable_force/branch.rb +0 -4
- data/lib/rubocop/cops_documentation_generator.rb +4 -2
- data/lib/rubocop/core_ext/string.rb +2 -2
- data/lib/rubocop/directive_comment.rb +32 -0
- data/lib/rubocop/ext/regexp_node.rb +62 -0
- data/lib/rubocop/file_finder.rb +1 -0
- data/lib/rubocop/formatter/auto_gen_config_formatter.rb +2 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +12 -5
- data/lib/rubocop/formatter/html_formatter.rb +2 -0
- data/lib/rubocop/formatter/progress_formatter.rb +2 -1
- data/lib/rubocop/formatter/quiet_formatter.rb +1 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +36 -6
- data/lib/rubocop/name_similarity.rb +1 -0
- data/lib/rubocop/options.rb +40 -17
- data/lib/rubocop/remote_config.rb +1 -0
- data/lib/rubocop/result_cache.rb +39 -15
- data/lib/rubocop/rspec/cop_helper.rb +5 -2
- data/lib/rubocop/rspec/expect_offense.rb +14 -9
- data/lib/rubocop/rspec/shared_contexts.rb +12 -0
- data/lib/rubocop/runner.rb +38 -18
- data/lib/rubocop/string_interpreter.rb +3 -0
- data/lib/rubocop/target_finder.rb +28 -26
- data/lib/rubocop/target_ruby.rb +7 -1
- data/lib/rubocop/version.rb +7 -1
- data/lib/rubocop/yaml_duplication_checker.rb +1 -0
- metadata +31 -17
- data/lib/rubocop/cop/mixin/regexp_literal_help.rb +0 -43
- data/lib/rubocop/cop/tokens_util.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d381604ba6395ffc42db74e3f57245307935ec7a56d365e10b8d07207d432a1
|
4
|
+
data.tar.gz: 2b290525226f487d860b5a1201266d1b20e403a05ed8a704c1270b7edaca5e2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8639a2098ab1fb1e50fe6993e0a2d9f305998b7cc0215ab6bdd615506a4f8271de1fe78dbe1592b1ade597b40b79acfe4c5bc0503d8ee72940ff1732fd25a19d
|
7
|
+
data.tar.gz: 11278958d9183ba56561ffc1f6b3cc69ac0b2f7d883cf5192cb31ab3ace1eacce21a23a13f998f4f2917d14574a6c27309be8f48085fc7abf940eab2ba0d1cce
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
**RuboCop** is a Ruby static code analyzer (a.k.a. `linter`) and code formatter. Out of the box it
|
23
23
|
will enforce many of the guidelines outlined in the community [Ruby Style
|
24
24
|
Guide](https://rubystyle.guide). Apart from reporting the problems discovered in your code,
|
25
|
-
RuboCop can also automatically fix many of them you.
|
25
|
+
RuboCop can also automatically fix many of them for you.
|
26
26
|
|
27
27
|
RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various
|
28
28
|
[configuration options](https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml).
|
@@ -49,7 +49,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
49
49
|
might want to use a conservative version lock in your `Gemfile`:
|
50
50
|
|
51
51
|
```rb
|
52
|
-
gem 'rubocop', '~> 0.
|
52
|
+
gem 'rubocop', '~> 0.93.0', require: false
|
53
53
|
```
|
54
54
|
|
55
55
|
## Quickstart
|
data/config/default.yml
CHANGED
@@ -117,6 +117,8 @@ AllCops:
|
|
117
117
|
# CacheRootDirectory is ~ (nil), which it is by default, the root will be
|
118
118
|
# taken from the environment variable `$XDG_CACHE_HOME` if it is set, or if
|
119
119
|
# `$XDG_CACHE_HOME` is not set, it will be `$HOME/.cache/`.
|
120
|
+
# The CacheRootDirectory can be overwritten by passing the `--cache-root` command
|
121
|
+
# line option or by setting `$RUBOCOP_CACHE_ROOT` environment variable.
|
120
122
|
CacheRootDirectory: ~
|
121
123
|
# It is possible for a malicious user to know the location of RuboCop's cache
|
122
124
|
# directory by looking at CacheRootDirectory, and create a symlink in its
|
@@ -309,6 +311,19 @@ Layout/AssignmentIndentation:
|
|
309
311
|
# But it can be overridden by setting this parameter
|
310
312
|
IndentationWidth: ~
|
311
313
|
|
314
|
+
Layout/BeginEndAlignment:
|
315
|
+
Description: 'Align ends corresponding to begins correctly.'
|
316
|
+
Enabled: pending
|
317
|
+
VersionAdded: '0.91'
|
318
|
+
# The value `start_of_line` means that `end` should be aligned the start of the line
|
319
|
+
# where the `begin` keyword is.
|
320
|
+
# The value `begin` means that `end` should be aligned with the `begin` keyword.
|
321
|
+
EnforcedStyleAlignWith: start_of_line
|
322
|
+
SupportedStylesAlignWith:
|
323
|
+
- start_of_line
|
324
|
+
- begin
|
325
|
+
Severity: warning
|
326
|
+
|
312
327
|
Layout/BlockAlignment:
|
313
328
|
Description: 'Align block ends correctly.'
|
314
329
|
Enabled: true
|
@@ -399,7 +414,6 @@ Layout/DefEndAlignment:
|
|
399
414
|
SupportedStylesAlignWith:
|
400
415
|
- start_of_line
|
401
416
|
- def
|
402
|
-
AutoCorrect: false
|
403
417
|
Severity: warning
|
404
418
|
|
405
419
|
Layout/DotPosition:
|
@@ -436,6 +450,14 @@ Layout/EmptyLineAfterMagicComment:
|
|
436
450
|
Enabled: true
|
437
451
|
VersionAdded: '0.49'
|
438
452
|
|
453
|
+
Layout/EmptyLineAfterMultilineCondition:
|
454
|
+
Description: 'Enforces empty line after multiline condition.'
|
455
|
+
# This is disabled, because this style is not very common in practice.
|
456
|
+
Enabled: false
|
457
|
+
VersionAdded: '0.90'
|
458
|
+
Reference:
|
459
|
+
- https://github.com/airbnb/ruby#multiline-if-newline
|
460
|
+
|
439
461
|
Layout/EmptyLineBetweenDefs:
|
440
462
|
Description: 'Use empty lines between defs.'
|
441
463
|
StyleGuide: '#empty-lines-between-methods'
|
@@ -555,7 +577,6 @@ Layout/EndAlignment:
|
|
555
577
|
- keyword
|
556
578
|
- variable
|
557
579
|
- start_of_line
|
558
|
-
AutoCorrect: false
|
559
580
|
Severity: warning
|
560
581
|
|
561
582
|
Layout/EndOfLine:
|
@@ -1374,6 +1395,12 @@ Lint/CircularArgumentReference:
|
|
1374
1395
|
Enabled: true
|
1375
1396
|
VersionAdded: '0.33'
|
1376
1397
|
|
1398
|
+
Lint/ConstantDefinitionInBlock:
|
1399
|
+
Description: 'Do not define constants within a block.'
|
1400
|
+
StyleGuide: '#no-constant-definition-in-block'
|
1401
|
+
Enabled: pending
|
1402
|
+
VersionAdded: '0.91'
|
1403
|
+
|
1377
1404
|
Lint/ConstantResolution:
|
1378
1405
|
Description: 'Check that constants are fully qualified with `::`.'
|
1379
1406
|
Enabled: false
|
@@ -1427,6 +1454,11 @@ Lint/DuplicateMethods:
|
|
1427
1454
|
Enabled: true
|
1428
1455
|
VersionAdded: '0.29'
|
1429
1456
|
|
1457
|
+
Lint/DuplicateRequire:
|
1458
|
+
Description: 'Check for duplicate `require`s and `require_relative`s.'
|
1459
|
+
Enabled: pending
|
1460
|
+
VersionAdded: '0.90'
|
1461
|
+
|
1430
1462
|
Lint/DuplicateRescueException:
|
1431
1463
|
Description: 'Checks that there are no repeated exceptions used in `rescue` expressions.'
|
1432
1464
|
Enabled: pending
|
@@ -1453,13 +1485,18 @@ Lint/EmptyEnsure:
|
|
1453
1485
|
Enabled: true
|
1454
1486
|
VersionAdded: '0.10'
|
1455
1487
|
VersionChanged: '0.48'
|
1456
|
-
AutoCorrect: false
|
1457
1488
|
|
1458
1489
|
Lint/EmptyExpression:
|
1459
1490
|
Description: 'Checks for empty expressions.'
|
1460
1491
|
Enabled: true
|
1461
1492
|
VersionAdded: '0.45'
|
1462
1493
|
|
1494
|
+
Lint/EmptyFile:
|
1495
|
+
Description: 'Enforces that Ruby source files are not empty.'
|
1496
|
+
Enabled: pending
|
1497
|
+
AllowComments: true
|
1498
|
+
VersionAdded: '0.90'
|
1499
|
+
|
1463
1500
|
Lint/EmptyInterpolation:
|
1464
1501
|
Description: 'Checks for empty string interpolation.'
|
1465
1502
|
Enabled: true
|
@@ -1509,6 +1546,13 @@ Lint/FormatParameterMismatch:
|
|
1509
1546
|
Enabled: true
|
1510
1547
|
VersionAdded: '0.33'
|
1511
1548
|
|
1549
|
+
Lint/HashCompareByIdentity:
|
1550
|
+
Description: 'Prefer using `Hash#compare_by_identity` than using `object_id` for keys.'
|
1551
|
+
StyleGuide: '#identity-comparison'
|
1552
|
+
Enabled: pending
|
1553
|
+
Safe: false
|
1554
|
+
VersionAdded: '0.93'
|
1555
|
+
|
1512
1556
|
Lint/HeredocMethodCallPosition:
|
1513
1557
|
Description: >-
|
1514
1558
|
Checks for the ordering of a method call where
|
@@ -1517,6 +1561,12 @@ Lint/HeredocMethodCallPosition:
|
|
1517
1561
|
StyleGuide: '#heredoc-method-calls'
|
1518
1562
|
VersionAdded: '0.68'
|
1519
1563
|
|
1564
|
+
Lint/IdentityComparison:
|
1565
|
+
Description: 'Prefer `equal?` over `==` when comparing `object_id`.'
|
1566
|
+
Enabled: pending
|
1567
|
+
StyleGuide: '#identity-comparison'
|
1568
|
+
VersionAdded: '0.91'
|
1569
|
+
|
1520
1570
|
Lint/ImplicitStringConcatenation:
|
1521
1571
|
Description: >-
|
1522
1572
|
Checks for adjacent string literals on the same line, which
|
@@ -1703,6 +1753,21 @@ Lint/RedundantRequireStatement:
|
|
1703
1753
|
Enabled: true
|
1704
1754
|
VersionAdded: '0.76'
|
1705
1755
|
|
1756
|
+
Lint/RedundantSafeNavigation:
|
1757
|
+
Description: 'Checks for redundant safe navigation calls.'
|
1758
|
+
Enabled: pending
|
1759
|
+
VersionAdded: '0.93'
|
1760
|
+
Safe: false
|
1761
|
+
IgnoredMethods:
|
1762
|
+
- to_c
|
1763
|
+
- to_f
|
1764
|
+
- to_i
|
1765
|
+
- to_r
|
1766
|
+
- rationalize
|
1767
|
+
- public_send
|
1768
|
+
- send
|
1769
|
+
- __send__
|
1770
|
+
|
1706
1771
|
Lint/RedundantSplatExpansion:
|
1707
1772
|
Description: 'Checks for splat unnecessarily being called on literals.'
|
1708
1773
|
Enabled: true
|
@@ -1768,6 +1833,7 @@ Lint/SafeNavigationChain:
|
|
1768
1833
|
- presence
|
1769
1834
|
- try
|
1770
1835
|
- try!
|
1836
|
+
- in?
|
1771
1837
|
|
1772
1838
|
Lint/SafeNavigationConsistency:
|
1773
1839
|
Description: >-
|
@@ -1856,6 +1922,11 @@ Lint/TopLevelReturnWithArgument:
|
|
1856
1922
|
Enabled: 'pending'
|
1857
1923
|
VersionAdded: '0.89'
|
1858
1924
|
|
1925
|
+
Lint/TrailingCommaInAttributeDeclaration:
|
1926
|
+
Description: 'This cop checks for trailing commas in attribute declarations.'
|
1927
|
+
Enabled: pending
|
1928
|
+
VersionAdded: '0.90'
|
1929
|
+
|
1859
1930
|
Lint/UnderscorePrefixedVariableName:
|
1860
1931
|
Description: 'Do not use prefix `_` for a variable that is used.'
|
1861
1932
|
Enabled: true
|
@@ -1931,6 +2002,13 @@ Lint/UselessElseWithoutRescue:
|
|
1931
2002
|
Enabled: true
|
1932
2003
|
VersionAdded: '0.17'
|
1933
2004
|
|
2005
|
+
Lint/UselessMethodDefinition:
|
2006
|
+
Description: 'Checks for useless method definitions.'
|
2007
|
+
Enabled: pending
|
2008
|
+
VersionAdded: '0.90'
|
2009
|
+
Safe: false
|
2010
|
+
AllowComments: true
|
2011
|
+
|
1934
2012
|
Lint/UselessSetterCall:
|
1935
2013
|
Description: 'Checks for useless setter call to a local variable.'
|
1936
2014
|
Enabled: true
|
@@ -1938,6 +2016,12 @@ Lint/UselessSetterCall:
|
|
1938
2016
|
VersionChanged: '0.80'
|
1939
2017
|
Safe: false
|
1940
2018
|
|
2019
|
+
Lint/UselessTimes:
|
2020
|
+
Description: 'Checks for useless `Integer#times` calls.'
|
2021
|
+
Enabled: pending
|
2022
|
+
VersionAdded: '0.91'
|
2023
|
+
Safe: false
|
2024
|
+
|
1941
2025
|
Lint/Void:
|
1942
2026
|
Description: 'Possible use of operator/literal/variable in void context.'
|
1943
2027
|
Enabled: true
|
@@ -2401,7 +2485,7 @@ Style/ArrayCoercion:
|
|
2401
2485
|
with a variable you want to treat as an Array, but you're not certain it's an array.
|
2402
2486
|
StyleGuide: '#array-coercion'
|
2403
2487
|
Safe: false
|
2404
|
-
Enabled:
|
2488
|
+
Enabled: false
|
2405
2489
|
VersionAdded: '0.88'
|
2406
2490
|
|
2407
2491
|
Style/ArrayJoin:
|
@@ -2591,6 +2675,7 @@ Style/CaseLikeIf:
|
|
2591
2675
|
Description: 'This cop identifies places where `if-elsif` constructions can be replaced with `case-when`.'
|
2592
2676
|
StyleGuide: '#case-vs-if-else'
|
2593
2677
|
Enabled: 'pending'
|
2678
|
+
Safe: false
|
2594
2679
|
VersionAdded: '0.88'
|
2595
2680
|
|
2596
2681
|
Style/CharacterLiteral:
|
@@ -2608,7 +2693,6 @@ Style/ClassAndModuleChildren:
|
|
2608
2693
|
# have the knowledge to perform either operation safely and thus requires
|
2609
2694
|
# manual oversight.
|
2610
2695
|
SafeAutoCorrect: false
|
2611
|
-
AutoCorrect: false
|
2612
2696
|
Enabled: true
|
2613
2697
|
VersionAdded: '0.19'
|
2614
2698
|
#
|
@@ -2640,6 +2724,16 @@ Style/ClassCheck:
|
|
2640
2724
|
- is_a?
|
2641
2725
|
- kind_of?
|
2642
2726
|
|
2727
|
+
Style/ClassEqualityComparison:
|
2728
|
+
Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.'
|
2729
|
+
StyleGuide: '#instance-of-vs-class-comparison'
|
2730
|
+
Enabled: pending
|
2731
|
+
VersionAdded: '0.93'
|
2732
|
+
IgnoredMethods:
|
2733
|
+
- ==
|
2734
|
+
- equal?
|
2735
|
+
- eql?
|
2736
|
+
|
2643
2737
|
Style/ClassMethods:
|
2644
2738
|
Description: 'Use self when defining module/class methods.'
|
2645
2739
|
StyleGuide: '#def-self-class-methods'
|
@@ -2647,6 +2741,16 @@ Style/ClassMethods:
|
|
2647
2741
|
VersionAdded: '0.9'
|
2648
2742
|
VersionChanged: '0.20'
|
2649
2743
|
|
2744
|
+
Style/ClassMethodsDefinitions:
|
2745
|
+
Description: 'Enforces using `def self.method_name` or `class << self` to define class methods.'
|
2746
|
+
StyleGuide: '#def-self-class-methods'
|
2747
|
+
Enabled: false
|
2748
|
+
VersionAdded: '0.89'
|
2749
|
+
EnforcedStyle: def_self
|
2750
|
+
SupportedStyles:
|
2751
|
+
- def_self
|
2752
|
+
- self_class
|
2753
|
+
|
2650
2754
|
Style/ClassVars:
|
2651
2755
|
Description: 'Avoid the use of class variables.'
|
2652
2756
|
StyleGuide: '#no-class-vars'
|
@@ -2687,6 +2791,14 @@ Style/ColonMethodDefinition:
|
|
2687
2791
|
Enabled: true
|
2688
2792
|
VersionAdded: '0.52'
|
2689
2793
|
|
2794
|
+
Style/CombinableLoops:
|
2795
|
+
Description: >-
|
2796
|
+
Checks for places where multiple consecutive loops over the same data
|
2797
|
+
can be combined into a single loop.
|
2798
|
+
Enabled: pending
|
2799
|
+
Safe: false
|
2800
|
+
VersionAdded: '0.90'
|
2801
|
+
|
2690
2802
|
Style/CommandLiteral:
|
2691
2803
|
Description: 'Use `` or %x around command literals.'
|
2692
2804
|
StyleGuide: '#percent-x'
|
@@ -2783,7 +2895,8 @@ Style/DateTime:
|
|
2783
2895
|
StyleGuide: '#date--time'
|
2784
2896
|
Enabled: false
|
2785
2897
|
VersionAdded: '0.51'
|
2786
|
-
VersionChanged: '0.
|
2898
|
+
VersionChanged: '0.92'
|
2899
|
+
SafeAutoCorrect: false
|
2787
2900
|
AllowCoercion: false
|
2788
2901
|
|
2789
2902
|
Style/DefWithParentheses:
|
@@ -3021,13 +3134,14 @@ Style/FrozenStringLiteralComment:
|
|
3021
3134
|
# `never` will enforce that the frozen string literal comment does not
|
3022
3135
|
# exist in a file.
|
3023
3136
|
- never
|
3024
|
-
|
3137
|
+
SafeAutoCorrect: false
|
3025
3138
|
|
3026
3139
|
Style/GlobalStdStream:
|
3027
3140
|
Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
|
3028
3141
|
StyleGuide: '#global-stdout'
|
3029
3142
|
Enabled: pending
|
3030
3143
|
VersionAdded: '0.89'
|
3144
|
+
SafeAutoCorrect: false
|
3031
3145
|
|
3032
3146
|
Style/GlobalVars:
|
3033
3147
|
Description: 'Do not introduce global variables.'
|
@@ -3101,15 +3215,17 @@ Style/HashSyntax:
|
|
3101
3215
|
PreferHashRocketsForNonAlnumEndingSymbols: false
|
3102
3216
|
|
3103
3217
|
Style/HashTransformKeys:
|
3104
|
-
Description: 'Prefer `transform_keys` over `each_with_object`
|
3218
|
+
Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.'
|
3105
3219
|
Enabled: 'pending'
|
3106
3220
|
VersionAdded: '0.80'
|
3221
|
+
VersionChanged: '0.90'
|
3107
3222
|
Safe: false
|
3108
3223
|
|
3109
3224
|
Style/HashTransformValues:
|
3110
|
-
Description: 'Prefer `transform_values` over `each_with_object`
|
3225
|
+
Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.'
|
3111
3226
|
Enabled: 'pending'
|
3112
3227
|
VersionAdded: '0.80'
|
3228
|
+
VersionChanged: '0.90'
|
3113
3229
|
Safe: false
|
3114
3230
|
|
3115
3231
|
Style/IdenticalConditionalBranches:
|
@@ -3200,11 +3316,22 @@ Style/IpAddresses:
|
|
3200
3316
|
Description: "Don't include literal IP addresses in code."
|
3201
3317
|
Enabled: false
|
3202
3318
|
VersionAdded: '0.58'
|
3203
|
-
VersionChanged: '0.
|
3319
|
+
VersionChanged: '0.91'
|
3204
3320
|
# Allow addresses to be permitted
|
3205
3321
|
AllowedAddresses:
|
3206
3322
|
- "::"
|
3207
3323
|
# :: is a valid IPv6 address, but could potentially be legitimately in code
|
3324
|
+
Exclude:
|
3325
|
+
- '**/*.gemfile'
|
3326
|
+
- '**/Gemfile'
|
3327
|
+
- '**/gems.rb'
|
3328
|
+
- '**/*.gemspec'
|
3329
|
+
|
3330
|
+
Style/KeywordParametersOrder:
|
3331
|
+
Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
|
3332
|
+
StyleGuide: '#keyword-parameters-order'
|
3333
|
+
Enabled: pending
|
3334
|
+
VersionAdded: '0.90'
|
3208
3335
|
|
3209
3336
|
Style/Lambda:
|
3210
3337
|
Description: 'Use the new lambda literal syntax for single-line blocks.'
|
@@ -3579,7 +3706,6 @@ Style/NumericPredicate:
|
|
3579
3706
|
# object. Switching these methods has to be done with knowledge of the types
|
3580
3707
|
# of the variables which rubocop doesn't have.
|
3581
3708
|
SafeAutoCorrect: false
|
3582
|
-
AutoCorrect: false
|
3583
3709
|
Enabled: true
|
3584
3710
|
VersionAdded: '0.42'
|
3585
3711
|
VersionChanged: '0.59'
|
@@ -3595,12 +3721,13 @@ Style/NumericPredicate:
|
|
3595
3721
|
|
3596
3722
|
Style/OneLineConditional:
|
3597
3723
|
Description: >-
|
3598
|
-
Favor the ternary operator(?:) over
|
3599
|
-
if/then/else/end constructs.
|
3724
|
+
Favor the ternary operator (?:) or multi-line constructs over
|
3725
|
+
single-line if/then/else/end constructs.
|
3600
3726
|
StyleGuide: '#ternary-operator'
|
3601
3727
|
Enabled: true
|
3728
|
+
AlwaysCorrectToMultiline: false
|
3602
3729
|
VersionAdded: '0.9'
|
3603
|
-
VersionChanged: '0.
|
3730
|
+
VersionChanged: '0.90'
|
3604
3731
|
|
3605
3732
|
Style/OptionHash:
|
3606
3733
|
Description: "Don't use option hashes when you can use keyword arguments."
|
@@ -3631,6 +3758,8 @@ Style/OptionalBooleanParameter:
|
|
3631
3758
|
Enabled: pending
|
3632
3759
|
Safe: false
|
3633
3760
|
VersionAdded: '0.89'
|
3761
|
+
AllowedMethods:
|
3762
|
+
- respond_to_missing?
|
3634
3763
|
|
3635
3764
|
Style/OrAssignment:
|
3636
3765
|
Description: 'Recommend usage of double pipe equals (||=) where applicable.'
|
@@ -3831,6 +3960,12 @@ Style/RedundantSelf:
|
|
3831
3960
|
VersionAdded: '0.10'
|
3832
3961
|
VersionChanged: '0.13'
|
3833
3962
|
|
3963
|
+
Style/RedundantSelfAssignment:
|
3964
|
+
Description: 'Checks for places where redundant assignments are made for in place modification methods.'
|
3965
|
+
Enabled: pending
|
3966
|
+
Safe: false
|
3967
|
+
VersionAdded: '0.90'
|
3968
|
+
|
3834
3969
|
Style/RedundantSort:
|
3835
3970
|
Description: >-
|
3836
3971
|
Use `min` instead of `sort.first`,
|
@@ -3893,6 +4028,8 @@ Style/SafeNavigation:
|
|
3893
4028
|
This cop transforms usages of a method call safeguarded by
|
3894
4029
|
a check for the existence of the object to
|
3895
4030
|
safe navigation (`&.`).
|
4031
|
+
Auto-correction is unsafe as it assumes the object will
|
4032
|
+
be `nil` or truthy, but never `false`.
|
3896
4033
|
Enabled: true
|
3897
4034
|
VersionAdded: '0.43'
|
3898
4035
|
VersionChanged: '0.77'
|
@@ -3905,6 +4042,7 @@ Style/SafeNavigation:
|
|
3905
4042
|
- presence
|
3906
4043
|
- try
|
3907
4044
|
- try!
|
4045
|
+
SafeAutoCorrect: false
|
3908
4046
|
|
3909
4047
|
Style/Sample:
|
3910
4048
|
Description: >-
|
@@ -3983,6 +4121,14 @@ Style/SlicingWithRange:
|
|
3983
4121
|
VersionAdded: '0.83'
|
3984
4122
|
Safe: false
|
3985
4123
|
|
4124
|
+
Style/SoleNestedConditional:
|
4125
|
+
Description: >-
|
4126
|
+
Finds sole nested conditional nodes
|
4127
|
+
which can be merged into outer conditional node.
|
4128
|
+
Enabled: pending
|
4129
|
+
VersionAdded: '0.89'
|
4130
|
+
AllowModifier: false
|
4131
|
+
|
3986
4132
|
Style/SpecialGlobalVars:
|
3987
4133
|
Description: 'Avoid Perl-style global variables.'
|
3988
4134
|
StyleGuide: '#no-cryptic-perlisms'
|
data/lib/rubocop.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'English'
|
4
|
+
before_us = $LOADED_FEATURES.dup
|
3
5
|
require 'rainbow'
|
4
6
|
|
5
|
-
require 'English'
|
6
7
|
require 'set'
|
7
8
|
require 'forwardable'
|
8
9
|
require 'regexp_parser'
|
9
10
|
require 'unicode/display_width/no_string_ext'
|
10
|
-
require 'rubocop-ast'
|
11
|
-
require_relative 'rubocop/ast_aliases'
|
12
11
|
|
12
|
+
# we have to require RuboCop's version, before rubocop-ast's
|
13
13
|
require_relative 'rubocop/version'
|
14
|
+
require 'rubocop-ast'
|
15
|
+
|
16
|
+
require_relative 'rubocop/ast_aliases'
|
17
|
+
require_relative 'rubocop/ext/regexp_node'
|
14
18
|
|
15
19
|
require_relative 'rubocop/core_ext/string'
|
16
20
|
require_relative 'rubocop/ext/processed_source'
|
@@ -23,7 +27,6 @@ require_relative 'rubocop/string_interpreter'
|
|
23
27
|
require_relative 'rubocop/error'
|
24
28
|
require_relative 'rubocop/warning'
|
25
29
|
|
26
|
-
require_relative 'rubocop/cop/tokens_util'
|
27
30
|
require_relative 'rubocop/cop/util'
|
28
31
|
require_relative 'rubocop/cop/offense'
|
29
32
|
require_relative 'rubocop/cop/message_annotator'
|
@@ -34,6 +37,7 @@ require_relative 'rubocop/cop/registry'
|
|
34
37
|
require_relative 'rubocop/cop/base'
|
35
38
|
require_relative 'rubocop/cop/cop'
|
36
39
|
require_relative 'rubocop/cop/commissioner'
|
40
|
+
require_relative 'rubocop/cop/documentation'
|
37
41
|
require_relative 'rubocop/cop/corrector'
|
38
42
|
require_relative 'rubocop/cop/force'
|
39
43
|
require_relative 'rubocop/cop/severity'
|
@@ -101,7 +105,6 @@ require_relative 'rubocop/cop/mixin/percent_literal'
|
|
101
105
|
require_relative 'rubocop/cop/mixin/preceding_following_alignment'
|
102
106
|
require_relative 'rubocop/cop/mixin/preferred_delimiters'
|
103
107
|
require_relative 'rubocop/cop/mixin/rational_literal'
|
104
|
-
require_relative 'rubocop/cop/mixin/regexp_literal_help'
|
105
108
|
require_relative 'rubocop/cop/mixin/rescue_node'
|
106
109
|
require_relative 'rubocop/cop/mixin/safe_assignment'
|
107
110
|
require_relative 'rubocop/cop/mixin/space_after_punctuation'
|
@@ -116,6 +119,7 @@ require_relative 'rubocop/cop/mixin/trailing_comma'
|
|
116
119
|
require_relative 'rubocop/cop/mixin/uncommunicative_name'
|
117
120
|
require_relative 'rubocop/cop/mixin/unused_argument'
|
118
121
|
require_relative 'rubocop/cop/mixin/visibility_help'
|
122
|
+
require_relative 'rubocop/cop/mixin/comments_help' # relies on visibility_help
|
119
123
|
|
120
124
|
require_relative 'rubocop/cop/utils/format_string'
|
121
125
|
|
@@ -151,6 +155,7 @@ require_relative 'rubocop/cop/layout/access_modifier_indentation'
|
|
151
155
|
require_relative 'rubocop/cop/layout/argument_alignment'
|
152
156
|
require_relative 'rubocop/cop/layout/array_alignment'
|
153
157
|
require_relative 'rubocop/cop/layout/assignment_indentation'
|
158
|
+
require_relative 'rubocop/cop/layout/begin_end_alignment'
|
154
159
|
require_relative 'rubocop/cop/layout/block_alignment'
|
155
160
|
require_relative 'rubocop/cop/layout/block_end_newline'
|
156
161
|
require_relative 'rubocop/cop/layout/case_indentation'
|
@@ -165,6 +170,7 @@ require_relative 'rubocop/cop/layout/else_alignment'
|
|
165
170
|
require_relative 'rubocop/cop/layout/empty_comment'
|
166
171
|
require_relative 'rubocop/cop/layout/empty_line_after_guard_clause'
|
167
172
|
require_relative 'rubocop/cop/layout/empty_line_after_magic_comment'
|
173
|
+
require_relative 'rubocop/cop/layout/empty_line_after_multiline_condition'
|
168
174
|
require_relative 'rubocop/cop/layout/empty_line_between_defs'
|
169
175
|
require_relative 'rubocop/cop/layout/empty_lines_around_access_modifier'
|
170
176
|
require_relative 'rubocop/cop/layout/empty_lines_around_arguments'
|
@@ -246,6 +252,7 @@ require_relative 'rubocop/cop/lint/big_decimal_new'
|
|
246
252
|
require_relative 'rubocop/cop/lint/binary_operator_with_identical_operands'
|
247
253
|
require_relative 'rubocop/cop/lint/boolean_symbol'
|
248
254
|
require_relative 'rubocop/cop/lint/circular_argument_reference'
|
255
|
+
require_relative 'rubocop/cop/lint/constant_definition_in_block'
|
249
256
|
require_relative 'rubocop/cop/lint/constant_resolution'
|
250
257
|
require_relative 'rubocop/cop/lint/debugger'
|
251
258
|
require_relative 'rubocop/cop/lint/deprecated_class_methods'
|
@@ -255,12 +262,14 @@ require_relative 'rubocop/cop/lint/duplicate_case_condition'
|
|
255
262
|
require_relative 'rubocop/cop/lint/duplicate_elsif_condition'
|
256
263
|
require_relative 'rubocop/cop/lint/duplicate_hash_key'
|
257
264
|
require_relative 'rubocop/cop/lint/duplicate_methods'
|
265
|
+
require_relative 'rubocop/cop/lint/duplicate_require'
|
258
266
|
require_relative 'rubocop/cop/lint/duplicate_rescue_exception'
|
259
267
|
require_relative 'rubocop/cop/lint/each_with_object_argument'
|
260
268
|
require_relative 'rubocop/cop/lint/else_layout'
|
261
269
|
require_relative 'rubocop/cop/lint/empty_conditional_body'
|
262
270
|
require_relative 'rubocop/cop/lint/empty_ensure'
|
263
271
|
require_relative 'rubocop/cop/lint/empty_expression'
|
272
|
+
require_relative 'rubocop/cop/lint/empty_file'
|
264
273
|
require_relative 'rubocop/cop/lint/empty_interpolation'
|
265
274
|
require_relative 'rubocop/cop/lint/empty_when'
|
266
275
|
require_relative 'rubocop/cop/lint/ensure_return'
|
@@ -269,7 +278,9 @@ require_relative 'rubocop/cop/lint/flip_flop'
|
|
269
278
|
require_relative 'rubocop/cop/lint/float_comparison'
|
270
279
|
require_relative 'rubocop/cop/lint/float_out_of_range'
|
271
280
|
require_relative 'rubocop/cop/lint/format_parameter_mismatch'
|
281
|
+
require_relative 'rubocop/cop/lint/hash_compare_by_identity'
|
272
282
|
require_relative 'rubocop/cop/lint/heredoc_method_call_position'
|
283
|
+
require_relative 'rubocop/cop/lint/identity_comparison'
|
273
284
|
require_relative 'rubocop/cop/lint/implicit_string_concatenation'
|
274
285
|
require_relative 'rubocop/cop/lint/inherit_exception'
|
275
286
|
require_relative 'rubocop/cop/lint/ineffective_access_modifier'
|
@@ -297,6 +308,7 @@ require_relative 'rubocop/cop/lint/rand_one'
|
|
297
308
|
require_relative 'rubocop/cop/lint/redundant_cop_disable_directive'
|
298
309
|
require_relative 'rubocop/cop/lint/redundant_cop_enable_directive'
|
299
310
|
require_relative 'rubocop/cop/lint/redundant_require_statement'
|
311
|
+
require_relative 'rubocop/cop/lint/redundant_safe_navigation'
|
300
312
|
require_relative 'rubocop/cop/lint/redundant_splat_expansion'
|
301
313
|
require_relative 'rubocop/cop/lint/redundant_string_coercion'
|
302
314
|
require_relative 'rubocop/cop/lint/redundant_with_index'
|
@@ -320,6 +332,7 @@ require_relative 'rubocop/cop/lint/suppressed_exception'
|
|
320
332
|
require_relative 'rubocop/cop/lint/syntax'
|
321
333
|
require_relative 'rubocop/cop/lint/to_json'
|
322
334
|
require_relative 'rubocop/cop/lint/top_level_return_with_argument'
|
335
|
+
require_relative 'rubocop/cop/lint/trailing_comma_in_attribute_declaration'
|
323
336
|
require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
|
324
337
|
require_relative 'rubocop/cop/lint/unified_integer'
|
325
338
|
require_relative 'rubocop/cop/lint/unreachable_code'
|
@@ -331,7 +344,9 @@ require_relative 'rubocop/cop/lint/uri_regexp'
|
|
331
344
|
require_relative 'rubocop/cop/lint/useless_access_modifier'
|
332
345
|
require_relative 'rubocop/cop/lint/useless_assignment'
|
333
346
|
require_relative 'rubocop/cop/lint/useless_else_without_rescue'
|
347
|
+
require_relative 'rubocop/cop/lint/useless_method_definition'
|
334
348
|
require_relative 'rubocop/cop/lint/useless_setter_call'
|
349
|
+
require_relative 'rubocop/cop/lint/useless_times'
|
335
350
|
require_relative 'rubocop/cop/lint/void'
|
336
351
|
|
337
352
|
require_relative 'rubocop/cop/metrics/utils/iterating_block'
|
@@ -384,11 +399,14 @@ require_relative 'rubocop/cop/style/case_like_if'
|
|
384
399
|
require_relative 'rubocop/cop/style/character_literal'
|
385
400
|
require_relative 'rubocop/cop/style/class_and_module_children'
|
386
401
|
require_relative 'rubocop/cop/style/class_check'
|
402
|
+
require_relative 'rubocop/cop/style/class_equality_comparison'
|
387
403
|
require_relative 'rubocop/cop/style/class_methods'
|
404
|
+
require_relative 'rubocop/cop/style/class_methods_definitions'
|
388
405
|
require_relative 'rubocop/cop/style/class_vars'
|
389
406
|
require_relative 'rubocop/cop/style/collection_methods'
|
390
407
|
require_relative 'rubocop/cop/style/colon_method_call'
|
391
408
|
require_relative 'rubocop/cop/style/colon_method_definition'
|
409
|
+
require_relative 'rubocop/cop/style/combinable_loops'
|
392
410
|
require_relative 'rubocop/cop/style/command_literal'
|
393
411
|
require_relative 'rubocop/cop/style/comment_annotation'
|
394
412
|
require_relative 'rubocop/cop/style/commented_keyword'
|
@@ -442,6 +460,7 @@ require_relative 'rubocop/cop/style/infinite_loop'
|
|
442
460
|
require_relative 'rubocop/cop/style/inverse_methods'
|
443
461
|
require_relative 'rubocop/cop/style/inline_comment'
|
444
462
|
require_relative 'rubocop/cop/style/ip_addresses'
|
463
|
+
require_relative 'rubocop/cop/style/keyword_parameters_order'
|
445
464
|
require_relative 'rubocop/cop/style/lambda'
|
446
465
|
require_relative 'rubocop/cop/style/lambda_call'
|
447
466
|
require_relative 'rubocop/cop/style/line_end_concatenation'
|
@@ -450,6 +469,8 @@ require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
|
|
450
469
|
require_relative 'rubocop/cop/style/redundant_assignment'
|
451
470
|
require_relative 'rubocop/cop/style/redundant_fetch_block'
|
452
471
|
require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
|
472
|
+
require_relative 'rubocop/cop/style/redundant_self_assignment'
|
473
|
+
require_relative 'rubocop/cop/style/sole_nested_conditional'
|
453
474
|
require_relative 'rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses'
|
454
475
|
require_relative 'rubocop/cop/style/method_call_with_args_parentheses/require_parentheses'
|
455
476
|
require_relative 'rubocop/cop/style/method_called_on_do_end_block'
|
@@ -597,6 +618,7 @@ require_relative 'rubocop/config_obsoletion'
|
|
597
618
|
require_relative 'rubocop/config_store'
|
598
619
|
require_relative 'rubocop/config_validator'
|
599
620
|
require_relative 'rubocop/target_finder'
|
621
|
+
require_relative 'rubocop/directive_comment'
|
600
622
|
require_relative 'rubocop/comment_config'
|
601
623
|
require_relative 'rubocop/magic_comment'
|
602
624
|
require_relative 'rubocop/result_cache'
|
@@ -610,7 +632,13 @@ require_relative 'rubocop/cli/command/execute_runner'
|
|
610
632
|
require_relative 'rubocop/cli/command/init_dotfile'
|
611
633
|
require_relative 'rubocop/cli/command/show_cops'
|
612
634
|
require_relative 'rubocop/cli/command/version'
|
635
|
+
require_relative 'rubocop/config_regeneration'
|
613
636
|
require_relative 'rubocop/options'
|
614
637
|
require_relative 'rubocop/remote_config'
|
615
638
|
require_relative 'rubocop/target_ruby'
|
616
639
|
require_relative 'rubocop/yaml_duplication_checker'
|
640
|
+
|
641
|
+
unless File.exist?("#{__dir__}/../rubocop.gemspec") # Check if we are a gem
|
642
|
+
RuboCop::ResultCache.rubocop_required_features = $LOADED_FEATURES - before_us
|
643
|
+
end
|
644
|
+
RuboCop::AST.rubocop_loaded if RuboCop::AST.respond_to?(:rubocop_loaded)
|