rubocop 0.68.1 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -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
@@ -22,11 +22,11 @@ module RuboCop
|
|
22
22
|
#
|
23
23
|
# # good
|
24
24
|
#
|
25
|
-
#
|
25
|
+
# <<~SQL
|
26
26
|
# bar
|
27
27
|
# SQL
|
28
28
|
#
|
29
|
-
#
|
29
|
+
# <<~SQL.trim
|
30
30
|
# bar
|
31
31
|
# SQL
|
32
32
|
#
|
@@ -34,9 +34,8 @@ module RuboCop
|
|
34
34
|
include RangeHelp
|
35
35
|
|
36
36
|
MSG = 'Put a method call with a HEREDOC receiver on the ' \
|
37
|
-
'same line as the HEREDOC opening.'
|
37
|
+
'same line as the HEREDOC opening.'
|
38
38
|
|
39
|
-
STRING_TYPES = %i[str dstr xstr].freeze
|
40
39
|
def on_send(node)
|
41
40
|
heredoc = heredoc_node_descendent_receiver(node)
|
42
41
|
return unless heredoc
|
@@ -72,11 +71,11 @@ module RuboCop
|
|
72
71
|
def send_node?(node)
|
73
72
|
return nil unless node
|
74
73
|
|
75
|
-
node.
|
74
|
+
node.call_type?
|
76
75
|
end
|
77
76
|
|
78
77
|
def heredoc_node?(node)
|
79
|
-
node
|
78
|
+
node.respond_to?(:heredoc?) && node.heredoc?
|
80
79
|
end
|
81
80
|
|
82
81
|
def call_after_heredoc_range(heredoc)
|
@@ -24,11 +24,11 @@ module RuboCop
|
|
24
24
|
# ]
|
25
25
|
class ImplicitStringConcatenation < Cop
|
26
26
|
MSG = 'Combine %<string1>s and %<string2>s into a single string ' \
|
27
|
-
'literal, rather than using implicit string concatenation.'
|
27
|
+
'literal, rather than using implicit string concatenation.'
|
28
28
|
FOR_ARRAY = ' Or, if they were intended to be separate array ' \
|
29
|
-
'elements, separate them with a comma.'
|
29
|
+
'elements, separate them with a comma.'
|
30
30
|
FOR_METHOD = ' Or, if they were intended to be separate method ' \
|
31
|
-
'arguments, separate them with a comma.'
|
31
|
+
'arguments, separate them with a comma.'
|
32
32
|
|
33
33
|
def on_dstr(node)
|
34
34
|
each_bad_cons(node) do |child_node1, child_node2|
|
@@ -36,9 +36,9 @@ module RuboCop
|
|
36
36
|
message = format(MSG,
|
37
37
|
string1: display_str(child_node1),
|
38
38
|
string2: display_str(child_node2))
|
39
|
-
if node.parent
|
39
|
+
if node.parent&.array_type?
|
40
40
|
message << FOR_ARRAY
|
41
|
-
elsif node.parent
|
41
|
+
elsif node.parent&.send_type?
|
42
42
|
message << FOR_METHOD
|
43
43
|
end
|
44
44
|
add_offense(node, location: range, message: message)
|
@@ -47,11 +47,11 @@ module RuboCop
|
|
47
47
|
# end
|
48
48
|
class IneffectiveAccessModifier < Cop
|
49
49
|
MSG = '`%<modifier>s` (on line %<line>d) does not make singleton ' \
|
50
|
-
'methods %<modifier>s. Use %<alternative>s instead.'
|
50
|
+
'methods %<modifier>s. Use %<alternative>s instead.'
|
51
51
|
ALTERNATIVE_PRIVATE = '`private_class_method` or `private` inside a ' \
|
52
|
-
'`class << self` block'
|
52
|
+
'`class << self` block'
|
53
53
|
ALTERNATIVE_PROTECTED = '`protected` inside a `class << self` ' \
|
54
|
-
'block'
|
54
|
+
'block'
|
55
55
|
|
56
56
|
def_node_search :private_class_methods, <<-PATTERN
|
57
57
|
(send nil? :private_class_method $...)
|
@@ -68,7 +68,7 @@ module RuboCop
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def check_node(node)
|
71
|
-
return unless node
|
71
|
+
return unless node&.begin_type?
|
72
72
|
|
73
73
|
ignored_methods = private_class_method_names(node)
|
74
74
|
|
@@ -13,22 +13,30 @@ module RuboCop
|
|
13
13
|
#
|
14
14
|
# class C < Exception; end
|
15
15
|
#
|
16
|
+
# C = Class.new(Exception)
|
17
|
+
#
|
16
18
|
# # good
|
17
19
|
#
|
18
20
|
# class C < RuntimeError; end
|
19
21
|
#
|
22
|
+
# C = Class.new(RuntimeError)
|
23
|
+
#
|
20
24
|
# @example EnforcedStyle: standard_error
|
21
25
|
# # bad
|
22
26
|
#
|
23
27
|
# class C < Exception; end
|
24
28
|
#
|
29
|
+
# C = Class.new(Exception)
|
30
|
+
#
|
25
31
|
# # good
|
26
32
|
#
|
27
33
|
# class C < StandardError; end
|
34
|
+
#
|
35
|
+
# C = Class.new(StandardError)
|
28
36
|
class InheritException < Cop
|
29
37
|
include ConfigurableEnforcedStyle
|
30
38
|
|
31
|
-
MSG = 'Inherit from `%<prefer>s` instead of `%<current>s`.'
|
39
|
+
MSG = 'Inherit from `%<prefer>s` instead of `%<current>s`.'
|
32
40
|
PREFERRED_BASE_CLASS = {
|
33
41
|
runtime_error: 'RuntimeError',
|
34
42
|
standard_error: 'StandardError'
|
@@ -47,6 +55,12 @@ module RuboCop
|
|
47
55
|
SystemExit
|
48
56
|
].freeze
|
49
57
|
|
58
|
+
def_node_matcher :class_new_call?, <<-PATTERN
|
59
|
+
(send
|
60
|
+
(const {cbase nil?} :Class) :new
|
61
|
+
$(const {cbase nil?} _))
|
62
|
+
PATTERN
|
63
|
+
|
50
64
|
def on_class(node)
|
51
65
|
return unless node.parent_class &&
|
52
66
|
illegal_class_name?(node.parent_class)
|
@@ -54,6 +68,13 @@ module RuboCop
|
|
54
68
|
add_offense(node.parent_class)
|
55
69
|
end
|
56
70
|
|
71
|
+
def on_send(node)
|
72
|
+
constant = class_new_call?(node)
|
73
|
+
return unless constant && illegal_class_name?(constant)
|
74
|
+
|
75
|
+
add_offense(constant)
|
76
|
+
end
|
77
|
+
|
57
78
|
def autocorrect(node)
|
58
79
|
lambda do |corrector|
|
59
80
|
corrector.replace(node.loc.expression, preferred_base_class)
|
@@ -18,7 +18,7 @@ module RuboCop
|
|
18
18
|
# foo = "something with #{interpolation} inside"
|
19
19
|
class InterpolationCheck < Cop
|
20
20
|
MSG = 'Interpolation in single quoted string detected. '\
|
21
|
-
'Use double quoted strings if you need interpolation.'
|
21
|
+
'Use double quoted strings if you need interpolation.'
|
22
22
|
|
23
23
|
def on_str(node)
|
24
24
|
return if heredoc?(node)
|
@@ -46,9 +46,9 @@ module RuboCop
|
|
46
46
|
include RangeHelp
|
47
47
|
|
48
48
|
MSG = 'Re-enable %<cop>s cop with `# rubocop:enable` after ' \
|
49
|
-
'disabling it.'
|
49
|
+
'disabling it.'
|
50
50
|
MSG_BOUND = 'Re-enable %<cop>s cop within %<max_range>s lines after ' \
|
51
|
-
'disabling it.'
|
51
|
+
'disabling it.'
|
52
52
|
|
53
53
|
def investigate(processed_source)
|
54
54
|
max_range = cop_config['MaximumRangeSize']
|
@@ -22,7 +22,7 @@ module RuboCop
|
|
22
22
|
# x < y && y < z
|
23
23
|
# 10 <= x && x <= 20
|
24
24
|
class MultipleCompare < Cop
|
25
|
-
MSG = 'Use the `&&` operator to compare multiple values.'
|
25
|
+
MSG = 'Use the `&&` operator to compare multiple values.'
|
26
26
|
|
27
27
|
def_node_matcher :multiple_compare?, <<-PATTERN
|
28
28
|
(send (send _ {:< :> :<= :>=} $_) {:< :> :<= :>=} _)
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
include PercentLiteral
|
20
20
|
|
21
21
|
MSG = 'Within percent literals, nested percent literals do not ' \
|
22
|
-
'function and may be unwanted in the result.'
|
22
|
+
'function and may be unwanted in the result.'
|
23
23
|
|
24
24
|
# The array of regular expressions representing percent literals that,
|
25
25
|
# if found within a percent literal expression, will cause a
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
# acc + i
|
24
24
|
# end
|
25
25
|
class NextWithoutAccumulator < Cop
|
26
|
-
MSG = 'Use `next` with an accumulator argument in a `reduce`.'
|
26
|
+
MSG = 'Use `next` with an accumulator argument in a `reduce`.'
|
27
27
|
|
28
28
|
def_node_matcher :on_body_of_reduce, <<-PATTERN
|
29
29
|
(block (send _recv {:reduce :inject} !sym) _blockargs $(begin ...))
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
class NonLocalExitFromIterator < Cop
|
42
42
|
MSG = 'Non-local exit from iterator, without return value. ' \
|
43
43
|
'`next`, `break`, `Array#find`, `Array#any?`, etc. ' \
|
44
|
-
'is preferred.'
|
44
|
+
'is preferred.'
|
45
45
|
|
46
46
|
def on_return(return_node)
|
47
47
|
return if return_value?(return_node)
|
@@ -29,14 +29,20 @@ module RuboCop
|
|
29
29
|
MSG = 'Replace unsafe number conversion with number '\
|
30
30
|
'class parsing, instead of using '\
|
31
31
|
'%<number_object>s.%<to_method>s, use stricter '\
|
32
|
-
'%<corrected_method>s.'
|
32
|
+
'%<corrected_method>s.'
|
33
33
|
|
34
34
|
def_node_matcher :to_method, <<-PATTERN
|
35
35
|
(send $_ ${:to_i :to_f :to_c})
|
36
36
|
PATTERN
|
37
37
|
|
38
|
+
def_node_matcher :datetime?, <<-PATTERN
|
39
|
+
(send (const {nil? (cbase)} {:Time :DateTime}) ...)
|
40
|
+
PATTERN
|
41
|
+
|
38
42
|
def on_send(node)
|
39
43
|
to_method(node) do |receiver, to_method|
|
44
|
+
next if date_time_object?(receiver)
|
45
|
+
|
40
46
|
message = format(
|
41
47
|
MSG,
|
42
48
|
number_object: receiver.source,
|
@@ -49,6 +55,15 @@ module RuboCop
|
|
49
55
|
|
50
56
|
private
|
51
57
|
|
58
|
+
def date_time_object?(node)
|
59
|
+
child = node
|
60
|
+
while child.send_type?
|
61
|
+
return true if datetime? child
|
62
|
+
|
63
|
+
child = child.children[0]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
52
67
|
def correct_method(node, receiver)
|
53
68
|
format(CONVERSION_METHOD_CLASS_MAPPING[node.method_name],
|
54
69
|
number_object: receiver.source)
|
@@ -20,7 +20,7 @@ module RuboCop
|
|
20
20
|
class ParenthesesAsGroupedExpression < Cop
|
21
21
|
include RangeHelp
|
22
22
|
|
23
|
-
MSG = '`(...)` interpreted as grouped expression.'
|
23
|
+
MSG = '`(...)` interpreted as grouped expression.'
|
24
24
|
|
25
25
|
def on_send(node)
|
26
26
|
return unless node.arguments.one?
|
@@ -29,7 +29,7 @@ module RuboCop
|
|
29
29
|
return unless node.first_argument.source.start_with?('(')
|
30
30
|
|
31
31
|
space_length = spaces_before_left_parenthesis(node)
|
32
|
-
return unless space_length
|
32
|
+
return unless space_length.positive?
|
33
33
|
|
34
34
|
range = space_range(node.first_argument.source_range, space_length)
|
35
35
|
|
@@ -28,7 +28,7 @@ module RuboCop
|
|
28
28
|
TRAILING_QUOTE = /['"]?,?$/.freeze
|
29
29
|
|
30
30
|
MSG = "Within `%w`/`%W`, quotes and ',' are unnecessary and may be " \
|
31
|
-
'unwanted in the resulting strings.'
|
31
|
+
'unwanted in the resulting strings.'
|
32
32
|
|
33
33
|
def on_array(node)
|
34
34
|
process(node, '%w', '%W')
|
@@ -22,7 +22,7 @@ module RuboCop
|
|
22
22
|
# 0 # just use 0 instead
|
23
23
|
class RandOne < Cop
|
24
24
|
MSG = '`%<method>s` always returns `0`. ' \
|
25
|
-
'Perhaps you meant `rand(2)` or `rand`?'
|
25
|
+
'Perhaps you meant `rand(2)` or `rand`?'
|
26
26
|
|
27
27
|
def_node_matcher :rand_one?, <<-PATTERN
|
28
28
|
(send {(const nil? :Kernel) nil?} :rand {(int {-1 1}) (float {-1.0 1.0})})
|
@@ -29,8 +29,8 @@ module RuboCop
|
|
29
29
|
class RedundantWithIndex < Cop
|
30
30
|
include RangeHelp
|
31
31
|
|
32
|
-
MSG_EACH_WITH_INDEX = 'Use `each` instead of `each_with_index`.'
|
33
|
-
MSG_WITH_INDEX = 'Remove redundant `with_index`.'
|
32
|
+
MSG_EACH_WITH_INDEX = 'Use `each` instead of `each_with_index`.'
|
33
|
+
MSG_WITH_INDEX = 'Remove redundant `with_index`.'
|
34
34
|
|
35
35
|
def_node_matcher :redundant_with_index?, <<-PATTERN
|
36
36
|
(block
|
@@ -30,8 +30,8 @@ module RuboCop
|
|
30
30
|
include RangeHelp
|
31
31
|
|
32
32
|
MSG_EACH_WITH_OBJECT = 'Use `each` instead of `each_with_object`.'
|
33
|
-
|
34
|
-
MSG_WITH_OBJECT = 'Remove redundant `with_object`.'
|
33
|
+
|
34
|
+
MSG_WITH_OBJECT = 'Remove redundant `with_object`.'
|
35
35
|
|
36
36
|
def_node_matcher :redundant_with_object?, <<-PATTERN
|
37
37
|
(block
|
@@ -18,7 +18,7 @@ module RuboCop
|
|
18
18
|
# end
|
19
19
|
class RegexpAsCondition < Cop
|
20
20
|
MSG = 'Do not use regexp literal as a condition.' \
|
21
|
-
' The regexp literal matches `$_` implicitly.'
|
21
|
+
' The regexp literal matches `$_` implicitly.'
|
22
22
|
|
23
23
|
def on_match_current_line(node)
|
24
24
|
add_offense(node)
|
@@ -26,7 +26,7 @@ module RuboCop
|
|
26
26
|
# end
|
27
27
|
class RescueException < Cop
|
28
28
|
MSG = 'Avoid rescuing the `Exception` class. ' \
|
29
|
-
'Perhaps you meant to rescue `StandardError`?'
|
29
|
+
'Perhaps you meant to rescue `StandardError`?'
|
30
30
|
|
31
31
|
def on_resbody(node)
|
32
32
|
return unless node.children.first
|
@@ -38,7 +38,7 @@ module RuboCop
|
|
38
38
|
include RescueNode
|
39
39
|
|
40
40
|
MSG = 'Rescuing from `%<invalid_exceptions>s` will raise a ' \
|
41
|
-
'`TypeError` instead of catching the actual exception.'
|
41
|
+
'`TypeError` instead of catching the actual exception.'
|
42
42
|
INVALID_TYPES = %i[array dstr float hash nil int str sym].freeze
|
43
43
|
|
44
44
|
def on_resbody(node)
|
@@ -32,14 +32,14 @@ module RuboCop
|
|
32
32
|
# return
|
33
33
|
# end
|
34
34
|
class ReturnInVoidContext < Cop
|
35
|
-
MSG = 'Do not return a value in `%<method>s`.'
|
35
|
+
MSG = 'Do not return a value in `%<method>s`.'
|
36
36
|
|
37
37
|
def on_return(return_node)
|
38
38
|
return unless return_node.descendants.any?
|
39
39
|
|
40
40
|
context_node = non_void_context(return_node)
|
41
41
|
|
42
|
-
return unless context_node
|
42
|
+
return unless context_node&.def_type?
|
43
43
|
|
44
44
|
method_name = method_name(context_node)
|
45
45
|
|
@@ -25,10 +25,9 @@ module RuboCop
|
|
25
25
|
# x&.foo || bar
|
26
26
|
class SafeNavigationChain < Cop
|
27
27
|
include NilMethods
|
28
|
-
extend TargetRubyVersion
|
29
28
|
|
30
29
|
MSG = 'Do not chain ordinary method call' \
|
31
|
-
' after safe navigation operator.'
|
30
|
+
' after safe navigation operator.'
|
32
31
|
|
33
32
|
def_node_matcher :bad_method?, <<-PATTERN
|
34
33
|
{
|
@@ -37,8 +36,6 @@ module RuboCop
|
|
37
36
|
}
|
38
37
|
PATTERN
|
39
38
|
|
40
|
-
minimum_target_ruby_version 2.3
|
41
|
-
|
42
39
|
def on_send(node)
|
43
40
|
bad_method?(node) do |safe_nav, method|
|
44
41
|
return if nil_methods.include?(method)
|