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
@@ -53,7 +53,7 @@ module RuboCop
|
|
53
53
|
# # good
|
54
54
|
# delegate :bar, to: :foo, prefix: true
|
55
55
|
class Delegate < Cop
|
56
|
-
MSG = 'Use `delegate` to define delegations.'
|
56
|
+
MSG = 'Use `delegate` to define delegations.'
|
57
57
|
|
58
58
|
def_node_matcher :delegate?, <<-PATTERN
|
59
59
|
(def _method_name _args
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
# # good
|
15
15
|
# delegate :foo, to: :bar, allow_nil: true
|
16
16
|
class DelegateAllowBlank < Cop
|
17
|
-
MSG = '`allow_blank` is not a valid option, use `allow_nil`.'
|
17
|
+
MSG = '`allow_blank` is not a valid option, use `allow_nil`.'
|
18
18
|
|
19
19
|
def_node_matcher :allow_blank_option, <<-PATTERN
|
20
20
|
(send nil? :delegate _ (hash <$(pair (sym :allow_blank) true) ...>))
|
@@ -26,7 +26,7 @@ module RuboCop
|
|
26
26
|
# # good
|
27
27
|
# User.find_by!(email: email)
|
28
28
|
class DynamicFindBy < Cop
|
29
|
-
MSG = 'Use `%<static_name>s` instead of dynamic `%<method>s`.'
|
29
|
+
MSG = 'Use `%<static_name>s` instead of dynamic `%<method>s`.'
|
30
30
|
METHOD_PATTERN = /^find_by_(.+?)(!)?$/.freeze
|
31
31
|
|
32
32
|
def on_send(node)
|
@@ -21,7 +21,7 @@ module RuboCop
|
|
21
21
|
include Duplication
|
22
22
|
|
23
23
|
MSG = 'Duplicate value `%<value>s` found in `%<enum>s` ' \
|
24
|
-
'enum declaration.'
|
24
|
+
'enum declaration.'
|
25
25
|
|
26
26
|
def_node_matcher :enum_declaration, <<-PATTERN
|
27
27
|
(send nil? :enum (hash (pair (_ $_) ${array hash})))
|
@@ -16,10 +16,10 @@ module RuboCop
|
|
16
16
|
# # good
|
17
17
|
# Rails.env.production?
|
18
18
|
class EnvironmentComparison < Cop
|
19
|
-
MSG = "Favor `Rails.env.%<env>s?` over `Rails.env == '%<env>s'`."
|
19
|
+
MSG = "Favor `Rails.env.%<env>s?` over `Rails.env == '%<env>s'`."
|
20
20
|
|
21
21
|
SYM_MSG = 'Do not compare `Rails.env` with a symbol, it will always ' \
|
22
|
-
'evaluate to `false`.'
|
22
|
+
'evaluate to `false`.'
|
23
23
|
|
24
24
|
def_node_matcher :environment_str_comparison?, <<-PATTERN
|
25
25
|
(send
|
@@ -26,7 +26,7 @@ module RuboCop
|
|
26
26
|
class Exit < Cop
|
27
27
|
include ConfigurableEnforcedStyle
|
28
28
|
|
29
|
-
MSG = 'Do not use `exit` in Rails applications.'
|
29
|
+
MSG = 'Do not use `exit` in Rails applications.'
|
30
30
|
TARGET_METHODS = %i[exit exit!].freeze
|
31
31
|
EXPLICIT_RECEIVERS = %i[Kernel Process].freeze
|
32
32
|
|
@@ -30,9 +30,9 @@ module RuboCop
|
|
30
30
|
include RangeHelp
|
31
31
|
|
32
32
|
MSG_SLASHES = 'Please use `Rails.root.join(\'path/to\')` ' \
|
33
|
-
'instead.'
|
33
|
+
'instead.'
|
34
34
|
MSG_ARGUMENTS = 'Please use `Rails.root.join(\'path\', \'to\')` ' \
|
35
|
-
'instead.'
|
35
|
+
'instead.'
|
36
36
|
|
37
37
|
def_node_matcher :file_join_nodes?, <<-PATTERN
|
38
38
|
(send (const nil? :File) :join ...)
|
@@ -16,7 +16,7 @@ module RuboCop
|
|
16
16
|
class FindBy < Cop
|
17
17
|
include RangeHelp
|
18
18
|
|
19
|
-
MSG = 'Use `find_by` instead of `where.%<method>s`.'
|
19
|
+
MSG = 'Use `find_by` instead of `where.%<method>s`.'
|
20
20
|
TARGET_SELECTORS = %i[first take].freeze
|
21
21
|
|
22
22
|
def_node_matcher :where_first?, <<-PATTERN
|
@@ -13,7 +13,7 @@ module RuboCop
|
|
13
13
|
# # good
|
14
14
|
# User.all.find_each
|
15
15
|
class FindEach < Cop
|
16
|
-
MSG = 'Use `find_each` instead of `each`.'
|
16
|
+
MSG = 'Use `find_each` instead of `each`.'
|
17
17
|
|
18
18
|
SCOPE_METHODS = %i[
|
19
19
|
all eager_load includes joins left_joins left_outer_joins not preload
|
@@ -22,8 +22,7 @@ module RuboCop
|
|
22
22
|
IGNORED_METHODS = %i[order limit select].freeze
|
23
23
|
|
24
24
|
def on_send(node)
|
25
|
-
return unless node.receiver &&
|
26
|
-
node.receiver.send_type? &&
|
25
|
+
return unless node.receiver&.send_type? &&
|
27
26
|
node.method?(:each)
|
28
27
|
|
29
28
|
return unless SCOPE_METHODS.include?(node.receiver.method_name)
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
12
12
|
# # good
|
13
13
|
# # has_many :ingredients, through: :recipe_ingredients
|
14
14
|
class HasAndBelongsToMany < Cop
|
15
|
-
MSG = 'Prefer `has_many :through` to `has_and_belongs_to_many`.'
|
15
|
+
MSG = 'Prefer `has_many :through` to `has_and_belongs_to_many`.'
|
16
16
|
|
17
17
|
def on_send(node)
|
18
18
|
return unless node.command?(:has_and_belongs_to_many)
|
@@ -21,7 +21,7 @@ module RuboCop
|
|
21
21
|
# has_many :patients, through: :appointments
|
22
22
|
# end
|
23
23
|
class HasManyOrHasOneDependent < Cop
|
24
|
-
MSG = 'Specify a `:dependent` option.'
|
24
|
+
MSG = 'Specify a `:dependent` option.'
|
25
25
|
|
26
26
|
def_node_search :active_resource_class?, <<-PATTERN
|
27
27
|
(const (const nil? :ActiveResource) :Base)
|
@@ -20,7 +20,7 @@ module RuboCop
|
|
20
20
|
extend TargetRailsVersion
|
21
21
|
|
22
22
|
MSG = 'Use keyword arguments instead of ' \
|
23
|
-
'positional arguments for http call: `%<verb>s`.'
|
23
|
+
'positional arguments for http call: `%<verb>s`.'
|
24
24
|
KEYWORD_ARGS = %i[
|
25
25
|
method params session body flash xhr as headers env
|
26
26
|
].freeze
|
@@ -89,9 +89,9 @@ module RuboCop
|
|
89
89
|
# :nodoc:
|
90
90
|
class SymbolicStyleChecker
|
91
91
|
MSG = 'Prefer `%<prefer>s` over `%<current>s` ' \
|
92
|
-
'to define HTTP status code.'
|
92
|
+
'to define HTTP status code.'
|
93
93
|
DEFAULT_MSG = 'Prefer `symbolic` over `numeric` ' \
|
94
|
-
'to define HTTP status code.'
|
94
|
+
'to define HTTP status code.'
|
95
95
|
|
96
96
|
attr_reader :node
|
97
97
|
def initialize(node)
|
@@ -133,9 +133,9 @@ module RuboCop
|
|
133
133
|
# :nodoc:
|
134
134
|
class NumericStyleChecker
|
135
135
|
MSG = 'Prefer `%<prefer>s` over `%<current>s` ' \
|
136
|
-
'to define HTTP status code.'
|
136
|
+
'to define HTTP status code.'
|
137
137
|
DEFAULT_MSG = 'Prefer `numeric` over `symbolic` ' \
|
138
|
-
'to define HTTP status code.'
|
138
|
+
'to define HTTP status code.'
|
139
139
|
PERMITTED_STATUS = %i[error success missing redirect].freeze
|
140
140
|
|
141
141
|
attr_reader :node
|
@@ -38,7 +38,7 @@ module RuboCop
|
|
38
38
|
#
|
39
39
|
# @see https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options
|
40
40
|
class IgnoredSkipActionFilterOption < Cop
|
41
|
-
MSG =
|
41
|
+
MSG = <<~MSG.chomp.freeze
|
42
42
|
`%<ignore>s` option will be ignored when `%<prefer>s` and `%<ignore>s` are used together.
|
43
43
|
MSG
|
44
44
|
|
@@ -133,9 +133,9 @@ module RuboCop
|
|
133
133
|
|
134
134
|
minimum_target_rails_version 4.1
|
135
135
|
|
136
|
-
SPECIFY_MSG = 'Specify an `:inverse_of` option.'
|
136
|
+
SPECIFY_MSG = 'Specify an `:inverse_of` option.'
|
137
137
|
NIL_MSG = 'You specified `inverse_of: nil`, you probably meant to ' \
|
138
|
-
'use `inverse_of: false`.'
|
138
|
+
'use `inverse_of: false`.'
|
139
139
|
|
140
140
|
def_node_matcher :association_recv_arguments, <<-PATTERN
|
141
141
|
(send $_ {:has_many :has_one :belongs_to} _ $...)
|
@@ -8,14 +8,20 @@ module RuboCop
|
|
8
8
|
# risk as the loaded page will have control over the previous page
|
9
9
|
# and could change its location for phishing purposes.
|
10
10
|
#
|
11
|
+
# The option `rel: 'noreferrer'` also blocks this behavior
|
12
|
+
# and removes the http-referrer header.
|
13
|
+
#
|
11
14
|
# @example
|
12
15
|
# # bad
|
13
16
|
# link_to 'Click here', url, target: '_blank'
|
14
17
|
#
|
15
18
|
# # good
|
16
19
|
# link_to 'Click here', url, target: '_blank', rel: 'noopener'
|
20
|
+
#
|
21
|
+
# # good
|
22
|
+
# link_to 'Click here', url, target: '_blank', rel: 'noreferrer'
|
17
23
|
class LinkToBlank < Cop
|
18
|
-
MSG = 'Specify a `:rel` option containing noopener.'
|
24
|
+
MSG = 'Specify a `:rel` option containing noopener.'
|
19
25
|
|
20
26
|
def_node_matcher :blank_target?, <<-PATTERN
|
21
27
|
(pair {(sym :target) (str "target")} {(str "_blank") (sym :_blank)})
|
@@ -83,7 +89,8 @@ module RuboCop
|
|
83
89
|
def contains_noopener?(value)
|
84
90
|
return false unless value
|
85
91
|
|
86
|
-
value.to_s.split(' ')
|
92
|
+
rel_array = value.to_s.split(' ')
|
93
|
+
rel_array.include?('noopener') || rel_array.include?('noreferrer')
|
87
94
|
end
|
88
95
|
end
|
89
96
|
end
|
@@ -17,7 +17,7 @@ module RuboCop
|
|
17
17
|
# add_reference :products, :category
|
18
18
|
# add_reference :products, :category, null: false, default: 1
|
19
19
|
class NotNullColumn < Cop
|
20
|
-
MSG = 'Do not add a NOT NULL column without a default value.'
|
20
|
+
MSG = 'Do not add a NOT NULL column without a default value.'
|
21
21
|
|
22
22
|
def_node_matcher :add_not_null_column?, <<-PATTERN
|
23
23
|
(send nil? :add_column _ _ _ (hash $...))
|
@@ -15,7 +15,7 @@ module RuboCop
|
|
15
15
|
# Rails.logger.debug 'A debug message'
|
16
16
|
class Output < Cop
|
17
17
|
MSG = 'Do not write to stdout. ' \
|
18
|
-
"Use Rails's logger if you want to log."
|
18
|
+
"Use Rails's logger if you want to log."
|
19
19
|
|
20
20
|
def_node_matcher :output?, <<-PATTERN
|
21
21
|
(send nil? {:ap :p :pp :pretty_print :print :puts} ...)
|
@@ -63,7 +63,7 @@ module RuboCop
|
|
63
63
|
# # => ActiveSupport::SafeBuffer
|
64
64
|
# # "<b>hi</b> <span><b>hi</b></span>"
|
65
65
|
class OutputSafety < Cop
|
66
|
-
MSG = 'Tagging a string as html safe may be a security risk.'
|
66
|
+
MSG = 'Tagging a string as html safe may be a security risk.'
|
67
67
|
|
68
68
|
def on_send(node)
|
69
69
|
return if non_interpolated_string?(node)
|
@@ -79,7 +79,7 @@ module RuboCop
|
|
79
79
|
private
|
80
80
|
|
81
81
|
def non_interpolated_string?(node)
|
82
|
-
node.receiver
|
82
|
+
node.receiver&.str_type? && !node.receiver.dstr_type?
|
83
83
|
end
|
84
84
|
|
85
85
|
def looks_like_rails_html_safe?(node)
|
@@ -26,7 +26,7 @@ module RuboCop
|
|
26
26
|
|
27
27
|
PLURAL_DURATION_METHODS = SINGULAR_DURATION_METHODS.invert.freeze
|
28
28
|
|
29
|
-
MSG = 'Prefer `%<number>s.%<correct>s`.'
|
29
|
+
MSG = 'Prefer `%<number>s.%<correct>s`.'
|
30
30
|
|
31
31
|
def on_send(node)
|
32
32
|
return unless duration_method?(node.method_name)
|
@@ -44,11 +44,11 @@ module RuboCop
|
|
44
44
|
# # good
|
45
45
|
# something if foo.present?
|
46
46
|
class Present < Cop
|
47
|
-
MSG_NOT_BLANK = 'Use `%<prefer>s` instead of `%<current>s`.'
|
47
|
+
MSG_NOT_BLANK = 'Use `%<prefer>s` instead of `%<current>s`.'
|
48
48
|
MSG_EXISTS_AND_NOT_EMPTY = 'Use `%<prefer>s` instead of ' \
|
49
|
-
'`%<current>s`.'
|
49
|
+
'`%<current>s`.'
|
50
50
|
MSG_UNLESS_BLANK = 'Use `if %<prefer>s` instead of ' \
|
51
|
-
'`%<current>s`.'
|
51
|
+
'`%<current>s`.'
|
52
52
|
|
53
53
|
def_node_matcher :exists_and_not_empty?, <<-PATTERN
|
54
54
|
(and
|
@@ -24,7 +24,7 @@ module RuboCop
|
|
24
24
|
# x = self[:attr]
|
25
25
|
# self[:attr] = val
|
26
26
|
class ReadWriteAttribute < Cop
|
27
|
-
MSG = 'Prefer `%<prefer>s` over `%<current>s`.'
|
27
|
+
MSG = 'Prefer `%<prefer>s` over `%<current>s`.'
|
28
28
|
|
29
29
|
def_node_matcher :read_write_attribute?, <<-PATTERN
|
30
30
|
{
|
@@ -31,9 +31,9 @@ module RuboCop
|
|
31
31
|
|
32
32
|
MSG_SAME =
|
33
33
|
'`allow_nil` is redundant when `allow_blank` has the same value.'
|
34
|
-
|
34
|
+
|
35
35
|
MSG_ALLOW_NIL_FALSE =
|
36
|
-
'`allow_nil: false` is redundant when `allow_blank` is true.'
|
36
|
+
'`allow_nil: false` is redundant when `allow_blank` is true.'
|
37
37
|
|
38
38
|
def on_send(node)
|
39
39
|
return unless node.method_name == :validates
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
# # good
|
15
15
|
# has_many :accounts, class_name: 'Account'
|
16
16
|
class ReflectionClassName < Cop
|
17
|
-
MSG = 'Use a string value for `class_name`.'
|
17
|
+
MSG = 'Use a string value for `class_name`.'
|
18
18
|
|
19
19
|
def_node_matcher :association_with_reflection, <<-PATTERN
|
20
20
|
(send nil? {:has_many :has_one :belongs_to} _
|
@@ -18,7 +18,7 @@ module RuboCop
|
|
18
18
|
# assert_not_equal true, false
|
19
19
|
#
|
20
20
|
class RefuteMethods < Cop
|
21
|
-
MSG = 'Prefer `%<assert_method>s` over `%<refute_method>s`.'
|
21
|
+
MSG = 'Prefer `%<assert_method>s` over `%<refute_method>s`.'
|
22
22
|
|
23
23
|
CORRECTIONS = {
|
24
24
|
refute: 'assert_not',
|
@@ -22,7 +22,7 @@ module RuboCop
|
|
22
22
|
include RangeHelp
|
23
23
|
|
24
24
|
MSG = 'Do not assign %<method_name>s to constants as it ' \
|
25
|
-
'will be evaluated only once.'
|
25
|
+
'will be evaluated only once.'
|
26
26
|
|
27
27
|
def on_casgn(node)
|
28
28
|
relative_date_assignment?(node) do |method_name|
|
@@ -33,7 +33,7 @@ module RuboCop
|
|
33
33
|
def on_masgn(node)
|
34
34
|
lhs, rhs = *node
|
35
35
|
|
36
|
-
return unless rhs
|
36
|
+
return unless rhs&.array_type?
|
37
37
|
|
38
38
|
lhs.children.zip(rhs.children).each do |(name, value)|
|
39
39
|
next unless name.casgn_type?
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
include ConfigurableEnforcedStyle
|
24
24
|
|
25
25
|
MSG = 'Use `request.%<prefer>s` instead of ' \
|
26
|
-
'`request.%<current>s`.'
|
26
|
+
'`request.%<current>s`.'
|
27
27
|
|
28
28
|
def_node_matcher :referer?, <<-PATTERN
|
29
29
|
(send (send nil? :request) {:referer :referrer})
|
@@ -126,7 +126,7 @@ module RuboCop
|
|
126
126
|
#
|
127
127
|
# @see https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html
|
128
128
|
class ReversibleMigration < Cop
|
129
|
-
MSG = '%<action>s is not reversible.'
|
129
|
+
MSG = '%<action>s is not reversible.'
|
130
130
|
IRREVERSIBLE_CHANGE_TABLE_CALLS = %i[
|
131
131
|
change change_default remove
|
132
132
|
].freeze
|
@@ -140,7 +140,7 @@ module RuboCop
|
|
140
140
|
PATTERN
|
141
141
|
|
142
142
|
def_node_matcher :change_column_default_call, <<-PATTERN
|
143
|
-
(send nil? :change_column_default _ _ $...)
|
143
|
+
(send nil? :change_column_default {[(sym _) (sym _)] (splat _)} $...)
|
144
144
|
PATTERN
|
145
145
|
|
146
146
|
def_node_matcher :remove_column_call, <<-PATTERN
|
@@ -195,7 +195,7 @@ module RuboCop
|
|
195
195
|
|
196
196
|
def check_change_column_default_node(node)
|
197
197
|
change_column_default_call(node) do |args|
|
198
|
-
unless all_hash_key?(args.
|
198
|
+
unless all_hash_key?(args.last, :from, :to)
|
199
199
|
add_offense(
|
200
200
|
node,
|
201
201
|
message: format(
|
@@ -272,7 +272,7 @@ module RuboCop
|
|
272
272
|
end
|
273
273
|
|
274
274
|
def all_hash_key?(args, *keys)
|
275
|
-
return false unless args
|
275
|
+
return false unless args&.hash_type?
|
276
276
|
|
277
277
|
hash_keys = args.keys.map do |key|
|
278
278
|
key.children.first.to_sym
|
@@ -4,8 +4,7 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module Rails
|
6
6
|
# This cop converts usages of `try!` to `&.`. It can also be configured
|
7
|
-
# to convert `try`. It will convert code to use safe navigation
|
8
|
-
# target Ruby version is set to 2.3+
|
7
|
+
# to convert `try`. It will convert code to use safe navigation.
|
9
8
|
#
|
10
9
|
# @example
|
11
10
|
# # ConvertTry: false
|
@@ -40,17 +39,14 @@ module RuboCop
|
|
40
39
|
# foo&.bar(baz)
|
41
40
|
# foo&.bar { |e| e.baz }
|
42
41
|
class SafeNavigation < Cop
|
43
|
-
extend TargetRubyVersion
|
44
42
|
include RangeHelp
|
45
43
|
|
46
|
-
MSG = 'Use safe navigation (`&.`) instead of `%<try>s`.'
|
44
|
+
MSG = 'Use safe navigation (`&.`) instead of `%<try>s`.'
|
47
45
|
|
48
46
|
def_node_matcher :try_call, <<-PATTERN
|
49
47
|
(send !nil? ${:try :try!} $_ ...)
|
50
48
|
PATTERN
|
51
49
|
|
52
|
-
minimum_target_ruby_version 2.3
|
53
|
-
|
54
50
|
def on_send(node)
|
55
51
|
try_call(node) do |try_method, dispatch|
|
56
52
|
return if try_method == :try && !cop_config['ConvertTry']
|
@@ -100,12 +100,12 @@ module RuboCop
|
|
100
100
|
include NegativeConditional
|
101
101
|
|
102
102
|
MSG = 'Use `%<prefer>s` instead of `%<current>s` if the return ' \
|
103
|
-
'value is not checked.'
|
103
|
+
'value is not checked.'
|
104
104
|
CREATE_MSG = (MSG +
|
105
105
|
' Or check `persisted?` on model returned from ' \
|
106
106
|
'`%<current>s`.').freeze
|
107
107
|
CREATE_CONDITIONAL_MSG = '`%<current>s` returns a model which is ' \
|
108
|
-
'always truthy.'
|
108
|
+
'always truthy.'
|
109
109
|
|
110
110
|
CREATE_PERSIST_METHODS = %i[create
|
111
111
|
first_or_create find_or_create_by].freeze
|
@@ -129,7 +129,7 @@ module RuboCop
|
|
129
129
|
def check_assignment(assignment)
|
130
130
|
node = right_assignment_node(assignment)
|
131
131
|
|
132
|
-
return unless node
|
132
|
+
return unless node&.send_type?
|
133
133
|
return unless persist_method?(node, CREATE_PERSIST_METHODS)
|
134
134
|
return if persisted_referenced?(assignment)
|
135
135
|
|
@@ -167,7 +167,7 @@ module RuboCop
|
|
167
167
|
def right_assignment_node(assignment)
|
168
168
|
node = assignment.node.child_nodes.first
|
169
169
|
|
170
|
-
return node unless node
|
170
|
+
return node unless node&.block_type?
|
171
171
|
|
172
172
|
node.send_node
|
173
173
|
end
|
@@ -195,17 +195,17 @@ module RuboCop
|
|
195
195
|
|
196
196
|
def hash_parent(node)
|
197
197
|
pair = node.parent
|
198
|
-
return unless pair
|
198
|
+
return unless pair&.pair_type?
|
199
199
|
|
200
200
|
hash = pair.parent
|
201
|
-
return unless hash
|
201
|
+
return unless hash&.hash_type?
|
202
202
|
|
203
203
|
hash
|
204
204
|
end
|
205
205
|
|
206
206
|
def array_parent(node)
|
207
207
|
array = node.parent
|
208
|
-
return unless array
|
208
|
+
return unless array&.array_type?
|
209
209
|
|
210
210
|
array
|
211
211
|
end
|
@@ -293,7 +293,7 @@ module RuboCop
|
|
293
293
|
|
294
294
|
def return_value_assigned?(node)
|
295
295
|
assignment = assignable_node(node).parent
|
296
|
-
assignment
|
296
|
+
assignment&.lvasgn_type?
|
297
297
|
end
|
298
298
|
|
299
299
|
def persist_method?(node, methods = PERSIST_METHODS)
|