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
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
# # good
|
15
15
|
# scope :something, -> { where(something: true) }
|
16
16
|
class ScopeArgs < Cop
|
17
|
-
MSG = 'Use `lambda`/`proc` instead of a plain method call.'
|
17
|
+
MSG = 'Use `lambda`/`proc` instead of a plain method call.'
|
18
18
|
|
19
19
|
def_node_matcher :scope?, '(send nil? :scope _ $send)'
|
20
20
|
|
@@ -36,7 +36,7 @@ module RuboCop
|
|
36
36
|
# user.touch
|
37
37
|
#
|
38
38
|
class SkipsModelValidations < Cop
|
39
|
-
MSG = 'Avoid using `%<method>s` because it skips validations.'
|
39
|
+
MSG = 'Avoid using `%<method>s` because it skips validations.'
|
40
40
|
|
41
41
|
METHODS_WITH_ARGUMENTS = %w[decrement!
|
42
42
|
decrement_counter
|
@@ -6,7 +6,7 @@ module RuboCop
|
|
6
6
|
# This cop checks for the use of Time methods without zone.
|
7
7
|
#
|
8
8
|
# Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time)
|
9
|
-
# and the article http://danilenko.org/2012/7/6/rails_timezones/
|
9
|
+
# and the article http://danilenko.org/2012/7/6/rails_timezones/
|
10
10
|
#
|
11
11
|
# Two styles are supported for this cop. When EnforcedStyle is 'strict'
|
12
12
|
# then only use of Time.zone is allowed.
|
@@ -47,52 +47,69 @@ module RuboCop
|
|
47
47
|
include ConfigurableEnforcedStyle
|
48
48
|
|
49
49
|
MSG = 'Do not use `%<current>s` without zone. Use `%<prefer>s` ' \
|
50
|
-
'instead.'
|
50
|
+
'instead.'
|
51
51
|
|
52
52
|
MSG_ACCEPTABLE = 'Do not use `%<current>s` without zone. ' \
|
53
|
-
'Use one of %<prefer>s instead.'
|
53
|
+
'Use one of %<prefer>s instead.'
|
54
54
|
|
55
55
|
MSG_LOCALTIME = 'Do not use `Time.localtime` without ' \
|
56
|
-
'offset or zone.'
|
56
|
+
'offset or zone.'
|
57
57
|
|
58
|
-
|
59
|
-
'instead.'.freeze
|
60
|
-
|
61
|
-
TIMECLASS = %i[Time DateTime].freeze
|
58
|
+
TIMECLASSES = %i[Time DateTime].freeze
|
62
59
|
|
63
60
|
GOOD_METHODS = %i[zone zone_default find_zone find_zone!].freeze
|
64
61
|
|
65
|
-
DANGEROUS_METHODS = %i[now local new
|
66
|
-
parse at current].freeze
|
62
|
+
DANGEROUS_METHODS = %i[now local new parse at current].freeze
|
67
63
|
|
68
|
-
ACCEPTED_METHODS = %i[in_time_zone utc getlocal
|
69
|
-
|
70
|
-
httpdate to_i to_f].freeze
|
64
|
+
ACCEPTED_METHODS = %i[in_time_zone utc getlocal xmlschema iso8601
|
65
|
+
jisx0301 rfc3339 httpdate to_i to_f].freeze
|
71
66
|
|
72
67
|
def on_const(node)
|
73
68
|
mod, klass = *node
|
74
|
-
# we should only check core
|
75
|
-
# (`DateTime
|
69
|
+
# we should only check core classes
|
70
|
+
# (`DateTime`, `Time`, `::DateTime` or `::Time`)
|
76
71
|
return unless (mod.nil? || mod.cbase_type?) && method_send?(node)
|
77
72
|
|
78
|
-
check_time_node(klass, node.parent) if
|
73
|
+
check_time_node(klass, node.parent) if TIMECLASSES.include?(klass)
|
79
74
|
end
|
80
75
|
|
81
76
|
def autocorrect(node)
|
82
77
|
lambda do |corrector|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
78
|
+
# add `.zone`: `Time.at` => `Time.zone.at`
|
79
|
+
corrector.insert_after(node.children[0].source_range, '.zone')
|
80
|
+
# replace `Time.zone.current` => `Time.zone.now`
|
81
|
+
if node.method_name == :current
|
82
|
+
corrector.replace(node.loc.selector, 'now')
|
83
|
+
end
|
84
|
+
# prefer `Time` over `DateTime` class
|
85
|
+
if strict?
|
86
|
+
corrector.replace(node.children.first.source_range, 'Time')
|
87
87
|
end
|
88
|
+
remove_redundant_in_time_zone(corrector, node)
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
92
|
private
|
92
93
|
|
94
|
+
# remove redundant `.in_time_zone` from `Time.zone.now.in_time_zone`
|
95
|
+
def remove_redundant_in_time_zone(corrector, node)
|
96
|
+
time_methods_called = extract_method_chain(node)
|
97
|
+
return unless time_methods_called.include?(:in_time_zone) ||
|
98
|
+
time_methods_called.include?(:zone)
|
99
|
+
|
100
|
+
while node&.send_type?
|
101
|
+
if node.children.last == :in_time_zone
|
102
|
+
in_time_zone_with_dot =
|
103
|
+
node.loc.selector.adjust(begin_pos: -1)
|
104
|
+
corrector.remove(in_time_zone_with_dot)
|
105
|
+
end
|
106
|
+
node = node.parent
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
93
110
|
def check_time_node(klass, node)
|
94
111
|
chain = extract_method_chain(node)
|
95
|
-
return if
|
112
|
+
return if not_danger_chain?(chain)
|
96
113
|
|
97
114
|
return check_localtime(node) if need_check_localtime?(chain)
|
98
115
|
|
@@ -105,17 +122,13 @@ module RuboCop
|
|
105
122
|
add_offense(node, location: :selector, message: message)
|
106
123
|
end
|
107
124
|
|
108
|
-
# rubocop:disable Metrics/MethodLength
|
109
125
|
def build_message(klass, method_name, node)
|
110
|
-
if
|
126
|
+
if flexible?
|
111
127
|
format(
|
112
128
|
MSG_ACCEPTABLE,
|
113
129
|
current: "#{klass}.#{method_name}",
|
114
130
|
prefer: acceptable_methods(klass, method_name, node).join(', ')
|
115
131
|
)
|
116
|
-
elsif method_name == 'current'
|
117
|
-
format(MSG_CURRENT,
|
118
|
-
current: "#{klass}.#{method_name}")
|
119
132
|
else
|
120
133
|
safe_method_name = safe_method(method_name, node)
|
121
134
|
format(MSG,
|
@@ -123,7 +136,6 @@ module RuboCop
|
|
123
136
|
prefer: "Time.zone.#{safe_method_name}")
|
124
137
|
end
|
125
138
|
end
|
126
|
-
# rubocop:enable Metrics/MethodLength
|
127
139
|
|
128
140
|
def extract_method_chain(node)
|
129
141
|
chain = []
|
@@ -141,32 +153,30 @@ module RuboCop
|
|
141
153
|
if (receiver.is_a? RuboCop::AST::Node) && !receiver.cbase_type?
|
142
154
|
method_from_time_class?(receiver)
|
143
155
|
else
|
144
|
-
|
156
|
+
TIMECLASSES.include?(method_name)
|
145
157
|
end
|
146
158
|
end
|
147
159
|
|
148
160
|
# checks that parent node of send_type
|
149
161
|
# and receiver is the given node
|
150
162
|
def method_send?(node)
|
151
|
-
return false unless node.parent
|
163
|
+
return false unless node.parent&.send_type?
|
152
164
|
|
153
165
|
node.parent.receiver == node
|
154
166
|
end
|
155
167
|
|
156
168
|
def safe_method(method_name, node)
|
157
|
-
|
158
|
-
|
159
|
-
if node.arguments?
|
160
|
-
'local'
|
169
|
+
if %w[new current].include?(method_name)
|
170
|
+
node.arguments? ? 'local' : 'now'
|
161
171
|
else
|
162
|
-
|
172
|
+
method_name
|
163
173
|
end
|
164
174
|
end
|
165
175
|
|
166
176
|
def check_localtime(node)
|
167
177
|
selector_node = node
|
168
178
|
|
169
|
-
while node
|
179
|
+
while node&.send_type?
|
170
180
|
break if node.method_name == :localtime
|
171
181
|
|
172
182
|
node = node.parent
|
@@ -178,20 +188,24 @@ module RuboCop
|
|
178
188
|
location: :selector, message: MSG_LOCALTIME)
|
179
189
|
end
|
180
190
|
|
181
|
-
def
|
191
|
+
def not_danger_chain?(chain)
|
182
192
|
(chain & DANGEROUS_METHODS).empty? || !(chain & good_methods).empty?
|
183
193
|
end
|
184
194
|
|
185
195
|
def need_check_localtime?(chain)
|
186
|
-
|
196
|
+
flexible? && chain.include?(:localtime)
|
187
197
|
end
|
188
198
|
|
189
|
-
def
|
199
|
+
def flexible?
|
190
200
|
style == :flexible
|
191
201
|
end
|
192
202
|
|
203
|
+
def strict?
|
204
|
+
style == :strict
|
205
|
+
end
|
206
|
+
|
193
207
|
def good_methods
|
194
|
-
if
|
208
|
+
if strict?
|
195
209
|
GOOD_METHODS
|
196
210
|
else
|
197
211
|
GOOD_METHODS + [:current] + ACCEPTED_METHODS
|
@@ -46,10 +46,10 @@ module RuboCop
|
|
46
46
|
include ConfigurableEnforcedStyle
|
47
47
|
include RangeHelp
|
48
48
|
|
49
|
-
MSG = 'Use `%<method>s` before `pluck`.'
|
50
|
-
NEWLINE = "\n"
|
49
|
+
MSG = 'Use `%<method>s` before `pluck`.'
|
50
|
+
NEWLINE = "\n"
|
51
51
|
PATTERN = '[!^block (send (send %<type>s :pluck ...) ' \
|
52
|
-
'${:uniq :distinct} ...)]'
|
52
|
+
'${:uniq :distinct} ...)]'
|
53
53
|
|
54
54
|
def_node_matcher :conservative_node_match,
|
55
55
|
format(PATTERN, type: 'const')
|
@@ -15,9 +15,9 @@ module RuboCop
|
|
15
15
|
class UnknownEnv < Cop
|
16
16
|
include NameSimilarity
|
17
17
|
|
18
|
-
MSG = 'Unknown environment `%<name>s`.'
|
18
|
+
MSG = 'Unknown environment `%<name>s`.'
|
19
19
|
MSG_SIMILAR = 'Unknown environment `%<name>s`. ' \
|
20
|
-
'Did you mean `%<similar>s`?'
|
20
|
+
'Did you mean `%<similar>s`?'
|
21
21
|
|
22
22
|
def_node_matcher :unknown_environment?, <<-PATTERN
|
23
23
|
(send
|
data/lib/rubocop/cop/registry.rb
CHANGED
@@ -6,7 +6,7 @@ module RuboCop
|
|
6
6
|
# refer to two or more cops under different departments
|
7
7
|
class AmbiguousCopName < RuboCop::Error
|
8
8
|
MSG = 'Ambiguous cop name `%<name>s` used in %<origin>s needs ' \
|
9
|
-
'department qualifier. Did you mean %<options>s?'
|
9
|
+
'department qualifier. Did you mean %<options>s?'
|
10
10
|
|
11
11
|
def initialize(name, origin, badges)
|
12
12
|
super(
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
12
12
|
# eval(something)
|
13
13
|
# binding.eval(something)
|
14
14
|
class Eval < Cop
|
15
|
-
MSG = 'The use of `eval` is a serious security risk.'
|
15
|
+
MSG = 'The use of `eval` is a serious security risk.'
|
16
16
|
|
17
17
|
def_node_matcher :eval?, <<-PATTERN
|
18
18
|
(send {nil? (send nil? :binding)} :eval $!str ...)
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
# JSON.parse("{}")
|
24
24
|
#
|
25
25
|
class JSONLoad < Cop
|
26
|
-
MSG = 'Prefer `JSON.parse` over `JSON.%<method>s`.'
|
26
|
+
MSG = 'Prefer `JSON.parse` over `JSON.%<method>s`.'
|
27
27
|
|
28
28
|
def_node_matcher :json_load, <<-PATTERN
|
29
29
|
(send (const {nil? cbase} :JSON) ${:load :restore} ...)
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
# Marshal.load(Marshal.dump({}))
|
20
20
|
#
|
21
21
|
class MarshalLoad < Cop
|
22
|
-
MSG = 'Avoid using `Marshal.%<method>s`.'
|
22
|
+
MSG = 'Avoid using `Marshal.%<method>s`.'
|
23
23
|
|
24
24
|
def_node_matcher :marshal_load, <<-PATTERN
|
25
25
|
(send (const {nil? cbase} :Marshal) ${:load :restore}
|
@@ -20,7 +20,7 @@ module RuboCop
|
|
20
20
|
# IO.popen(something)
|
21
21
|
# URI.parse(something).open
|
22
22
|
class Open < Cop
|
23
|
-
MSG = 'The use of `Kernel#open` is a serious security risk.'
|
23
|
+
MSG = 'The use of `Kernel#open` is a serious security risk.'
|
24
24
|
|
25
25
|
def_node_matcher :open?, <<-PATTERN
|
26
26
|
(send nil? :open $!str ...)
|
@@ -16,7 +16,7 @@ module RuboCop
|
|
16
16
|
# YAML.dump("foo")
|
17
17
|
#
|
18
18
|
class YAMLLoad < Cop
|
19
|
-
MSG = 'Prefer using `YAML.safe_load` over `YAML.load`.'
|
19
|
+
MSG = 'Prefer using `YAML.safe_load` over `YAML.load`.'
|
20
20
|
|
21
21
|
def_node_matcher :yaml_load, <<-PATTERN
|
22
22
|
(send (const {nil? cbase} :YAML) :load ...)
|
@@ -25,11 +25,11 @@ module RuboCop
|
|
25
25
|
class Alias < Cop
|
26
26
|
include ConfigurableEnforcedStyle
|
27
27
|
|
28
|
-
MSG_ALIAS = 'Use `alias_method` instead of `alias`.'
|
28
|
+
MSG_ALIAS = 'Use `alias_method` instead of `alias`.'
|
29
29
|
MSG_ALIAS_METHOD = 'Use `alias` instead of `alias_method` ' \
|
30
|
-
'%<current>s.'
|
30
|
+
'%<current>s.'
|
31
31
|
MSG_SYMBOL_ARGS = 'Use `alias %<prefer>s` instead of ' \
|
32
|
-
'`alias %<current>s`.'
|
32
|
+
'`alias %<current>s`.'
|
33
33
|
|
34
34
|
def on_send(node)
|
35
35
|
return unless node.command?(:alias_method)
|
@@ -40,7 +40,7 @@ module RuboCop
|
|
40
40
|
include ConfigurableEnforcedStyle
|
41
41
|
include RangeHelp
|
42
42
|
|
43
|
-
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
43
|
+
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
44
44
|
|
45
45
|
def on_and(node)
|
46
46
|
process_logical_operator(node) if style == :always
|
@@ -17,7 +17,7 @@ module RuboCop
|
|
17
17
|
class Attr < Cop
|
18
18
|
include RangeHelp
|
19
19
|
|
20
|
-
MSG = 'Do not use `attr`. Use `%<replacement>s` instead.'
|
20
|
+
MSG = 'Do not use `attr`. Use `%<replacement>s` instead.'
|
21
21
|
|
22
22
|
def on_send(node)
|
23
23
|
return unless node.command?(:attr) && node.arguments?
|
@@ -43,7 +43,7 @@ module RuboCop
|
|
43
43
|
include ConfigurableEnforcedStyle
|
44
44
|
include RangeHelp
|
45
45
|
|
46
|
-
MSG = '%<type>s curly braces around a hash parameter.'
|
46
|
+
MSG = '%<type>s curly braces around a hash parameter.'
|
47
47
|
|
48
48
|
def on_send(node)
|
49
49
|
return if node.assignment_method? || node.operator_method?
|
@@ -17,7 +17,7 @@ module RuboCop
|
|
17
17
|
# some_string =~ /something/
|
18
18
|
#
|
19
19
|
class CaseEquality < Cop
|
20
|
-
MSG = 'Avoid the use of the case equality operator `===`.'
|
20
|
+
MSG = 'Avoid the use of the case equality operator `===`.'
|
21
21
|
|
22
22
|
def_node_matcher :case_equality?, '(send _ :=== _)'
|
23
23
|
|
@@ -26,9 +26,9 @@ module RuboCop
|
|
26
26
|
include RangeHelp
|
27
27
|
|
28
28
|
NESTED_MSG = 'Use nested module/class definitions instead of ' \
|
29
|
-
'compact style.'
|
29
|
+
'compact style.'
|
30
30
|
COMPACT_MSG = 'Use compact module/class definition instead of ' \
|
31
|
-
'nested style.'
|
31
|
+
'nested style.'
|
32
32
|
|
33
33
|
def on_class(node)
|
34
34
|
return if node.parent_class && style != :nested
|
@@ -68,20 +68,20 @@ module RuboCop
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def replace_keyword_with_module(corrector, node)
|
71
|
-
corrector.replace(node.loc.keyword, 'module'
|
71
|
+
corrector.replace(node.loc.keyword, 'module')
|
72
72
|
end
|
73
73
|
|
74
74
|
def split_on_double_colon(corrector, node, padding)
|
75
75
|
children_definition = node.children.first
|
76
76
|
range = range_between(children_definition.loc.double_colon.begin_pos,
|
77
77
|
children_definition.loc.double_colon.end_pos)
|
78
|
-
replacement = "\n#{padding}#{node.loc.keyword.source} "
|
78
|
+
replacement = "\n#{padding}#{node.loc.keyword.source} "
|
79
79
|
|
80
80
|
corrector.replace(range, replacement)
|
81
81
|
end
|
82
82
|
|
83
83
|
def add_trailing_end(corrector, node, padding)
|
84
|
-
replacement = "#{padding}end\n#{leading_spaces(node)}end"
|
84
|
+
replacement = "#{padding}end\n#{leading_spaces(node)}end"
|
85
85
|
corrector.replace(node.loc.end, replacement)
|
86
86
|
end
|
87
87
|
|