rubocop 0.68.1 → 0.69.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 +3 -3
- data/config/default.yml +25 -9
- data/lib/rubocop.rb +1 -0
- data/lib/rubocop/ast/node.rb +6 -2
- data/lib/rubocop/ast/node/array_node.rb +2 -2
- data/lib/rubocop/ast/node/block_node.rb +2 -2
- data/lib/rubocop/ast/node/for_node.rb +1 -1
- data/lib/rubocop/ast/node/hash_node.rb +1 -1
- data/lib/rubocop/ast/node/if_node.rb +1 -1
- data/lib/rubocop/ast/node/keyword_splat_node.rb +1 -1
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +3 -3
- data/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb +2 -2
- data/lib/rubocop/ast/node/mixin/parameterized_node.rb +1 -1
- data/lib/rubocop/ast/node/mixin/predicate_operator_node.rb +4 -4
- data/lib/rubocop/ast/node/pair_node.rb +4 -4
- data/lib/rubocop/ast/node/until_node.rb +1 -1
- data/lib/rubocop/ast/node/when_node.rb +1 -1
- data/lib/rubocop/ast/node/while_node.rb +1 -1
- data/lib/rubocop/cli.rb +6 -6
- data/lib/rubocop/comment_config.rb +6 -6
- data/lib/rubocop/config.rb +8 -6
- data/lib/rubocop/config_loader.rb +3 -3
- data/lib/rubocop/cop/badge.rb +1 -1
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -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/correctors/alignment_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +5 -5
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +1 -1
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +1 -1
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +0 -1
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +7 -7
- data/lib/rubocop/cop/generator.rb +6 -6
- data/lib/rubocop/cop/generator/configuration_injector.rb +5 -5
- data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +1 -1
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/align_arguments.rb +2 -2
- data/lib/rubocop/cop/layout/align_array.rb +1 -1
- data/lib/rubocop/cop/layout/align_hash.rb +3 -3
- data/lib/rubocop/cop/layout/align_parameters.rb +2 -2
- data/lib/rubocop/cop/layout/block_alignment.rb +4 -4
- data/lib/rubocop/cop/layout/block_end_newline.rb +0 -1
- data/lib/rubocop/cop/layout/case_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/class_structure.rb +2 -2
- data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +4 -4
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +3 -3
- data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/condition_position.rb +1 -1
- data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/else_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/empty_comment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +5 -5
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -2
- data/lib/rubocop/cop/layout/empty_lines.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2 -2
- data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +1 -1
- data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
- data/lib/rubocop/cop/layout/extra_spacing.rb +5 -5
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +3 -10
- data/lib/rubocop/cop/layout/indent_assignment.rb +1 -1
- data/lib/rubocop/cop/layout/indent_first_argument.rb +1 -1
- data/lib/rubocop/cop/layout/indent_first_array_element.rb +1 -1
- data/lib/rubocop/cop/layout/indent_first_hash_element.rb +1 -1
- data/lib/rubocop/cop/layout/indent_first_parameter.rb +2 -2
- data/lib/rubocop/cop/layout/indent_heredoc.rb +9 -47
- data/lib/rubocop/cop/layout/indentation_consistency.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +2 -2
- data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/leading_blank_lines.rb +1 -1
- data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +4 -4
- data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +2 -2
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +2 -2
- data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +4 -4
- data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +4 -4
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +4 -4
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/space_after_colon.rb +1 -1
- data/lib/rubocop/cop/layout/space_after_method_name.rb +2 -2
- data/lib/rubocop/cop/layout/space_after_not.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +9 -9
- data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -2
- data/lib/rubocop/cop/layout/space_before_comment.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -1
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +4 -3
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_parens.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +2 -2
- data/lib/rubocop/cop/layout/tab.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_blank_lines.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +1 -1
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +2 -2
- data/lib/rubocop/cop/lint/big_decimal_new.rb +1 -1
- data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +1 -1
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
- data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -1
- data/lib/rubocop/cop/lint/duplicated_key.rb +1 -1
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
- data/lib/rubocop/cop/lint/else_layout.rb +1 -1
- data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
- data/lib/rubocop/cop/lint/empty_expression.rb +1 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/empty_when.rb +1 -1
- data/lib/rubocop/cop/lint/end_in_method.rb +1 -1
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
- data/lib/rubocop/cop/lint/flip_flop.rb +1 -1
- data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +7 -8
- data/lib/rubocop/cop/lint/handle_exceptions.rb +1 -1
- data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +5 -6
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +5 -5
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +4 -4
- data/lib/rubocop/cop/lint/inherit_exception.rb +22 -1
- data/lib/rubocop/cop/lint/interpolation_check.rb +1 -1
- data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/loop.rb +1 -1
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +2 -2
- data/lib/rubocop/cop/lint/multiple_compare.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/nested_percent_literal.rb +1 -1
- 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 +16 -1
- data/lib/rubocop/cop/lint/ordered_magic_comments.rb +1 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +2 -2
- data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
- data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
- data/lib/rubocop/cop/lint/rand_one.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_with_index.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
- data/lib/rubocop/cop/lint/regexp_as_condition.rb +1 -1
- data/lib/rubocop/cop/lint/require_parentheses.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
- data/lib/rubocop/cop/lint/return_in_void_context.rb +2 -2
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -4
- data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +2 -2
- data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
- data/lib/rubocop/cop/lint/script_permission.rb +2 -2
- data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -1
- data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -1
- data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +2 -2
- data/lib/rubocop/cop/lint/to_json.rb +1 -1
- data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +1 -1
- data/lib/rubocop/cop/lint/unified_integer.rb +3 -1
- data/lib/rubocop/cop/lint/unneeded_cop_disable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/unneeded_cop_enable_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 -7
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/unused_method_argument.rb +1 -1
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +1 -1
- data/lib/rubocop/cop/lint/uri_regexp.rb +1 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -1
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -1
- data/lib/rubocop/cop/lint/useless_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +1 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +6 -6
- data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
- data/lib/rubocop/cop/metrics/block_length.rb +2 -2
- data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +1 -1
- data/lib/rubocop/cop/metrics/line_length.rb +1 -1
- data/lib/rubocop/cop/metrics/method_length.rb +1 -1
- data/lib/rubocop/cop/metrics/parameter_lists.rb +1 -1
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/check_assignment.rb +1 -1
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +3 -3
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +3 -4
- data/lib/rubocop/cop/mixin/min_body_length.rb +1 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +4 -4
- data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
- data/lib/rubocop/cop/mixin/percent_array.rb +2 -2
- data/lib/rubocop/cop/mixin/range_help.rb +1 -1
- data/lib/rubocop/cop/mixin/rescue_node.rb +1 -2
- data/lib/rubocop/cop/mixin/safe_mode.rb +1 -1
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/surrounding_space.rb +3 -3
- data/lib/rubocop/cop/mixin/too_many_lines.rb +2 -2
- data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
- data/lib/rubocop/cop/mixin/uncommunicative_name.rb +4 -4
- data/lib/rubocop/cop/naming/accessor_method_name.rb +2 -2
- data/lib/rubocop/cop/naming/ascii_identifiers.rb +1 -1
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +4 -4
- data/lib/rubocop/cop/naming/file_name.rb +3 -3
- data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +1 -1
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -2
- data/lib/rubocop/cop/naming/method_name.rb +1 -1
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/variable_number.rb +1 -1
- data/lib/rubocop/cop/rails/action_filter.rb +1 -1
- data/lib/rubocop/cop/rails/active_record_aliases.rb +1 -1
- data/lib/rubocop/cop/rails/active_record_override.rb +1 -1
- data/lib/rubocop/cop/rails/active_support_aliases.rb +1 -1
- data/lib/rubocop/cop/rails/application_job.rb +3 -3
- data/lib/rubocop/cop/rails/application_record.rb +3 -3
- data/lib/rubocop/cop/rails/assert_not.rb +1 -1
- data/lib/rubocop/cop/rails/belongs_to.rb +2 -2
- data/lib/rubocop/cop/rails/blank.rb +3 -3
- data/lib/rubocop/cop/rails/bulk_change_table.rb +4 -4
- data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +1 -1
- data/lib/rubocop/cop/rails/date.rb +11 -6
- data/lib/rubocop/cop/rails/delegate.rb +1 -1
- data/lib/rubocop/cop/rails/delegate_allow_blank.rb +1 -1
- data/lib/rubocop/cop/rails/dynamic_find_by.rb +1 -1
- data/lib/rubocop/cop/rails/enum_uniqueness.rb +1 -1
- data/lib/rubocop/cop/rails/environment_comparison.rb +2 -2
- data/lib/rubocop/cop/rails/exit.rb +1 -1
- data/lib/rubocop/cop/rails/file_path.rb +2 -2
- data/lib/rubocop/cop/rails/find_by.rb +1 -1
- data/lib/rubocop/cop/rails/find_each.rb +2 -3
- data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +1 -1
- data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +1 -1
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +1 -1
- data/lib/rubocop/cop/rails/http_status.rb +4 -4
- data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +1 -1
- data/lib/rubocop/cop/rails/inverse_of.rb +2 -2
- data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +1 -1
- data/lib/rubocop/cop/rails/link_to_blank.rb +9 -2
- data/lib/rubocop/cop/rails/not_null_column.rb +1 -1
- data/lib/rubocop/cop/rails/output.rb +1 -1
- data/lib/rubocop/cop/rails/output_safety.rb +2 -2
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +1 -1
- data/lib/rubocop/cop/rails/presence.rb +1 -1
- data/lib/rubocop/cop/rails/present.rb +3 -3
- data/lib/rubocop/cop/rails/read_write_attribute.rb +1 -1
- data/lib/rubocop/cop/rails/redundant_allow_nil.rb +2 -2
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +1 -1
- data/lib/rubocop/cop/rails/reflection_class_name.rb +1 -1
- data/lib/rubocop/cop/rails/refute_methods.rb +1 -1
- data/lib/rubocop/cop/rails/relative_date_constant.rb +2 -2
- data/lib/rubocop/cop/rails/request_referer.rb +1 -1
- data/lib/rubocop/cop/rails/reversible_migration.rb +4 -4
- data/lib/rubocop/cop/rails/safe_navigation.rb +2 -6
- data/lib/rubocop/cop/rails/save_bang.rb +8 -8
- data/lib/rubocop/cop/rails/scope_args.rb +1 -1
- data/lib/rubocop/cop/rails/skips_model_validations.rb +1 -1
- data/lib/rubocop/cop/rails/time_zone.rb +53 -39
- data/lib/rubocop/cop/rails/uniq_before_pluck.rb +3 -3
- data/lib/rubocop/cop/rails/unknown_env.rb +2 -2
- data/lib/rubocop/cop/rails/validation.rb +1 -1
- data/lib/rubocop/cop/registry.rb +1 -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/alias.rb +3 -3
- data/lib/rubocop/cop/style/and_or.rb +1 -1
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
- data/lib/rubocop/cop/style/attr.rb +1 -1
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +1 -1
- data/lib/rubocop/cop/style/bare_percent_literals.rb +1 -1
- data/lib/rubocop/cop/style/begin_block.rb +1 -1
- data/lib/rubocop/cop/style/block_comments.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +0 -1
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +1 -1
- data/lib/rubocop/cop/style/case_equality.rb +1 -1
- data/lib/rubocop/cop/style/character_literal.rb +1 -1
- data/lib/rubocop/cop/style/class_and_module_children.rb +5 -5
- data/lib/rubocop/cop/style/class_check.rb +1 -1
- data/lib/rubocop/cop/style/class_methods.rb +1 -1
- data/lib/rubocop/cop/style/class_vars.rb +1 -1
- data/lib/rubocop/cop/style/collection_methods.rb +1 -1
- data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
- data/lib/rubocop/cop/style/colon_method_definition.rb +1 -1
- data/lib/rubocop/cop/style/command_literal.rb +2 -2
- data/lib/rubocop/cop/style/comment_annotation.rb +2 -2
- data/lib/rubocop/cop/style/commented_keyword.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +14 -14
- data/lib/rubocop/cop/style/constant_visibility.rb +1 -1
- data/lib/rubocop/cop/style/copyright.rb +2 -2
- data/lib/rubocop/cop/style/date_time.rb +2 -2
- data/lib/rubocop/cop/style/def_with_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/dir.rb +1 -1
- data/lib/rubocop/cop/style/documentation.rb +2 -2
- data/lib/rubocop/cop/style/documentation_method.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +1 -1
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +3 -3
- data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
- data/lib/rubocop/cop/style/empty_case_condition.rb +1 -1
- data/lib/rubocop/cop/style/empty_else.rb +2 -2
- data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
- data/lib/rubocop/cop/style/empty_literal.rb +3 -3
- data/lib/rubocop/cop/style/empty_method.rb +2 -2
- data/lib/rubocop/cop/style/encoding.rb +2 -2
- data/lib/rubocop/cop/style/end_block.rb +1 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +3 -3
- 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/for.rb +2 -2
- data/lib/rubocop/cop/style/format_string.rb +1 -1
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +5 -21
- data/lib/rubocop/cop/style/global_vars.rb +1 -1
- data/lib/rubocop/cop/style/guard_clause.rb +3 -3
- data/lib/rubocop/cop/style/hash_syntax.rb +3 -3
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +1 -1
- data/lib/rubocop/cop/style/if_inside_else.rb +2 -2
- data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -1
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +1 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -2
- data/lib/rubocop/cop/style/implicit_runtime_error.rb +1 -1
- data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
- data/lib/rubocop/cop/style/inline_comment.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +7 -1
- data/lib/rubocop/cop/style/ip_addresses.rb +1 -1
- data/lib/rubocop/cop/style/lambda.rb +2 -2
- data/lib/rubocop/cop/style/line_end_concatenation.rb +2 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +3 -3
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -2
- data/lib/rubocop/cop/style/method_def_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/method_missing_super.rb +1 -1
- data/lib/rubocop/cop/style/min_max.rb +1 -1
- data/lib/rubocop/cop/style/missing_else.rb +3 -3
- data/lib/rubocop/cop/style/missing_respond_to_missing.rb +1 -1
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/mixin_usage.rb +1 -1
- data/lib/rubocop/cop/style/module_function.rb +3 -3
- data/lib/rubocop/cop/style/multiline_block_chain.rb +2 -2
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +1 -1
- data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
- 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/negated_if.rb +1 -1
- data/lib/rubocop/cop/style/negated_unless.rb +89 -0
- data/lib/rubocop/cop/style/nested_modifier.rb +4 -4
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/next.rb +5 -5
- data/lib/rubocop/cop/style/nil_comparison.rb +2 -2
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +5 -5
- data/lib/rubocop/cop/style/numeric_literals.rb +2 -2
- data/lib/rubocop/cop/style/numeric_predicate.rb +2 -10
- data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
- 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/or_assignment.rb +1 -1
- data/lib/rubocop/cop/style/parallel_assignment.rb +2 -2
- data/lib/rubocop/cop/style/percent_q_literals.rb +2 -2
- data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +1 -1
- data/lib/rubocop/cop/style/proc.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +2 -2
- data/lib/rubocop/cop/style/random_with_offset.rb +1 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +2 -2
- data/lib/rubocop/cop/style/redundant_conditional.rb +1 -1
- 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 +6 -6
- data/lib/rubocop/cop/style/redundant_return.rb +3 -3
- data/lib/rubocop/cop/style/redundant_self.rb +2 -2
- data/lib/rubocop/cop/style/redundant_sort_by.rb +1 -1
- data/lib/rubocop/cop/style/regexp_literal.rb +2 -2
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
- data/lib/rubocop/cop/style/return_nil.rb +2 -2
- data/lib/rubocop/cop/style/safe_navigation.rb +2 -7
- data/lib/rubocop/cop/style/sample.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/semicolon.rb +1 -1
- data/lib/rubocop/cop/style/send.rb +1 -1
- data/lib/rubocop/cop/style/signal_exception.rb +2 -2
- data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +1 -1
- data/lib/rubocop/cop/style/special_global_vars.rb +5 -5
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/stderr_puts.rb +0 -1
- data/lib/rubocop/cop/style/string_hash_keys.rb +2 -1
- data/lib/rubocop/cop/style/string_literals.rb +1 -1
- data/lib/rubocop/cop/style/string_methods.rb +1 -1
- data/lib/rubocop/cop/style/strip.rb +1 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +2 -2
- data/lib/rubocop/cop/style/symbol_literal.rb +1 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
- data/lib/rubocop/cop/style/ternary_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/trailing_body_on_class.rb +1 -1
- data/lib/rubocop/cop/style/trailing_body_on_method_definition.rb +1 -1
- data/lib/rubocop/cop/style/trailing_body_on_module.rb +1 -1
- data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -1
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +2 -2
- data/lib/rubocop/cop/style/trivial_accessors.rb +2 -2
- data/lib/rubocop/cop/style/unless_else.rb +2 -2
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_condition.rb +4 -4
- data/lib/rubocop/cop/style/unneeded_interpolation.rb +3 -3
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +7 -7
- data/lib/rubocop/cop/style/unneeded_sort.rb +2 -2
- data/lib/rubocop/cop/style/unpack_first.rb +1 -1
- data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/when_then.rb +1 -1
- data/lib/rubocop/cop/style/while_until_do.rb +1 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
- data/lib/rubocop/cop/style/word_array.rb +2 -2
- data/lib/rubocop/cop/style/yoda_condition.rb +1 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +2 -2
- data/lib/rubocop/cop/util.rb +2 -2
- data/lib/rubocop/cop/variable_force/variable_table.rb +1 -1
- data/lib/rubocop/core_ext/string.rb +1 -1
- data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -2
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/html_formatter.rb +1 -1
- data/lib/rubocop/formatter/progress_formatter.rb +1 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
- data/lib/rubocop/magic_comment.rb +4 -4
- data/lib/rubocop/node_pattern.rb +9 -9
- data/lib/rubocop/options.rb +2 -2
- data/lib/rubocop/processed_source.rb +3 -5
- data/lib/rubocop/rspec/cop_helper.rb +2 -2
- data/lib/rubocop/rspec/expect_offense.rb +5 -5
- data/lib/rubocop/rspec/shared_contexts.rb +0 -4
- data/lib/rubocop/runner.rb +1 -1
- data/lib/rubocop/string_interpreter.rb +7 -7
- data/lib/rubocop/version.rb +2 -2
- metadata +11 -16
@@ -83,7 +83,7 @@ module RuboCop
|
|
83
83
|
include MultilineElementIndentation
|
84
84
|
|
85
85
|
MSG = 'Use %<configured_indentation_width>d spaces for indentation ' \
|
86
|
-
'in a hash, relative to %<base_description>s.'
|
86
|
+
'in a hash, relative to %<base_description>s.'
|
87
87
|
|
88
88
|
def on_hash(node)
|
89
89
|
check(node, nil) if node.loc.begin
|
@@ -16,7 +16,7 @@ module RuboCop
|
|
16
16
|
# 123
|
17
17
|
# end
|
18
18
|
#
|
19
|
-
# @example EnforcedStyle: consistent
|
19
|
+
# @example EnforcedStyle: consistent (default)
|
20
20
|
# # The first parameter should always be indented one step more than the
|
21
21
|
# # preceding line.
|
22
22
|
#
|
@@ -43,7 +43,7 @@ module RuboCop
|
|
43
43
|
include MultilineElementIndentation
|
44
44
|
|
45
45
|
MSG = 'Use %<configured_indentation_width>d spaces for indentation ' \
|
46
|
-
'in method args, relative to %<base_description>s.'
|
46
|
+
'in method args, relative to %<base_description>s.'
|
47
47
|
|
48
48
|
def on_def(node)
|
49
49
|
return if node.arguments.empty?
|
@@ -12,32 +12,13 @@ module RuboCop
|
|
12
12
|
# this cop does not add any offenses for long here documents to
|
13
13
|
# avoid `Metrics/LineLength`'s offenses.
|
14
14
|
#
|
15
|
-
# @example EnforcedStyle:
|
15
|
+
# @example EnforcedStyle: squiggly (default)
|
16
16
|
# # bad
|
17
17
|
# <<-RUBY
|
18
18
|
# something
|
19
19
|
# RUBY
|
20
20
|
#
|
21
21
|
# # good
|
22
|
-
# # When using Ruby 2.3 or higher.
|
23
|
-
# <<~RUBY
|
24
|
-
# something
|
25
|
-
# RUBY
|
26
|
-
#
|
27
|
-
# # good
|
28
|
-
# # When using Ruby 2.2 or lower and enabled Rails department.
|
29
|
-
# # The following is possible to enable Rails department by
|
30
|
-
# # adding for example:
|
31
|
-
# #
|
32
|
-
# # Rails:
|
33
|
-
# # Enabled: true
|
34
|
-
# #
|
35
|
-
# <<-RUBY.strip_heredoc
|
36
|
-
# something
|
37
|
-
# RUBY
|
38
|
-
#
|
39
|
-
# @example EnforcedStyle: squiggly
|
40
|
-
# # good
|
41
22
|
# # When EnforcedStyle is squiggly, bad code is auto-corrected to the
|
42
23
|
# # following code.
|
43
24
|
# <<~RUBY
|
@@ -56,7 +37,7 @@ module RuboCop
|
|
56
37
|
# # good
|
57
38
|
# # When EnforcedStyle is powerpack, bad code is auto-corrected to
|
58
39
|
# # the following code.
|
59
|
-
#
|
40
|
+
# <<~RUBY
|
60
41
|
# something
|
61
42
|
# RUBY
|
62
43
|
#
|
@@ -75,11 +56,11 @@ module RuboCop
|
|
75
56
|
|
76
57
|
RUBY23_TYPE_MSG = 'Use %<indentation_width>d spaces for indentation ' \
|
77
58
|
'in a heredoc by using `<<~` instead of ' \
|
78
|
-
'`%<current_indent_type>s`.'
|
59
|
+
'`%<current_indent_type>s`.'
|
79
60
|
RUBY23_WIDTH_MSG = 'Use %<indentation_width>d spaces for '\
|
80
|
-
'indentation in a heredoc.'
|
61
|
+
'indentation in a heredoc.'
|
81
62
|
LIBRARY_MSG = 'Use %<indentation_width>d spaces for indentation in a ' \
|
82
|
-
'heredoc by using %<method>s.'
|
63
|
+
'heredoc by using %<method>s.'
|
83
64
|
STRIP_METHODS = {
|
84
65
|
unindent: 'unindent',
|
85
66
|
active_support: 'strip_heredoc',
|
@@ -117,17 +98,6 @@ module RuboCop
|
|
117
98
|
|
118
99
|
private
|
119
100
|
|
120
|
-
def style
|
121
|
-
style = super
|
122
|
-
return style unless style == :auto_detection
|
123
|
-
|
124
|
-
if target_ruby_version >= 2.3
|
125
|
-
:squiggly
|
126
|
-
elsif rails?
|
127
|
-
:active_support
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
101
|
def message(node)
|
132
102
|
case style
|
133
103
|
when :squiggly
|
@@ -198,8 +168,6 @@ module RuboCop
|
|
198
168
|
end
|
199
169
|
|
200
170
|
def correct_by_squiggly(node)
|
201
|
-
return if target_ruby_version < 2.3
|
202
|
-
|
203
171
|
lambda do |corrector|
|
204
172
|
if heredoc_indent_type(node) == '~'
|
205
173
|
adjust_squiggly(corrector, node)
|
@@ -229,16 +197,10 @@ module RuboCop
|
|
229
197
|
end
|
230
198
|
|
231
199
|
def check_style!
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
when :squiggly
|
237
|
-
if target_ruby_version < 2.3
|
238
|
-
raise Warning, '`squiggly` style is selectable only on Ruby ' \
|
239
|
-
"2.3 or higher for #{cop_name}."
|
240
|
-
end
|
241
|
-
end
|
200
|
+
return if style
|
201
|
+
|
202
|
+
raise Warning, "Auto-correction does not work for #{cop_name}. " \
|
203
|
+
'Please configure EnforcedStyle.'
|
242
204
|
end
|
243
205
|
|
244
206
|
def indented_body(node)
|
@@ -50,7 +50,7 @@ module RuboCop
|
|
50
50
|
include RangeHelp
|
51
51
|
|
52
52
|
MSG = 'Use %<configured_indentation_width>d (not %<indentation>d) ' \
|
53
|
-
'spaces for%<name>s indentation.'
|
53
|
+
'spaces for%<name>s indentation.'
|
54
54
|
|
55
55
|
SPECIAL_MODIFIERS = %w[private protected].freeze
|
56
56
|
|
@@ -342,7 +342,7 @@ module RuboCop
|
|
342
342
|
end
|
343
343
|
|
344
344
|
def leftmost_modifier_of(node)
|
345
|
-
return node unless node.parent
|
345
|
+
return node unless node.parent&.send_type?
|
346
346
|
|
347
347
|
leftmost_modifier_of(node.parent)
|
348
348
|
end
|
@@ -20,7 +20,7 @@ module RuboCop
|
|
20
20
|
class InitialIndentation < Cop
|
21
21
|
include RangeHelp
|
22
22
|
|
23
|
-
MSG = 'Indentation of first line in file detected.'
|
23
|
+
MSG = 'Indentation of first line in file detected.'
|
24
24
|
|
25
25
|
def investigate(_processed_source)
|
26
26
|
space_before(first_token) do |space|
|
@@ -28,7 +28,7 @@ module RuboCop
|
|
28
28
|
# # (start of file)
|
29
29
|
# # a comment
|
30
30
|
class LeadingBlankLines < Cop
|
31
|
-
MSG = 'Unnecessary blank line at the beginning of the source.'
|
31
|
+
MSG = 'Unnecessary blank line at the beginning of the source.'
|
32
32
|
|
33
33
|
def investigate(processed_source)
|
34
34
|
token = processed_source.tokens[0]
|
@@ -93,17 +93,17 @@ module RuboCop
|
|
93
93
|
|
94
94
|
SAME_LINE_MESSAGE = 'The closing array brace must be on the same ' \
|
95
95
|
'line as the last array element when the opening brace is on the ' \
|
96
|
-
'same line as the first array element.'
|
96
|
+
'same line as the first array element.'
|
97
97
|
|
98
98
|
NEW_LINE_MESSAGE = 'The closing array brace must be on the line ' \
|
99
99
|
'after the last array element when the opening brace is on a ' \
|
100
|
-
'separate line from the first array element.'
|
100
|
+
'separate line from the first array element.'
|
101
101
|
|
102
102
|
ALWAYS_NEW_LINE_MESSAGE = 'The closing array brace must be on the ' \
|
103
|
-
'line after the last array element.'
|
103
|
+
'line after the last array element.'
|
104
104
|
|
105
105
|
ALWAYS_SAME_LINE_MESSAGE = 'The closing array brace must be on the ' \
|
106
|
-
'same line as the last array element.'
|
106
|
+
'same line as the last array element.'
|
107
107
|
|
108
108
|
def on_array(node)
|
109
109
|
check_brace_layout(node)
|
@@ -37,10 +37,10 @@ module RuboCop
|
|
37
37
|
include RangeHelp
|
38
38
|
|
39
39
|
NEW_LINE_OFFENSE = 'Right hand side of multi-line assignment is on ' \
|
40
|
-
'the same line as the assignment operator `=`.'
|
40
|
+
'the same line as the assignment operator `=`.'
|
41
41
|
|
42
42
|
SAME_LINE_OFFENSE = 'Right hand side of multi-line assignment is not ' \
|
43
|
-
'on the same line as the assignment operator `=`.'
|
43
|
+
'on the same line as the assignment operator `=`.'
|
44
44
|
|
45
45
|
def check_assignment(node, rhs)
|
46
46
|
return if node.send_type?
|
@@ -39,9 +39,9 @@ module RuboCop
|
|
39
39
|
include RangeHelp
|
40
40
|
|
41
41
|
MSG = 'Block body expression is on the same line as ' \
|
42
|
-
'the block start.'
|
42
|
+
'the block start.'
|
43
43
|
ARG_MSG = 'Block argument expression is not on the same line as the ' \
|
44
|
-
'block start.'
|
44
|
+
'block start.'
|
45
45
|
|
46
46
|
def on_block(node)
|
47
47
|
return if node.single_line?
|
@@ -93,17 +93,17 @@ module RuboCop
|
|
93
93
|
|
94
94
|
SAME_LINE_MESSAGE = 'Closing hash brace must be on the same line as ' \
|
95
95
|
'the last hash element when opening brace is on the same line as ' \
|
96
|
-
'the first hash element.'
|
96
|
+
'the first hash element.'
|
97
97
|
|
98
98
|
NEW_LINE_MESSAGE = 'Closing hash brace must be on the line after ' \
|
99
99
|
'the last hash element when opening brace is on a separate line ' \
|
100
|
-
'from the first hash element.'
|
100
|
+
'from the first hash element.'
|
101
101
|
|
102
102
|
ALWAYS_NEW_LINE_MESSAGE = 'Closing hash brace must be on the line ' \
|
103
|
-
'after the last hash element.'
|
103
|
+
'after the last hash element.'
|
104
104
|
|
105
105
|
ALWAYS_SAME_LINE_MESSAGE = 'Closing hash brace must be on the same ' \
|
106
|
-
'line as the last hash element.'
|
106
|
+
'line as the last hash element.'
|
107
107
|
|
108
108
|
def self.autocorrect_incompatible_with
|
109
109
|
[Style::BracesAroundHashParameters]
|
@@ -93,17 +93,17 @@ module RuboCop
|
|
93
93
|
|
94
94
|
SAME_LINE_MESSAGE = 'Closing method call brace must be on the ' \
|
95
95
|
'same line as the last argument when opening brace is on the same ' \
|
96
|
-
'line as the first argument.'
|
96
|
+
'line as the first argument.'
|
97
97
|
|
98
98
|
NEW_LINE_MESSAGE = 'Closing method call brace must be on the ' \
|
99
99
|
'line after the last argument when opening brace is on a separate ' \
|
100
|
-
'line from the first argument.'
|
100
|
+
'line from the first argument.'
|
101
101
|
|
102
102
|
ALWAYS_NEW_LINE_MESSAGE = 'Closing method call brace must be on ' \
|
103
|
-
'the line after the last argument.'
|
103
|
+
'the line after the last argument.'
|
104
104
|
|
105
105
|
ALWAYS_SAME_LINE_MESSAGE = 'Closing method call brace must be on ' \
|
106
|
-
'the same line as the last argument.'
|
106
|
+
'the same line as the last argument.'
|
107
107
|
|
108
108
|
def on_send(node)
|
109
109
|
check_brace_layout(node)
|
@@ -170,7 +170,7 @@ module RuboCop
|
|
170
170
|
return unless rhs.source.start_with?('.')
|
171
171
|
|
172
172
|
node = semantic_alignment_node(node)
|
173
|
-
return unless node
|
173
|
+
return unless node&.loc&.selector
|
174
174
|
|
175
175
|
node.loc.dot.join(node.loc.selector)
|
176
176
|
end
|
@@ -183,7 +183,7 @@ module RuboCop
|
|
183
183
|
node = node.parent
|
184
184
|
node = node.parent until node.loc.dot
|
185
185
|
|
186
|
-
node
|
186
|
+
node&.receiver&.source_range
|
187
187
|
end
|
188
188
|
|
189
189
|
def semantic_alignment_node(node)
|
@@ -105,17 +105,17 @@ module RuboCop
|
|
105
105
|
|
106
106
|
SAME_LINE_MESSAGE = 'Closing method definition brace must be on the ' \
|
107
107
|
'same line as the last parameter when opening brace is on the same ' \
|
108
|
-
'line as the first parameter.'
|
108
|
+
'line as the first parameter.'
|
109
109
|
|
110
110
|
NEW_LINE_MESSAGE = 'Closing method definition brace must be on the ' \
|
111
111
|
'line after the last parameter when opening brace is on a separate ' \
|
112
|
-
'line from the first parameter.'
|
112
|
+
'line from the first parameter.'
|
113
113
|
|
114
114
|
ALWAYS_NEW_LINE_MESSAGE = 'Closing method definition brace must be ' \
|
115
|
-
'on the line after the last parameter.'
|
115
|
+
'on the line after the last parameter.'
|
116
116
|
|
117
117
|
ALWAYS_SAME_LINE_MESSAGE = 'Closing method definition brace must be ' \
|
118
|
-
'on the same line as the last parameter.'
|
118
|
+
'on the same line as the last parameter.'
|
119
119
|
|
120
120
|
def on_def(node)
|
121
121
|
check_brace_layout(node.arguments)
|
@@ -26,7 +26,7 @@ module RuboCop
|
|
26
26
|
|
27
27
|
MSG = '`%<kw_loc>s` at %<kw_loc_line>d, %<kw_loc_column>d is not ' \
|
28
28
|
'aligned with `%<beginning>s` at ' \
|
29
|
-
'%<begin_loc_line>d, %<begin_loc_column>d.'
|
29
|
+
'%<begin_loc_line>d, %<begin_loc_column>d.'
|
30
30
|
ANCESTOR_TYPES = %i[kwbegin def defs class module].freeze
|
31
31
|
RUBY_2_5_ANCESTOR_TYPES = (ANCESTOR_TYPES + %i[block]).freeze
|
32
32
|
ANCESTOR_TYPES_WITH_ACCESS_MODIFIERS = %i[def defs].freeze
|
@@ -140,7 +140,7 @@ module RuboCop
|
|
140
140
|
def assignment_node(node)
|
141
141
|
assignment_node = node.ancestors.first
|
142
142
|
return nil unless
|
143
|
-
assignment_node
|
143
|
+
assignment_node&.assignment?
|
144
144
|
|
145
145
|
assignment_node
|
146
146
|
end
|
@@ -18,11 +18,11 @@ module RuboCop
|
|
18
18
|
include RangeHelp
|
19
19
|
|
20
20
|
MSG = 'Do not put a space between a method name and the opening ' \
|
21
|
-
'parenthesis.'
|
21
|
+
'parenthesis.'
|
22
22
|
|
23
23
|
def on_def(node)
|
24
24
|
args = node.arguments
|
25
|
-
return unless args.loc.begin
|
25
|
+
return unless args.loc.begin&.is?('(')
|
26
26
|
|
27
27
|
expr = args.source_range
|
28
28
|
pos_before_left_paren = range_between(expr.begin_pos - 1,
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
class SpaceAfterNot < Cop
|
15
15
|
include RangeHelp
|
16
16
|
|
17
|
-
MSG = 'Do not leave space between `!` and its argument.'
|
17
|
+
MSG = 'Do not leave space between `!` and its argument.'
|
18
18
|
|
19
19
|
def on_send(node)
|
20
20
|
return unless node.prefix_bang? && whitespace_after_operator?(node)
|
@@ -32,7 +32,7 @@ module RuboCop
|
|
32
32
|
include ConfigurableEnforcedStyle
|
33
33
|
include RangeHelp
|
34
34
|
|
35
|
-
MSG = 'Surrounding space %<type>s in default value assignment.'
|
35
|
+
MSG = 'Surrounding space %<type>s in default value assignment.'
|
36
36
|
|
37
37
|
def on_optarg(node)
|
38
38
|
index = index_of_first_token(node)
|
@@ -25,11 +25,11 @@ module RuboCop
|
|
25
25
|
#
|
26
26
|
# something = 123 if test
|
27
27
|
class SpaceAroundKeyword < Cop
|
28
|
-
MSG_BEFORE = 'Space before keyword `%<range>s` is missing.'
|
29
|
-
MSG_AFTER = 'Space after keyword `%<range>s` is missing.'
|
28
|
+
MSG_BEFORE = 'Space before keyword `%<range>s` is missing.'
|
29
|
+
MSG_AFTER = 'Space after keyword `%<range>s` is missing.'
|
30
30
|
|
31
|
-
DO = 'do'
|
32
|
-
SAFE_NAVIGATION = '&.'
|
31
|
+
DO = 'do'
|
32
|
+
SAFE_NAVIGATION = '&.'
|
33
33
|
ACCEPT_LEFT_PAREN =
|
34
34
|
%w[break defined? next not rescue return super yield].freeze
|
35
35
|
ACCEPT_LEFT_SQUARE_BRACKET =
|
@@ -60,7 +60,7 @@ module RuboCop
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def on_if(node)
|
63
|
-
check(node, %i[keyword else begin end].freeze, 'then'
|
63
|
+
check(node, %i[keyword else begin end].freeze, 'then')
|
64
64
|
end
|
65
65
|
|
66
66
|
def on_kwbegin(node)
|
@@ -129,9 +129,9 @@ module RuboCop
|
|
129
129
|
|
130
130
|
def autocorrect(range)
|
131
131
|
if space_before_missing?(range)
|
132
|
-
->(corrector) { corrector.insert_before(range, ' '
|
132
|
+
->(corrector) { corrector.insert_before(range, ' ') }
|
133
133
|
else
|
134
|
-
->(corrector) { corrector.insert_after(range, ' '
|
134
|
+
->(corrector) { corrector.insert_after(range, ' ') }
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -165,7 +165,7 @@ module RuboCop
|
|
165
165
|
end
|
166
166
|
|
167
167
|
def do?(node)
|
168
|
-
node.loc.begin
|
168
|
+
node.loc.begin&.is?(DO)
|
169
169
|
end
|
170
170
|
|
171
171
|
def check_keyword(node, range)
|
@@ -182,7 +182,7 @@ module RuboCop
|
|
182
182
|
|
183
183
|
def space_before_missing?(range)
|
184
184
|
pos = range.begin_pos - 1
|
185
|
-
return false if pos
|
185
|
+
return false if pos.negative?
|
186
186
|
|
187
187
|
range.source_buffer.source[pos] !~ /[\s\(\|\{\[;,\*\=]/
|
188
188
|
end
|