rubocop 0.43.0 → 0.44.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.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/rubocop +0 -1
- data/config/default.yml +31 -0
- data/config/disabled.yml +6 -6
- data/config/enabled.yml +182 -140
- data/lib/rubocop.rb +7 -2
- data/lib/rubocop/ast_node.rb +0 -1
- data/lib/rubocop/ast_node/builder.rb +0 -1
- data/lib/rubocop/ast_node/sexp.rb +0 -1
- data/lib/rubocop/ast_node/traversal.rb +0 -1
- data/lib/rubocop/cached_data.rb +3 -20
- data/lib/rubocop/cli.rb +0 -1
- data/lib/rubocop/comment_config.rb +0 -1
- data/lib/rubocop/config.rb +0 -1
- data/lib/rubocop/config_loader.rb +1 -2
- data/lib/rubocop/config_loader_resolver.rb +0 -1
- data/lib/rubocop/config_store.rb +0 -1
- data/lib/rubocop/cop/autocorrect_logic.rb +0 -1
- data/lib/rubocop/cop/commissioner.rb +0 -1
- data/lib/rubocop/cop/cop.rb +15 -5
- data/lib/rubocop/cop/corrector.rb +0 -1
- data/lib/rubocop/cop/force.rb +0 -1
- data/lib/rubocop/cop/ignored_node.rb +0 -1
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +0 -1
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +0 -1
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +2 -2
- data/lib/rubocop/cop/lint/block_alignment.rb +0 -1
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +0 -1
- data/lib/rubocop/cop/lint/condition_position.rb +0 -1
- data/lib/rubocop/cop/lint/debugger.rb +0 -1
- data/lib/rubocop/cop/lint/def_end_alignment.rb +0 -1
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +0 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +0 -1
- data/lib/rubocop/cop/lint/duplicated_key.rb +0 -1
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +0 -1
- data/lib/rubocop/cop/lint/else_layout.rb +0 -1
- data/lib/rubocop/cop/lint/empty_ensure.rb +0 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +0 -1
- data/lib/rubocop/cop/lint/end_alignment.rb +0 -1
- data/lib/rubocop/cop/lint/end_in_method.rb +0 -1
- data/lib/rubocop/cop/lint/ensure_return.rb +0 -1
- data/lib/rubocop/cop/lint/eval.rb +0 -1
- data/lib/rubocop/cop/lint/float_out_of_range.rb +0 -1
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +0 -1
- data/lib/rubocop/cop/lint/handle_exceptions.rb +0 -1
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +0 -1
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +0 -1
- data/lib/rubocop/cop/lint/inherit_exception.rb +0 -1
- data/lib/rubocop/cop/lint/invalid_character_literal.rb +0 -1
- data/lib/rubocop/cop/lint/literal_in_condition.rb +0 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +0 -1
- data/lib/rubocop/cop/lint/loop.rb +0 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +0 -1
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +0 -1
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +0 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +0 -1
- data/lib/rubocop/cop/lint/percent_string_array.rb +0 -1
- data/lib/rubocop/cop/lint/percent_symbol_array.rb +0 -1
- data/lib/rubocop/cop/lint/rand_one.rb +0 -1
- data/lib/rubocop/cop/lint/require_parentheses.rb +0 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +0 -1
- data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -2
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +0 -1
- data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +0 -1
- data/lib/rubocop/cop/lint/syntax.rb +0 -1
- data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +0 -1
- data/lib/rubocop/cop/lint/unified_integer.rb +0 -1
- data/lib/rubocop/cop/lint/unneeded_disable.rb +0 -1
- data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +15 -2
- data/lib/rubocop/cop/lint/unreachable_code.rb +0 -1
- data/lib/rubocop/cop/lint/unused_block_argument.rb +81 -27
- data/lib/rubocop/cop/lint/unused_method_argument.rb +0 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +0 -1
- data/lib/rubocop/cop/lint/useless_assignment.rb +0 -1
- data/lib/rubocop/cop/lint/useless_comparison.rb +0 -1
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +0 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +0 -1
- data/lib/rubocop/cop/lint/void.rb +0 -1
- data/lib/rubocop/cop/metrics/abc_size.rb +1 -2
- data/lib/rubocop/cop/metrics/block_length.rb +26 -0
- data/lib/rubocop/cop/metrics/block_nesting.rb +0 -1
- data/lib/rubocop/cop/metrics/class_length.rb +0 -1
- data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +0 -1
- data/lib/rubocop/cop/metrics/line_length.rb +45 -8
- data/lib/rubocop/cop/metrics/method_length.rb +5 -10
- data/lib/rubocop/cop/metrics/module_length.rb +0 -1
- data/lib/rubocop/cop/metrics/parameter_lists.rb +0 -1
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +0 -1
- data/lib/rubocop/cop/mixin/access_modifier_node.rb +0 -1
- data/lib/rubocop/cop/mixin/annotation_comment.rb +0 -1
- data/lib/rubocop/cop/mixin/array_hash_indentation.rb +0 -1
- data/lib/rubocop/cop/mixin/array_syntax.rb +0 -1
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +0 -1
- data/lib/rubocop/cop/mixin/check_assignment.rb +0 -1
- data/lib/rubocop/cop/mixin/classish_length.rb +0 -1
- data/lib/rubocop/cop/mixin/code_length.rb +1 -2
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +0 -1
- data/lib/rubocop/cop/mixin/configurable_max.rb +0 -1
- data/lib/rubocop/cop/mixin/configurable_naming.rb +0 -1
- data/lib/rubocop/cop/mixin/configurable_numbering.rb +2 -2
- data/lib/rubocop/cop/mixin/def_node.rb +0 -1
- data/lib/rubocop/cop/mixin/documentation_comment.rb +0 -1
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +41 -16
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +0 -1
- data/lib/rubocop/cop/mixin/first_element_line_break.rb +0 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +0 -1
- data/lib/rubocop/cop/mixin/hash_node.rb +0 -1
- data/lib/rubocop/cop/mixin/if_node.rb +0 -1
- data/lib/rubocop/cop/mixin/integer_node.rb +0 -1
- data/lib/rubocop/cop/mixin/match_range.rb +0 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +0 -1
- data/lib/rubocop/cop/mixin/method_preference.rb +0 -1
- data/lib/rubocop/cop/mixin/min_body_length.rb +0 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +0 -1
- data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +0 -1
- data/lib/rubocop/cop/mixin/negative_conditional.rb +0 -1
- data/lib/rubocop/cop/mixin/on_method_def.rb +0 -1
- data/lib/rubocop/cop/mixin/on_normal_if_unless.rb +0 -1
- data/lib/rubocop/cop/mixin/parentheses.rb +0 -1
- data/lib/rubocop/cop/mixin/parser_diagnostic.rb +0 -1
- data/lib/rubocop/cop/mixin/percent_literal.rb +0 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +0 -1
- data/lib/rubocop/cop/mixin/safe_assignment.rb +0 -1
- data/lib/rubocop/cop/mixin/safe_mode.rb +0 -1
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +0 -1
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +0 -1
- data/lib/rubocop/cop/mixin/space_inside.rb +0 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +0 -1
- data/lib/rubocop/cop/mixin/string_help.rb +0 -1
- data/lib/rubocop/cop/mixin/string_literals_help.rb +0 -1
- data/lib/rubocop/cop/mixin/surrounding_space.rb +0 -1
- data/lib/rubocop/cop/mixin/too_many_lines.rb +25 -0
- data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -2
- data/lib/rubocop/cop/mixin/unused_argument.rb +0 -1
- data/lib/rubocop/cop/offense.rb +0 -1
- data/lib/rubocop/cop/performance/case_when_splat.rb +17 -8
- data/lib/rubocop/cop/performance/casecmp.rb +0 -1
- data/lib/rubocop/cop/performance/count.rb +0 -1
- data/lib/rubocop/cop/performance/detect.rb +0 -1
- data/lib/rubocop/cop/performance/double_start_end_with.rb +0 -1
- data/lib/rubocop/cop/performance/end_with.rb +0 -1
- data/lib/rubocop/cop/performance/fixed_size.rb +0 -1
- data/lib/rubocop/cop/performance/flat_map.rb +0 -1
- data/lib/rubocop/cop/performance/{hash_each.rb → hash_each_methods.rb} +0 -1
- data/lib/rubocop/cop/performance/lstrip_rstrip.rb +0 -1
- data/lib/rubocop/cop/performance/range_include.rb +0 -1
- data/lib/rubocop/cop/performance/redundant_block_call.rb +0 -1
- data/lib/rubocop/cop/performance/redundant_match.rb +0 -1
- data/lib/rubocop/cop/performance/redundant_merge.rb +1 -1
- data/lib/rubocop/cop/performance/redundant_sort_by.rb +0 -1
- data/lib/rubocop/cop/performance/reverse_each.rb +0 -1
- data/lib/rubocop/cop/performance/sample.rb +1 -2
- data/lib/rubocop/cop/performance/size.rb +0 -1
- data/lib/rubocop/cop/performance/sort_with_block.rb +0 -1
- data/lib/rubocop/cop/performance/start_with.rb +0 -1
- data/lib/rubocop/cop/performance/string_replacement.rb +0 -1
- data/lib/rubocop/cop/performance/times_map.rb +0 -1
- data/lib/rubocop/cop/rails/action_filter.rb +2 -3
- data/lib/rubocop/cop/rails/date.rb +0 -1
- data/lib/rubocop/cop/rails/delegate.rb +0 -1
- data/lib/rubocop/cop/rails/delegate_allow_blank.rb +62 -0
- data/lib/rubocop/cop/rails/dynamic_find_by.rb +77 -0
- data/lib/rubocop/cop/rails/exit.rb +0 -1
- data/lib/rubocop/cop/rails/find_by.rb +0 -1
- data/lib/rubocop/cop/rails/find_each.rb +0 -1
- data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +0 -1
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +89 -0
- data/lib/rubocop/cop/rails/not_null_column.rb +1 -2
- data/lib/rubocop/cop/rails/output.rb +0 -1
- data/lib/rubocop/cop/rails/output_safety.rb +1 -2
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +0 -1
- data/lib/rubocop/cop/rails/read_write_attribute.rb +0 -1
- data/lib/rubocop/cop/rails/request_referer.rb +0 -1
- data/lib/rubocop/cop/rails/safe_navigation.rb +0 -1
- data/lib/rubocop/cop/rails/save_bang.rb +12 -3
- data/lib/rubocop/cop/rails/scope_args.rb +0 -1
- data/lib/rubocop/cop/rails/time_zone.rb +0 -1
- data/lib/rubocop/cop/rails/uniq_before_pluck.rb +1 -2
- data/lib/rubocop/cop/rails/validation.rb +0 -1
- data/lib/rubocop/cop/security/json_load.rb +11 -3
- data/lib/rubocop/cop/severity.rb +0 -1
- data/lib/rubocop/cop/style/access_modifier_indentation.rb +0 -1
- data/lib/rubocop/cop/style/accessor_method_name.rb +0 -1
- data/lib/rubocop/cop/style/alias.rb +0 -1
- data/lib/rubocop/cop/style/align_array.rb +0 -1
- data/lib/rubocop/cop/style/align_hash.rb +0 -1
- data/lib/rubocop/cop/style/align_parameters.rb +0 -1
- data/lib/rubocop/cop/style/and_or.rb +0 -1
- data/lib/rubocop/cop/style/array_join.rb +0 -1
- data/lib/rubocop/cop/style/ascii_comments.rb +0 -1
- data/lib/rubocop/cop/style/ascii_identifiers.rb +0 -1
- data/lib/rubocop/cop/style/attr.rb +0 -1
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +0 -1
- data/lib/rubocop/cop/style/bare_percent_literals.rb +0 -1
- data/lib/rubocop/cop/style/begin_block.rb +0 -1
- data/lib/rubocop/cop/style/block_comments.rb +0 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +0 -1
- data/lib/rubocop/cop/style/block_end_newline.rb +0 -1
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +0 -1
- data/lib/rubocop/cop/style/case_equality.rb +0 -1
- data/lib/rubocop/cop/style/case_indentation.rb +0 -1
- data/lib/rubocop/cop/style/character_literal.rb +0 -1
- data/lib/rubocop/cop/style/class_and_module_camel_case.rb +0 -1
- data/lib/rubocop/cop/style/class_and_module_children.rb +0 -1
- data/lib/rubocop/cop/style/class_check.rb +0 -1
- data/lib/rubocop/cop/style/class_methods.rb +0 -1
- data/lib/rubocop/cop/style/class_vars.rb +0 -1
- data/lib/rubocop/cop/style/closing_parenthesis_indentation.rb +0 -1
- data/lib/rubocop/cop/style/collection_methods.rb +0 -1
- data/lib/rubocop/cop/style/colon_method_call.rb +0 -1
- data/lib/rubocop/cop/style/command_literal.rb +0 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +0 -1
- data/lib/rubocop/cop/style/comment_indentation.rb +0 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +0 -1
- data/lib/rubocop/cop/style/constant_name.rb +0 -1
- data/lib/rubocop/cop/style/copyright.rb +0 -1
- data/lib/rubocop/cop/style/def_with_parentheses.rb +0 -1
- data/lib/rubocop/cop/style/documentation.rb +0 -1
- data/lib/rubocop/cop/style/documentation_method.rb +0 -1
- data/lib/rubocop/cop/style/dot_position.rb +0 -1
- data/lib/rubocop/cop/style/double_negation.rb +0 -1
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +0 -1
- data/lib/rubocop/cop/style/each_with_object.rb +0 -1
- data/lib/rubocop/cop/style/else_alignment.rb +0 -1
- data/lib/rubocop/cop/style/empty_case_condition.rb +0 -1
- data/lib/rubocop/cop/style/empty_else.rb +7 -6
- data/lib/rubocop/cop/style/empty_line_between_defs.rb +0 -1
- data/lib/rubocop/cop/style/empty_lines.rb +0 -1
- data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +15 -8
- data/lib/rubocop/cop/style/empty_lines_around_block_body.rb +0 -1
- data/lib/rubocop/cop/style/empty_lines_around_class_body.rb +0 -1
- data/lib/rubocop/cop/style/empty_lines_around_method_body.rb +0 -1
- data/lib/rubocop/cop/style/empty_lines_around_module_body.rb +0 -1
- data/lib/rubocop/cop/style/empty_literal.rb +0 -1
- data/lib/rubocop/cop/style/encoding.rb +0 -1
- data/lib/rubocop/cop/style/end_block.rb +0 -1
- data/lib/rubocop/cop/style/end_of_line.rb +0 -1
- data/lib/rubocop/cop/style/even_odd.rb +0 -1
- data/lib/rubocop/cop/style/extra_spacing.rb +5 -4
- data/lib/rubocop/cop/style/file_name.rb +0 -1
- data/lib/rubocop/cop/style/first_array_element_line_break.rb +0 -1
- data/lib/rubocop/cop/style/first_hash_element_line_break.rb +0 -1
- data/lib/rubocop/cop/style/first_method_argument_line_break.rb +0 -1
- data/lib/rubocop/cop/style/first_method_parameter_line_break.rb +0 -1
- data/lib/rubocop/cop/style/first_parameter_indentation.rb +0 -1
- data/lib/rubocop/cop/style/flip_flop.rb +0 -1
- data/lib/rubocop/cop/style/for.rb +0 -1
- data/lib/rubocop/cop/style/format_string.rb +0 -1
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +0 -1
- data/lib/rubocop/cop/style/global_vars.rb +0 -1
- data/lib/rubocop/cop/style/guard_clause.rb +2 -4
- data/lib/rubocop/cop/style/hash_syntax.rb +0 -1
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +0 -1
- data/lib/rubocop/cop/style/if_inside_else.rb +0 -1
- data/lib/rubocop/cop/style/if_unless_modifier.rb +0 -1
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +0 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +0 -1
- data/lib/rubocop/cop/style/implicit_runtime_error.rb +0 -1
- data/lib/rubocop/cop/style/indent_array.rb +0 -1
- data/lib/rubocop/cop/style/indent_assignment.rb +0 -1
- data/lib/rubocop/cop/style/indent_hash.rb +0 -1
- data/lib/rubocop/cop/style/indentation_consistency.rb +0 -1
- data/lib/rubocop/cop/style/indentation_width.rb +0 -1
- data/lib/rubocop/cop/style/infinite_loop.rb +0 -1
- data/lib/rubocop/cop/style/initial_indentation.rb +0 -1
- data/lib/rubocop/cop/style/inline_comment.rb +0 -1
- data/lib/rubocop/cop/style/lambda.rb +0 -1
- data/lib/rubocop/cop/style/lambda_call.rb +0 -1
- data/lib/rubocop/cop/style/leading_comment_space.rb +0 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +1 -2
- data/lib/rubocop/cop/style/method_call_parentheses.rb +0 -1
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +0 -1
- data/lib/rubocop/cop/style/method_def_parentheses.rb +0 -1
- data/lib/rubocop/cop/style/method_missing.rb +0 -1
- data/lib/rubocop/cop/style/method_name.rb +0 -1
- data/lib/rubocop/cop/style/missing_else.rb +0 -1
- data/lib/rubocop/cop/style/module_function.rb +0 -1
- data/lib/rubocop/cop/style/multiline_array_brace_layout.rb +0 -1
- data/lib/rubocop/cop/style/multiline_assignment_layout.rb +0 -1
- data/lib/rubocop/cop/style/multiline_block_chain.rb +0 -1
- data/lib/rubocop/cop/style/multiline_block_layout.rb +0 -1
- data/lib/rubocop/cop/style/multiline_hash_brace_layout.rb +0 -1
- data/lib/rubocop/cop/style/multiline_if_then.rb +0 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +44 -0
- data/lib/rubocop/cop/style/multiline_method_call_brace_layout.rb +0 -1
- data/lib/rubocop/cop/style/multiline_method_call_indentation.rb +0 -1
- data/lib/rubocop/cop/style/multiline_method_definition_brace_layout.rb +0 -1
- data/lib/rubocop/cop/style/multiline_operation_indentation.rb +0 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +0 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +0 -1
- data/lib/rubocop/cop/style/negated_if.rb +0 -1
- data/lib/rubocop/cop/style/negated_while.rb +0 -1
- data/lib/rubocop/cop/style/nested_modifier.rb +0 -1
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +0 -1
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +0 -1
- data/lib/rubocop/cop/style/next.rb +0 -1
- data/lib/rubocop/cop/style/nil_comparison.rb +0 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +18 -2
- data/lib/rubocop/cop/style/not.rb +0 -1
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +2 -5
- data/lib/rubocop/cop/style/numeric_literals.rb +0 -1
- data/lib/rubocop/cop/style/numeric_predicate.rb +0 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +0 -1
- data/lib/rubocop/cop/style/op_method.rb +0 -1
- data/lib/rubocop/cop/style/option_hash.rb +0 -1
- data/lib/rubocop/cop/style/optional_arguments.rb +0 -1
- data/lib/rubocop/cop/style/parallel_assignment.rb +13 -2
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +0 -1
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +0 -1
- data/lib/rubocop/cop/style/percent_q_literals.rb +0 -1
- data/lib/rubocop/cop/style/perl_backrefs.rb +0 -1
- data/lib/rubocop/cop/style/predicate_name.rb +0 -1
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +44 -6
- data/lib/rubocop/cop/style/proc.rb +0 -1
- data/lib/rubocop/cop/style/raise_args.rb +13 -14
- data/lib/rubocop/cop/style/redundant_begin.rb +0 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +0 -1
- data/lib/rubocop/cop/style/redundant_freeze.rb +0 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/redundant_return.rb +37 -9
- data/lib/rubocop/cop/style/redundant_self.rb +0 -1
- data/lib/rubocop/cop/style/regexp_literal.rb +0 -1
- data/lib/rubocop/cop/style/rescue_ensure_alignment.rb +0 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +0 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +51 -39
- data/lib/rubocop/cop/style/self_assignment.rb +0 -1
- data/lib/rubocop/cop/style/semicolon.rb +0 -1
- data/lib/rubocop/cop/style/send.rb +0 -1
- data/lib/rubocop/cop/style/signal_exception.rb +0 -1
- data/lib/rubocop/cop/style/single_line_block_params.rb +0 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +0 -1
- data/lib/rubocop/cop/style/space_after_colon.rb +0 -1
- data/lib/rubocop/cop/style/space_after_comma.rb +0 -1
- data/lib/rubocop/cop/style/space_after_method_name.rb +0 -1
- data/lib/rubocop/cop/style/space_after_not.rb +0 -1
- data/lib/rubocop/cop/style/space_after_semicolon.rb +0 -1
- data/lib/rubocop/cop/style/space_around_block_parameters.rb +0 -1
- data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +0 -1
- data/lib/rubocop/cop/style/space_around_keyword.rb +0 -1
- data/lib/rubocop/cop/style/space_around_operators.rb +0 -1
- data/lib/rubocop/cop/style/space_before_block_braces.rb +0 -1
- data/lib/rubocop/cop/style/space_before_comma.rb +0 -1
- data/lib/rubocop/cop/style/space_before_comment.rb +0 -1
- data/lib/rubocop/cop/style/space_before_first_arg.rb +0 -1
- data/lib/rubocop/cop/style/space_before_semicolon.rb +0 -1
- data/lib/rubocop/cop/style/space_inside_array_percent_literal.rb +0 -1
- data/lib/rubocop/cop/style/space_inside_block_braces.rb +0 -1
- data/lib/rubocop/cop/style/space_inside_brackets.rb +0 -1
- data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +0 -1
- data/lib/rubocop/cop/style/space_inside_parens.rb +0 -1
- data/lib/rubocop/cop/style/space_inside_percent_literal_delimiters.rb +0 -1
- data/lib/rubocop/cop/style/space_inside_range_literal.rb +0 -1
- data/lib/rubocop/cop/style/space_inside_string_interpolation.rb +0 -1
- data/lib/rubocop/cop/style/special_global_vars.rb +0 -1
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +0 -1
- data/lib/rubocop/cop/style/string_literals.rb +0 -1
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +0 -1
- data/lib/rubocop/cop/style/string_methods.rb +0 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +0 -1
- data/lib/rubocop/cop/style/symbol_array.rb +0 -1
- data/lib/rubocop/cop/style/symbol_literal.rb +0 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +0 -1
- data/lib/rubocop/cop/style/tab.rb +0 -1
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -2
- data/lib/rubocop/cop/style/trailing_blank_lines.rb +0 -1
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +0 -1
- data/lib/rubocop/cop/style/trailing_comma_in_literal.rb +0 -1
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +0 -1
- data/lib/rubocop/cop/style/trailing_whitespace.rb +0 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +0 -1
- data/lib/rubocop/cop/style/unless_else.rb +0 -1
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +3 -2
- data/lib/rubocop/cop/style/unneeded_interpolation.rb +0 -1
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +0 -1
- data/lib/rubocop/cop/style/variable_interpolation.rb +0 -1
- data/lib/rubocop/cop/style/variable_name.rb +0 -1
- data/lib/rubocop/cop/style/variable_number.rb +0 -1
- data/lib/rubocop/cop/style/when_then.rb +0 -1
- data/lib/rubocop/cop/style/while_until_do.rb +0 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
- data/lib/rubocop/cop/style/word_array.rb +0 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +0 -1
- data/lib/rubocop/cop/team.rb +1 -2
- data/lib/rubocop/cop/util.rb +11 -6
- data/lib/rubocop/cop/variable_force.rb +0 -1
- data/lib/rubocop/cop/variable_force/assignment.rb +0 -1
- data/lib/rubocop/cop/variable_force/locatable.rb +0 -1
- data/lib/rubocop/cop/variable_force/reference.rb +0 -1
- data/lib/rubocop/cop/variable_force/scope.rb +0 -1
- data/lib/rubocop/cop/variable_force/variable.rb +0 -1
- data/lib/rubocop/cop/variable_force/variable_table.rb +0 -1
- data/lib/rubocop/error.rb +0 -1
- data/lib/rubocop/formatter/base_formatter.rb +0 -1
- data/lib/rubocop/formatter/clang_style_formatter.rb +0 -1
- data/lib/rubocop/formatter/colorizable.rb +0 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +0 -1
- data/lib/rubocop/formatter/disabled_lines_formatter.rb +0 -1
- data/lib/rubocop/formatter/emacs_style_formatter.rb +0 -1
- data/lib/rubocop/formatter/file_list_formatter.rb +0 -1
- data/lib/rubocop/formatter/formatter_set.rb +0 -1
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +0 -1
- data/lib/rubocop/formatter/html_formatter.rb +2 -3
- data/lib/rubocop/formatter/json_formatter.rb +0 -1
- data/lib/rubocop/formatter/offense_count_formatter.rb +0 -1
- data/lib/rubocop/formatter/progress_formatter.rb +0 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +0 -1
- data/lib/rubocop/formatter/text_util.rb +0 -1
- data/lib/rubocop/formatter/worst_offenders_formatter.rb +0 -1
- data/lib/rubocop/name_similarity.rb +0 -1
- data/lib/rubocop/node_pattern.rb +0 -1
- data/lib/rubocop/options.rb +0 -1
- data/lib/rubocop/path_util.rb +0 -1
- data/lib/rubocop/processed_source.rb +3 -4
- data/lib/rubocop/rake_task.rb +0 -1
- data/lib/rubocop/remote_config.rb +0 -1
- data/lib/rubocop/result_cache.rb +3 -4
- data/lib/rubocop/rspec/cop_helper.rb +0 -1
- data/lib/rubocop/rspec/host_environment_simulation_helper.rb +0 -1
- data/lib/rubocop/rspec/shared_contexts.rb +0 -1
- data/lib/rubocop/rspec/shared_examples.rb +0 -1
- data/lib/rubocop/rspec/support.rb +0 -1
- data/lib/rubocop/runner.rb +0 -1
- data/lib/rubocop/string_interpreter.rb +0 -1
- data/lib/rubocop/string_util.rb +0 -1
- data/lib/rubocop/target_finder.rb +0 -1
- data/lib/rubocop/token.rb +0 -1
- data/lib/rubocop/version.rb +1 -2
- data/lib/rubocop/warning.rb +0 -1
- metadata +9 -3
data/lib/rubocop/cop/offense.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
3
|
+
require 'pry'
|
4
4
|
module RuboCop
|
5
5
|
module Cop
|
6
6
|
module Performance
|
@@ -82,7 +82,7 @@ module RuboCop
|
|
82
82
|
*conditions, _body = *node
|
83
83
|
|
84
84
|
lambda do |corrector|
|
85
|
-
if needs_reorder?(
|
85
|
+
if needs_reorder?(node)
|
86
86
|
reorder_condition(corrector, node, replacement(conditions))
|
87
87
|
else
|
88
88
|
inline_fix_branch(corrector, node, conditions,
|
@@ -94,8 +94,10 @@ module RuboCop
|
|
94
94
|
private
|
95
95
|
|
96
96
|
def replacement(conditions)
|
97
|
-
|
98
|
-
|
97
|
+
ordered_conditions = conditions.partition { |cond| !cond.splat_type? }
|
98
|
+
ordered_conditions.flatten!
|
99
|
+
ordered_conditions.map!(&:source)
|
100
|
+
ordered_conditions.join(', ')
|
99
101
|
end
|
100
102
|
|
101
103
|
def inline_fix_branch(corrector, _node, conditions, new_condition)
|
@@ -107,6 +109,8 @@ module RuboCop
|
|
107
109
|
def reorder_condition(corrector, node, new_condition)
|
108
110
|
*_conditions, body = *node
|
109
111
|
_case_branch, *when_branches, _else_branch = *node.parent
|
112
|
+
return if when_branches.size == 1 # Can't reorder one branch
|
113
|
+
|
110
114
|
corrector.remove(when_branch_range(node, when_branches))
|
111
115
|
|
112
116
|
correction = if same_line?(node, body)
|
@@ -159,10 +163,15 @@ module RuboCop
|
|
159
163
|
!condition.splat_type?
|
160
164
|
end
|
161
165
|
|
162
|
-
def needs_reorder?(
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
+
def needs_reorder?(node)
|
167
|
+
_case_condition, *when_branches, _else_branch = *node.parent
|
168
|
+
current_index = when_branches.index { |branch| branch == node }
|
169
|
+
when_branches[(current_index + 1)..-1].any? do |branch|
|
170
|
+
*conditions, _ = *branch
|
171
|
+
conditions.none? do |condition|
|
172
|
+
variable, = *condition
|
173
|
+
condition.splat_type? && !(variable && variable.array_type?)
|
174
|
+
end
|
166
175
|
end
|
167
176
|
end
|
168
177
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module RuboCop
|
@@ -45,6 +44,7 @@ module RuboCop
|
|
45
44
|
|
46
45
|
def each_redundant_merge(node)
|
47
46
|
redundant_merge(node) do |receiver, pairs|
|
47
|
+
next unless receiver
|
48
48
|
next if node.value_used? &&
|
49
49
|
!EachWithObjectInspector.new(node, receiver).value_used?
|
50
50
|
next if pairs.size > 1 && !receiver.pure?
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module RuboCop
|
@@ -92,7 +91,7 @@ module RuboCop
|
|
92
91
|
def range_size(range_node)
|
93
92
|
vals = *range_node
|
94
93
|
return :unknown unless vals.all?(&:int_type?)
|
95
|
-
low, high = *vals.map
|
94
|
+
low, high = *vals.map { |val| val.to_a.first }
|
96
95
|
return :unknown unless low.zero? && high >= 0
|
97
96
|
case range_node.type
|
98
97
|
when :erange then high - low
|
@@ -1,12 +1,11 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module RuboCop
|
5
4
|
module Cop
|
6
5
|
module Rails
|
7
|
-
# This cop enforces the consistent use of action
|
6
|
+
# This cop enforces the consistent use of action filter methods.
|
8
7
|
#
|
9
|
-
# The cop is configurable and
|
8
|
+
# The cop is configurable and can enforce the use of the older
|
10
9
|
# something_filter methods or the newer something_action methods.
|
11
10
|
class ActionFilter < Cop
|
12
11
|
include ConfigurableEnforcedStyle
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Rails
|
6
|
+
# This cop looks for delegations that pass :allow_blank as an option
|
7
|
+
# instead of :allow_nil. :allow_blank is not a valid option to pass
|
8
|
+
# to ActiveSupport#delegate.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# # bad
|
12
|
+
# delegate :foo, to: :bar, allow_blank: true
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# delegate :foo, to: :bar, allow_nil: true
|
16
|
+
class DelegateAllowBlank < Cop
|
17
|
+
MSG = '`allow_blank` is not a valid option, use `allow_nil`.'.freeze
|
18
|
+
|
19
|
+
def_node_matcher :delegate, <<-PATTERN
|
20
|
+
(send _ :delegate _ $hash)
|
21
|
+
PATTERN
|
22
|
+
|
23
|
+
def_node_matcher :delegate_options, <<-PATTERN
|
24
|
+
(hash $...)
|
25
|
+
PATTERN
|
26
|
+
|
27
|
+
def_node_matcher :allow_blank?, <<-PATTERN
|
28
|
+
(pair $(sym :allow_blank) true)
|
29
|
+
PATTERN
|
30
|
+
|
31
|
+
def on_send(node)
|
32
|
+
offending_node = allow_blank_option(node)
|
33
|
+
return unless offending_node
|
34
|
+
|
35
|
+
allow_blank = offending_node.children.first
|
36
|
+
add_offense(node, allow_blank.source_range, MSG)
|
37
|
+
end
|
38
|
+
|
39
|
+
def autocorrect(node)
|
40
|
+
offending_node = allow_blank_option(node)
|
41
|
+
return unless offending_node
|
42
|
+
|
43
|
+
allow_blank = offending_node.children.first
|
44
|
+
lambda do |corrector|
|
45
|
+
corrector.replace(allow_blank.source_range, 'allow_nil')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def allow_blank_option(node)
|
52
|
+
options_hash = delegate(node)
|
53
|
+
return unless options_hash
|
54
|
+
options = delegate_options(options_hash)
|
55
|
+
return unless options
|
56
|
+
|
57
|
+
options.detect { |opt| allow_blank?(opt) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Rails
|
6
|
+
# This cop checks dynamic `find_by_*` methods.
|
7
|
+
# Use `find_by` instead of dynamic method.
|
8
|
+
# See. https://github.com/bbatsov/rails-style-guide#find_by
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# # bad
|
12
|
+
# User.find_by_name(name)
|
13
|
+
#
|
14
|
+
# # bad
|
15
|
+
# User.find_by_name_and_email(name)
|
16
|
+
#
|
17
|
+
# # bad
|
18
|
+
# User.find_by_email!(name)
|
19
|
+
#
|
20
|
+
# # good
|
21
|
+
# User.find_by(name: name)
|
22
|
+
#
|
23
|
+
# # good
|
24
|
+
# User.find_by(name: name, email: email)
|
25
|
+
#
|
26
|
+
# # good
|
27
|
+
# User.find_by!(email: email)
|
28
|
+
class DynamicFindBy < Cop
|
29
|
+
MSG = 'Use `%s` instead of dynamic `%s`.'.freeze
|
30
|
+
METHOD_PATTERN = /^find_by_(.+?)(!)?$/
|
31
|
+
|
32
|
+
def on_send(node)
|
33
|
+
_receiver, method, _args = *node
|
34
|
+
method_name = method.to_s
|
35
|
+
return if whitelist.include?(method_name)
|
36
|
+
static_name = static_method_name(method_name)
|
37
|
+
return unless static_name
|
38
|
+
|
39
|
+
add_offense(node, :expression, format(MSG, static_name, method))
|
40
|
+
end
|
41
|
+
|
42
|
+
def autocorrect(node)
|
43
|
+
_receiver, method, *args = *node
|
44
|
+
static_name = static_method_name(method.to_s)
|
45
|
+
keywords = column_keywords(method)
|
46
|
+
return if keywords.size != args.size
|
47
|
+
|
48
|
+
lambda do |corrector|
|
49
|
+
corrector.replace(node.loc.selector, static_name)
|
50
|
+
keywords.each.with_index do |keyword, idx|
|
51
|
+
corrector.insert_before(args[idx].loc.expression, keyword)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def whitelist
|
59
|
+
cop_config['Whitelist']
|
60
|
+
end
|
61
|
+
|
62
|
+
def column_keywords(method)
|
63
|
+
keyword_string = method.to_s[METHOD_PATTERN, 1]
|
64
|
+
keyword_string.split('_and_').map { |keyword| "#{keyword}: " }
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns static method name.
|
68
|
+
# If code isn't wrong, returns nil
|
69
|
+
def static_method_name(method_name)
|
70
|
+
match = METHOD_PATTERN.match(method_name)
|
71
|
+
return nil unless match
|
72
|
+
match[2] ? 'find_by!' : 'find_by'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Rails
|
6
|
+
# This cop is used to identify usages of http methods
|
7
|
+
# like `get`, `post`, `put`, `path` without the usage of keyword arguments
|
8
|
+
# in your tests and change them to use keyword arguments.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# # bad
|
12
|
+
# get :new, { user_id: 1}
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# get :new, params: { user_id: 1 }
|
16
|
+
class HttpPositionalArguments < Cop
|
17
|
+
MSG = 'Use keyword arguments instead of ' \
|
18
|
+
'positional arguments for http call: `%s`.'.freeze
|
19
|
+
KEYWORD_ARGS = [:headers, :env, :params, :body, :flash, :as].freeze
|
20
|
+
HTTP_METHODS = [:get, :post, :put, :patch, :delete, :head].freeze
|
21
|
+
|
22
|
+
def on_send(node)
|
23
|
+
receiver, http_method, http_path, data = *node
|
24
|
+
# if the first word on the line is not an http method, then skip
|
25
|
+
return unless HTTP_METHODS.include?(http_method)
|
26
|
+
# if the data is nil then we don't need to add keyword arguments
|
27
|
+
# because there is no data to put in params or headers, so skip
|
28
|
+
return if data.nil?
|
29
|
+
return unless needs_conversion?(data)
|
30
|
+
# ensures this is the first method on the line
|
31
|
+
# there is an edge case here where sometimes the http method is
|
32
|
+
# wrapped into another method, but its just safer to skip those
|
33
|
+
# cases and process manually
|
34
|
+
return unless receiver.nil?
|
35
|
+
# a http_method without a path?, must be something else
|
36
|
+
return if http_path.nil?
|
37
|
+
add_offense(node, node.loc.selector, format(MSG, node.method_name))
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Boolean] true if the line needs to be converted
|
41
|
+
def needs_conversion?(data)
|
42
|
+
# if the line has already been converted to use keyword args
|
43
|
+
# then skip
|
44
|
+
# ie. get :new, params: { user_id: 1 } (looking for keyword arg)
|
45
|
+
value = data.descendants.find do |d|
|
46
|
+
KEYWORD_ARGS.include?(d.children.first) if d.type == :sym
|
47
|
+
end
|
48
|
+
value.nil?
|
49
|
+
end
|
50
|
+
|
51
|
+
def convert_hash_data(data, type)
|
52
|
+
# empty hash or no hash return empty string
|
53
|
+
return '' if data.nil? || data.children.count < 1
|
54
|
+
hash_data = if data.type == :send
|
55
|
+
# user supplies an object,
|
56
|
+
# no need to surround with braces
|
57
|
+
data.source
|
58
|
+
else
|
59
|
+
format('{ %s }', data.children.map(&:source).join(', '))
|
60
|
+
end
|
61
|
+
format(', %s: %s', type, hash_data)
|
62
|
+
end
|
63
|
+
|
64
|
+
# given a pre Rails 5 method: get :new, user_id: @user.id, {}
|
65
|
+
#
|
66
|
+
# @return lambda of auto correct procedure
|
67
|
+
# the result should look like:
|
68
|
+
# get :new, params: { user_id: @user.id }, headers: {}
|
69
|
+
# the http_method is the method use to call the controller
|
70
|
+
# the controller node can be a symbol, method, object or string
|
71
|
+
# that represents the path/action on the Rails controller
|
72
|
+
# the data is the http parameters and environment sent in
|
73
|
+
# the Rails 5 http call
|
74
|
+
def autocorrect(node)
|
75
|
+
_receiver, http_method, http_path, *data = *node
|
76
|
+
controller_action = http_path.source
|
77
|
+
params = convert_hash_data(data.first, 'params')
|
78
|
+
headers = convert_hash_data(data.last, 'headers') if data.count > 1
|
79
|
+
# the range of the text to replace, which is the whole line
|
80
|
+
code_to_replace = node.loc.expression
|
81
|
+
# what to replace with
|
82
|
+
new_code = format('%s %s%s%s', http_method, controller_action,
|
83
|
+
params, headers)
|
84
|
+
->(corrector) { corrector.replace(code_to_replace, new_code) }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|