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
@@ -9,22 +9,7 @@ module RuboCop
|
|
9
9
|
# after Ruby 3.0. The comment will be added below a shebang and encoding
|
10
10
|
# comment. The frozen string literal comment is only valid in Ruby 2.3+.
|
11
11
|
#
|
12
|
-
# @example EnforcedStyle:
|
13
|
-
# # The `when_needed` style will add the frozen string literal comment
|
14
|
-
# # to files only when the `TargetRubyVersion` is set to 2.3+.
|
15
|
-
# # bad
|
16
|
-
# module Foo
|
17
|
-
# # ...
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
# # good
|
21
|
-
# # frozen_string_literal: true
|
22
|
-
#
|
23
|
-
# module Foo
|
24
|
-
# # ...
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
# @example EnforcedStyle: always
|
12
|
+
# @example EnforcedStyle: always (default)
|
28
13
|
# # The `always` style will always add the frozen string literal comment
|
29
14
|
# # to a file, regardless of the Ruby version or if `freeze` or `<<` are
|
30
15
|
# # called on a string literal.
|
@@ -59,12 +44,11 @@ module RuboCop
|
|
59
44
|
include FrozenStringLiteral
|
60
45
|
include RangeHelp
|
61
46
|
|
62
|
-
MSG = 'Missing magic comment `# frozen_string_literal: true`.'
|
63
|
-
MSG_UNNECESSARY = 'Unnecessary frozen string literal comment.'
|
64
|
-
SHEBANG = '#!'
|
47
|
+
MSG = 'Missing magic comment `# frozen_string_literal: true`.'
|
48
|
+
MSG_UNNECESSARY = 'Unnecessary frozen string literal comment.'
|
49
|
+
SHEBANG = '#!'
|
65
50
|
|
66
51
|
def investigate(processed_source)
|
67
|
-
return if style == :when_needed && target_ruby_version < 2.3
|
68
52
|
return if processed_source.tokens.empty?
|
69
53
|
|
70
54
|
if frozen_string_literal_comment_exists?
|
@@ -157,7 +141,7 @@ module RuboCop
|
|
157
141
|
last_special_comment = last_special_comment(processed_source)
|
158
142
|
following_line = processed_source.following_line(last_special_comment)
|
159
143
|
|
160
|
-
if following_line
|
144
|
+
if following_line&.empty?
|
161
145
|
"\n#{FROZEN_STRING_LITERAL_ENABLED}"
|
162
146
|
else
|
163
147
|
"\n#{FROZEN_STRING_LITERAL_ENABLED}\n"
|
@@ -20,7 +20,7 @@ module RuboCop
|
|
20
20
|
# foo = 2
|
21
21
|
# $stdin.read
|
22
22
|
class GlobalVars < Cop
|
23
|
-
MSG = 'Do not introduce global variables.'
|
23
|
+
MSG = 'Do not introduce global variables.'
|
24
24
|
|
25
25
|
# built-in global variables and their English aliases
|
26
26
|
# https://www.zenspider.com/ruby/quickref.html
|
@@ -39,7 +39,7 @@ module RuboCop
|
|
39
39
|
include MinBodyLength
|
40
40
|
|
41
41
|
MSG = 'Use a guard clause instead of wrapping the code inside a ' \
|
42
|
-
'conditional expression.'
|
42
|
+
'conditional expression.'
|
43
43
|
|
44
44
|
def on_def(node)
|
45
45
|
body = node.body
|
@@ -83,8 +83,8 @@ module RuboCop
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def contains_guard_clause?(node)
|
86
|
-
node.if_branch
|
87
|
-
node.else_branch
|
86
|
+
node.if_branch&.guard_clause? ||
|
87
|
+
node.else_branch&.guard_clause?
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -58,9 +58,9 @@ module RuboCop
|
|
58
58
|
include ConfigurableEnforcedStyle
|
59
59
|
include RangeHelp
|
60
60
|
|
61
|
-
MSG_19 = 'Use the new Ruby 1.9 hash syntax.'
|
62
|
-
MSG_NO_MIXED_KEYS = "Don't mix styles in the same hash."
|
63
|
-
MSG_HASH_ROCKETS = 'Use hash rockets syntax.'
|
61
|
+
MSG_19 = 'Use the new Ruby 1.9 hash syntax.'
|
62
|
+
MSG_NO_MIXED_KEYS = "Don't mix styles in the same hash."
|
63
|
+
MSG_HASH_ROCKETS = 'Use hash rockets syntax.'
|
64
64
|
|
65
65
|
def on_hash(node)
|
66
66
|
pairs = node.pairs
|
@@ -28,14 +28,14 @@ module RuboCop
|
|
28
28
|
# action_c
|
29
29
|
# end
|
30
30
|
class IfInsideElse < Cop
|
31
|
-
MSG = 'Convert `if` nested inside `else` to `elsif`.'
|
31
|
+
MSG = 'Convert `if` nested inside `else` to `elsif`.'
|
32
32
|
|
33
33
|
def on_if(node)
|
34
34
|
return if node.ternary? || node.unless?
|
35
35
|
|
36
36
|
else_branch = node.else_branch
|
37
37
|
|
38
|
-
return unless else_branch
|
38
|
+
return unless else_branch&.if_type? && else_branch&.if?
|
39
39
|
|
40
40
|
add_offense(else_branch, location: :keyword)
|
41
41
|
end
|
@@ -26,7 +26,7 @@ module RuboCop
|
|
26
26
|
|
27
27
|
MSG = 'Favor modifier `%<keyword>s` usage when having a single-line ' \
|
28
28
|
'body. Another good alternative is the usage of control flow ' \
|
29
|
-
'`&&`/`||`.'
|
29
|
+
'`&&`/`||`.'
|
30
30
|
|
31
31
|
ASSIGNMENT_TYPES = %i[lvasgn casgn cvasgn
|
32
32
|
gvasgn ivasgn masgn].freeze
|
@@ -25,7 +25,7 @@ module RuboCop
|
|
25
25
|
class IfUnlessModifierOfIfUnless < Cop
|
26
26
|
include StatementModifier
|
27
27
|
|
28
|
-
MSG = 'Avoid modifier `%<keyword>s` after another conditional.'
|
28
|
+
MSG = 'Avoid modifier `%<keyword>s` after another conditional.'
|
29
29
|
|
30
30
|
def on_if(node)
|
31
31
|
return unless node.modifier_form? && node.body.if_type?
|
@@ -16,11 +16,11 @@ module RuboCop
|
|
16
16
|
class IfWithSemicolon < Cop
|
17
17
|
include OnNormalIfUnless
|
18
18
|
|
19
|
-
MSG = 'Do not use if x; Use the ternary operator instead.'
|
19
|
+
MSG = 'Do not use if x; Use the ternary operator instead.'
|
20
20
|
|
21
21
|
def on_normal_if_unless(node)
|
22
22
|
beginning = node.loc.begin
|
23
|
-
return unless beginning
|
23
|
+
return unless beginning&.is?(';')
|
24
24
|
|
25
25
|
add_offense(node)
|
26
26
|
end
|
@@ -16,7 +16,7 @@ module RuboCop
|
|
16
16
|
# raise ArgumentError, 'Error message here'
|
17
17
|
class ImplicitRuntimeError < Cop
|
18
18
|
MSG = 'Use `%<method>s` with an explicit exception class and message,' \
|
19
|
-
' rather than just a message.'
|
19
|
+
' rather than just a message.'
|
20
20
|
|
21
21
|
def_node_matcher :implicit_runtime_error_raise_or_fail,
|
22
22
|
'(send nil? ${:raise :fail} {str dstr})'
|
@@ -18,7 +18,7 @@ module RuboCop
|
|
18
18
|
# f.bar # Trailing inline comment
|
19
19
|
# end
|
20
20
|
class InlineComment < Cop
|
21
|
-
MSG = 'Avoid trailing inline comments.'
|
21
|
+
MSG = 'Avoid trailing inline comments.'
|
22
22
|
|
23
23
|
def investigate(processed_source)
|
24
24
|
processed_source.each_comment do |comment|
|
@@ -28,11 +28,16 @@ module RuboCop
|
|
28
28
|
# foo == bar
|
29
29
|
# !!('foo' =~ /^\w+$/)
|
30
30
|
# !(foo.class < Numeric) # Checking class hierarchy is allowed
|
31
|
+
# # Blocks with guard clauses are ignored:
|
32
|
+
# foo.select do |f|
|
33
|
+
# next if f.zero?
|
34
|
+
# f != 1
|
35
|
+
# end
|
31
36
|
class InverseMethods < Cop
|
32
37
|
include IgnoredNode
|
33
38
|
include RangeHelp
|
34
39
|
|
35
|
-
MSG = 'Use `%<inverse>s` instead of inverting `%<method>s`.'
|
40
|
+
MSG = 'Use `%<inverse>s` instead of inverting `%<method>s`.'
|
36
41
|
CLASS_COMPARISON_METHODS = %i[<= >= < >].freeze
|
37
42
|
EQUALITY_METHODS = %i[== != =~ !~ <= >= < >].freeze
|
38
43
|
NEGATED_EQUALITY_METHODS = %i[!= !~].freeze
|
@@ -76,6 +81,7 @@ module RuboCop
|
|
76
81
|
inverse_block?(node) do |_method_call, method, block|
|
77
82
|
return unless inverse_blocks.key?(method)
|
78
83
|
return if negated?(node) && negated?(node.parent)
|
84
|
+
return if node.each_node(:next).any?
|
79
85
|
|
80
86
|
# Inverse method offenses inside of the block of an inverse method
|
81
87
|
# offense, such as `y.reject { |key, _value| !(key =~ /c\d/) }`,
|
@@ -50,9 +50,9 @@ module RuboCop
|
|
50
50
|
include ConfigurableEnforcedStyle
|
51
51
|
|
52
52
|
LITERAL_MESSAGE = 'Use the `-> { ... }` lambda literal syntax for ' \
|
53
|
-
'%<modifier>s lambdas.'
|
53
|
+
'%<modifier>s lambdas.'
|
54
54
|
METHOD_MESSAGE = 'Use the `lambda` method for %<modifier>s ' \
|
55
|
-
'lambdas.'
|
55
|
+
'lambdas.'
|
56
56
|
|
57
57
|
OFFENDING_SELECTORS = {
|
58
58
|
style: {
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
include RangeHelp
|
24
24
|
|
25
25
|
MSG = 'Use `\\` instead of `+` or `<<` to concatenate ' \
|
26
|
-
'those strings.'
|
26
|
+
'those strings.'
|
27
27
|
CONCAT_TOKEN_TYPES = %i[tPLUS tLSHFT].freeze
|
28
28
|
SIMPLE_STRING_TOKEN_TYPE = :tSTRING
|
29
29
|
COMPLEX_STRING_EDGE_TOKEN_TYPES = %i[tSTRING_BEG tSTRING_END].freeze
|
@@ -94,7 +94,7 @@ module RuboCop
|
|
94
94
|
begin_token, end_token = COMPLEX_STRING_EDGE_TOKEN_TYPES
|
95
95
|
if successor.type == begin_token
|
96
96
|
ends_to_find = 1
|
97
|
-
while ends_to_find
|
97
|
+
while ends_to_find.positive?
|
98
98
|
case processed_source.tokens[index].type
|
99
99
|
when begin_token then ends_to_find += 1
|
100
100
|
when end_token then ends_to_find -= 1
|
@@ -163,9 +163,9 @@ module RuboCop
|
|
163
163
|
def message(_node = nil)
|
164
164
|
case style
|
165
165
|
when :require_parentheses
|
166
|
-
'Use parentheses for method calls with arguments.'
|
166
|
+
'Use parentheses for method calls with arguments.'
|
167
167
|
when :omit_parentheses
|
168
|
-
'Omit parentheses for method calls with arguments.'
|
168
|
+
'Omit parentheses for method calls with arguments.'
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -327,7 +327,7 @@ module RuboCop
|
|
327
327
|
return false unless cop_config['AllowParenthesesInChaining']
|
328
328
|
|
329
329
|
previous = node.descendants.first
|
330
|
-
return false unless previous
|
330
|
+
return false unless previous&.send_type?
|
331
331
|
|
332
332
|
previous.parenthesized? ||
|
333
333
|
allowed_chained_call_with_parentheses?(previous)
|
@@ -15,7 +15,7 @@ module RuboCop
|
|
15
15
|
class MethodCalledOnDoEndBlock < Cop
|
16
16
|
include RangeHelp
|
17
17
|
|
18
|
-
MSG = 'Avoid chaining a method call on a do...end block.'
|
18
|
+
MSG = 'Avoid chaining a method call on a do...end block.'
|
19
19
|
|
20
20
|
def on_block(node)
|
21
21
|
# If the method that is chained on the do...end block is itself a
|
@@ -31,7 +31,7 @@ module RuboCop
|
|
31
31
|
|
32
32
|
receiver = node.receiver
|
33
33
|
|
34
|
-
return unless receiver
|
34
|
+
return unless receiver&.block_type? &&
|
35
35
|
receiver.loc.end.is?('end')
|
36
36
|
|
37
37
|
range = range_between(receiver.loc.end.begin_pos,
|
@@ -88,9 +88,9 @@ module RuboCop
|
|
88
88
|
include ConfigurableEnforcedStyle
|
89
89
|
include RangeHelp
|
90
90
|
|
91
|
-
MSG_PRESENT = 'Use def without parentheses.'
|
91
|
+
MSG_PRESENT = 'Use def without parentheses.'
|
92
92
|
MSG_MISSING = 'Use def with parentheses when there are ' \
|
93
|
-
'parameters.'
|
93
|
+
'parameters.'
|
94
94
|
|
95
95
|
def on_def(node)
|
96
96
|
args = node.arguments
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
# super
|
20
20
|
# end
|
21
21
|
class MethodMissingSuper < Cop
|
22
|
-
MSG = 'When using `method_missing`, fall back on `super`.'
|
22
|
+
MSG = 'When using `method_missing`, fall back on `super`.'
|
23
23
|
|
24
24
|
def on_def(node)
|
25
25
|
return unless node.method?(:method_missing)
|
@@ -15,7 +15,7 @@ module RuboCop
|
|
15
15
|
# bar = foo.minmax
|
16
16
|
# return foo.minmax
|
17
17
|
class MinMax < Cop
|
18
|
-
MSG = 'Use `%<receiver>s.minmax` instead of `%<offender>s`.'
|
18
|
+
MSG = 'Use `%<receiver>s.minmax` instead of `%<offender>s`.'
|
19
19
|
|
20
20
|
def on_array(node)
|
21
21
|
min_max_candidate(node) do |receiver|
|
@@ -97,11 +97,11 @@ module RuboCop
|
|
97
97
|
include OnNormalIfUnless
|
98
98
|
include ConfigurableEnforcedStyle
|
99
99
|
|
100
|
-
MSG = '`%<type>s` condition requires an `else`-clause.'
|
100
|
+
MSG = '`%<type>s` condition requires an `else`-clause.'
|
101
101
|
MSG_NIL = '`%<type>s` condition requires an `else`-clause with ' \
|
102
|
-
'`nil` in it.'
|
102
|
+
'`nil` in it.'
|
103
103
|
MSG_EMPTY = '`%<type>s` condition requires an empty ' \
|
104
|
-
'`else`-clause.'
|
104
|
+
'`else`-clause.'
|
105
105
|
|
106
106
|
def on_normal_if_unless(node)
|
107
107
|
return if case_style?
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
#
|
24
24
|
class MissingRespondToMissing < Cop
|
25
25
|
MSG =
|
26
|
-
'When using `method_missing`, define `respond_to_missing?`.'
|
26
|
+
'When using `method_missing`, define `respond_to_missing?`.'
|
27
27
|
|
28
28
|
def on_def(node)
|
29
29
|
return unless node.method?(:method_missing)
|
@@ -34,7 +34,7 @@ module RuboCop
|
|
34
34
|
include ConfigurableEnforcedStyle
|
35
35
|
|
36
36
|
MIXIN_METHODS = %i[extend include prepend].freeze
|
37
|
-
MSG = 'Put `%<mixin>s` mixins in %<suffix>s.'
|
37
|
+
MSG = 'Put `%<mixin>s` mixins in %<suffix>s.'
|
38
38
|
|
39
39
|
def on_class(node)
|
40
40
|
begin_node = node.child_nodes.find(&:begin_type?) || node
|
@@ -42,7 +42,7 @@ module RuboCop
|
|
42
42
|
# end
|
43
43
|
class MixinUsage < Cop
|
44
44
|
MSG = '`%<statement>s` is used at the top level. Use inside `class` ' \
|
45
|
-
'or `module`.'
|
45
|
+
'or `module`.'
|
46
46
|
|
47
47
|
def_node_matcher :include_statement, <<-PATTERN
|
48
48
|
(send nil? ${:include :extend :prepend}
|
@@ -52,16 +52,16 @@ module RuboCop
|
|
52
52
|
include ConfigurableEnforcedStyle
|
53
53
|
|
54
54
|
MODULE_FUNCTION_MSG =
|
55
|
-
'Use `module_function` instead of `extend self`.'
|
55
|
+
'Use `module_function` instead of `extend self`.'
|
56
56
|
EXTEND_SELF_MSG =
|
57
|
-
'Use `extend self` instead of `module_function`.'
|
57
|
+
'Use `extend self` instead of `module_function`.'
|
58
58
|
|
59
59
|
def_node_matcher :module_function_node?, '(send nil? :module_function)'
|
60
60
|
def_node_matcher :extend_self_node?, '(send nil? :extend self)'
|
61
61
|
def_node_matcher :private_directive?, '(send nil? :private ...)'
|
62
62
|
|
63
63
|
def on_module(node)
|
64
|
-
return unless node.body
|
64
|
+
return unless node.body&.begin_type?
|
65
65
|
|
66
66
|
each_wrong_style(node.body.children) do |child_node|
|
67
67
|
add_offense(child_node)
|
@@ -16,13 +16,13 @@ module RuboCop
|
|
16
16
|
class MultilineBlockChain < Cop
|
17
17
|
include RangeHelp
|
18
18
|
|
19
|
-
MSG = 'Avoid multi-line chains of blocks.'
|
19
|
+
MSG = 'Avoid multi-line chains of blocks.'
|
20
20
|
|
21
21
|
def on_block(node)
|
22
22
|
node.send_node.each_node(:send) do |send_node|
|
23
23
|
receiver = send_node.receiver
|
24
24
|
|
25
|
-
next unless receiver
|
25
|
+
next unless receiver&.block_type? && receiver&.multiline?
|
26
26
|
|
27
27
|
range = range_between(receiver.loc.end.begin_pos,
|
28
28
|
node.send_node.source_range.end_pos)
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
include Alignment
|
20
20
|
|
21
21
|
MSG = 'Favor a normal %<keyword>s-statement over a modifier' \
|
22
|
-
' clause in a multiline statement.'
|
22
|
+
' clause in a multiline statement.'
|
23
23
|
|
24
24
|
def on_if(node)
|
25
25
|
return unless node.modifier_form? && node.body.multiline?
|
@@ -22,7 +22,7 @@ module RuboCop
|
|
22
22
|
|
23
23
|
NON_MODIFIER_THEN = /then\s*(#.*)?$/.freeze
|
24
24
|
|
25
|
-
MSG = 'Do not use `then` for multi-line `%<keyword>s`.'
|
25
|
+
MSG = 'Do not use `then` for multi-line `%<keyword>s`.'
|
26
26
|
|
27
27
|
def on_normal_if_unless(node)
|
28
28
|
return unless non_modifier_then?(node)
|
@@ -33,7 +33,7 @@ module RuboCop
|
|
33
33
|
class MultilineMemoization < Cop
|
34
34
|
include ConfigurableEnforcedStyle
|
35
35
|
|
36
|
-
MSG = 'Wrap multiline memoization blocks in `begin` and `end`.'
|
36
|
+
MSG = 'Wrap multiline memoization blocks in `begin` and `end`.'
|
37
37
|
|
38
38
|
def on_or_asgn(node)
|
39
39
|
_lhs, rhs = *node
|