rubocop 0.18.1 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +65 -1
- data/Gemfile +0 -3
- data/LICENSE.txt +1 -1
- data/README.md +179 -77
- data/Rakefile +8 -0
- data/config/default.yml +151 -14
- data/config/enabled.yml +65 -8
- data/lib/rubocop.rb +19 -4
- data/lib/rubocop/cli.rb +2 -1
- data/lib/rubocop/comment_config.rb +97 -0
- data/lib/rubocop/config.rb +1 -1
- data/lib/rubocop/config_loader.rb +3 -2
- data/lib/rubocop/config_store.rb +6 -2
- data/lib/rubocop/cop/commissioner.rb +2 -2
- data/lib/rubocop/cop/cop.rb +22 -26
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +2 -2
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +1 -1
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/block_alignment.rb +6 -6
- data/lib/rubocop/cop/lint/condition_position.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +1 -1
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +60 -0
- 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/end_alignment.rb +14 -12
- 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/eval.rb +1 -1
- data/lib/rubocop/cop/lint/handle_exceptions.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_condition.rb +13 -2
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +28 -0
- data/lib/rubocop/cop/lint/loop.rb +4 -4
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/require_parentheses.rb +6 -6
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +2 -2
- data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +30 -0
- data/lib/rubocop/cop/lint/syntax.rb +5 -5
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/useless_assignment.rb +5 -5
- data/lib/rubocop/cop/lint/useless_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +5 -5
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +8 -5
- data/lib/rubocop/cop/mixin/code_length.rb +2 -2
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +7 -7
- data/lib/rubocop/cop/mixin/configurable_max.rb +1 -1
- data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
- data/lib/rubocop/cop/mixin/if_then_else.rb +1 -1
- data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
- data/lib/rubocop/cop/mixin/parser_diagnostic.rb +2 -2
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +3 -2
- data/lib/rubocop/cop/mixin/space_inside.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +1 -0
- data/lib/rubocop/cop/mixin/string_help.rb +4 -4
- data/lib/rubocop/cop/{offence.rb → offense.rb} +7 -7
- data/lib/rubocop/cop/rails/action_filter.rb +73 -0
- data/lib/rubocop/cop/rails/default_scope.rb +1 -1
- data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +1 -1
- data/lib/rubocop/cop/rails/output.rb +1 -10
- data/lib/rubocop/cop/rails/read_attribute.rb +1 -1
- data/lib/rubocop/cop/rails/scope_args.rb +33 -0
- data/lib/rubocop/cop/rails/validation.rb +1 -1
- data/lib/rubocop/cop/style/access_modifier_indentation.rb +1 -1
- data/lib/rubocop/cop/style/accessor_method_name.rb +2 -2
- data/lib/rubocop/cop/style/alias.rb +2 -2
- data/lib/rubocop/cop/style/align_array.rb +1 -1
- data/lib/rubocop/cop/style/align_hash.rb +29 -2
- data/lib/rubocop/cop/style/align_parameters.rb +16 -2
- data/lib/rubocop/cop/style/and_or.rb +2 -2
- data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
- data/lib/rubocop/cop/style/ascii_identifiers.rb +1 -1
- data/lib/rubocop/cop/style/attr.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_nesting.rb +1 -1
- data/lib/rubocop/cop/style/blocks.rb +2 -2
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +2 -2
- data/lib/rubocop/cop/style/case_equality.rb +1 -1
- data/lib/rubocop/cop/style/case_indentation.rb +2 -2
- data/lib/rubocop/cop/style/character_literal.rb +2 -2
- data/lib/rubocop/cop/style/class_and_module_camel_case.rb +1 -1
- data/lib/rubocop/cop/style/class_and_module_children.rb +69 -0
- data/lib/rubocop/cop/style/class_methods.rb +1 -1
- data/lib/rubocop/cop/style/class_vars.rb +3 -3
- data/lib/rubocop/cop/style/collection_methods.rb +4 -4
- data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
- data/lib/rubocop/cop/style/constant_name.rb +1 -1
- data/lib/rubocop/cop/style/cyclomatic_complexity.rb +2 -2
- data/lib/rubocop/cop/style/def_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/documentation.rb +1 -1
- data/lib/rubocop/cop/style/dot_position.rb +10 -11
- data/lib/rubocop/cop/style/double_negation.rb +40 -0
- data/lib/rubocop/cop/style/empty_line_between_defs.rb +8 -1
- data/lib/rubocop/cop/style/empty_lines.rb +3 -2
- data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +1 -1
- data/lib/rubocop/cop/style/empty_lines_around_body.rb +1 -1
- data/lib/rubocop/cop/style/empty_literal.rb +3 -3
- data/lib/rubocop/cop/style/encoding.rb +1 -1
- data/lib/rubocop/cop/style/end_block.rb +1 -1
- data/lib/rubocop/cop/style/end_of_line.rb +2 -2
- data/lib/rubocop/cop/style/even_odd.rb +2 -2
- data/lib/rubocop/cop/style/favor_join.rb +1 -1
- data/lib/rubocop/cop/style/file_name.rb +29 -0
- data/lib/rubocop/cop/style/final_newline.rb +1 -1
- data/lib/rubocop/cop/style/flip_flop.rb +2 -2
- data/lib/rubocop/cop/style/for.rb +2 -2
- data/lib/rubocop/cop/style/format_string.rb +66 -0
- data/lib/rubocop/cop/style/global_vars.rb +2 -2
- data/lib/rubocop/cop/style/hash_methods.rb +1 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +3 -3
- data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -1
- data/lib/rubocop/cop/style/indent_array.rb +41 -0
- data/lib/rubocop/cop/style/indent_hash.rb +119 -0
- data/lib/rubocop/cop/style/indentation_consistency.rb +3 -11
- data/lib/rubocop/cop/style/indentation_width.rb +44 -23
- data/lib/rubocop/cop/style/lambda.rb +2 -2
- data/lib/rubocop/cop/style/lambda_call.rb +3 -3
- data/lib/rubocop/cop/style/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +7 -3
- data/lib/rubocop/cop/style/line_length.rb +2 -2
- data/lib/rubocop/cop/style/method_call_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -2
- data/lib/rubocop/cop/style/method_def_parentheses.rb +9 -7
- data/lib/rubocop/cop/style/module_function.rb +1 -1
- data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +2 -2
- data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literals.rb +5 -5
- data/lib/rubocop/cop/style/op_method.rb +2 -2
- data/lib/rubocop/cop/style/parameter_lists.rb +1 -1
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +5 -4
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +143 -0
- data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
- data/lib/rubocop/cop/style/predicate_name.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/redundant_begin.rb +1 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +1 -1
- data/lib/rubocop/cop/style/redundant_return.rb +1 -1
- data/lib/rubocop/cop/style/redundant_self.rb +2 -2
- data/lib/rubocop/cop/style/regexp_literal.rb +45 -19
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +73 -0
- data/lib/rubocop/cop/style/semicolon.rb +12 -8
- 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 +38 -1
- data/lib/rubocop/cop/style/space_after_colon.rb +3 -3
- data/lib/rubocop/cop/style/space_after_comma.rb +1 -1
- data/lib/rubocop/cop/style/space_after_control_keyword.rb +1 -1
- data/lib/rubocop/cop/style/space_after_method_name.rb +11 -3
- data/lib/rubocop/cop/style/space_after_not.rb +1 -1
- data/lib/rubocop/cop/style/space_after_semicolon.rb +1 -1
- data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +41 -6
- data/lib/rubocop/cop/style/space_around_operators.rb +4 -4
- data/lib/rubocop/cop/style/space_before_block_braces.rb +63 -0
- data/lib/rubocop/cop/style/space_before_modifier_keyword.rb +1 -1
- data/lib/rubocop/cop/style/{space_around_block_braces.rb → space_inside_block_braces.rb} +15 -24
- data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +14 -7
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
- data/lib/rubocop/cop/style/string_literals.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +1 -1
- data/lib/rubocop/cop/style/tab.rb +1 -1
- data/lib/rubocop/cop/style/trailing_blank_lines.rb +2 -2
- data/lib/rubocop/cop/style/trailing_comma.rb +4 -4
- data/lib/rubocop/cop/style/trailing_whitespace.rb +1 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +2 -2
- data/lib/rubocop/cop/style/unless_else.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 +2 -1
- data/lib/rubocop/cop/style/word_array.rb +2 -2
- data/lib/rubocop/cop/team.rb +24 -7
- data/lib/rubocop/cop/util.rb +3 -3
- data/lib/rubocop/cop/variable_inspector.rb +25 -13
- data/lib/rubocop/cop/variable_inspector/assignment.rb +1 -1
- data/lib/rubocop/cop/variable_inspector/reference.rb +1 -1
- data/lib/rubocop/cop/variable_inspector/scope.rb +1 -1
- data/lib/rubocop/cop/variable_inspector/variable.rb +2 -2
- data/lib/rubocop/cop/variable_inspector/variable_table.rb +1 -1
- data/lib/rubocop/file_inspector.rb +12 -13
- data/lib/rubocop/formatter/base_formatter.rb +4 -4
- data/lib/rubocop/formatter/clang_style_formatter.rb +2 -2
- data/lib/rubocop/formatter/disabled_config_formatter.rb +12 -12
- data/lib/rubocop/formatter/emacs_style_formatter.rb +3 -2
- data/lib/rubocop/formatter/file_list_formatter.rb +4 -4
- data/lib/rubocop/formatter/formatter_set.rb +2 -1
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +76 -0
- data/lib/rubocop/formatter/json_formatter.rb +17 -16
- data/lib/rubocop/formatter/offense_count_formatter.rb +54 -0
- data/lib/rubocop/formatter/progress_formatter.rb +16 -16
- data/lib/rubocop/formatter/simple_text_formatter.rb +25 -25
- data/lib/rubocop/options.rb +8 -7
- data/lib/rubocop/processed_source.rb +3 -2
- data/lib/rubocop/source_parser.rb +1 -59
- data/lib/rubocop/version.rb +3 -3
- data/relnotes/0.19.0.md +70 -0
- data/rubocop-todo.yml +6 -6
- data/rubocop.gemspec +2 -1
- data/spec/rubocop/cli_spec.rb +431 -268
- data/spec/rubocop/comment_config_spec.rb +103 -0
- data/spec/rubocop/config_loader_spec.rb +4 -4
- data/spec/rubocop/cop/commissioner_spec.rb +7 -7
- data/spec/rubocop/cop/cop_spec.rb +17 -17
- data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +16 -16
- data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +5 -5
- data/spec/rubocop/cop/lint/assignment_in_condition_spec.rb +19 -19
- data/spec/rubocop/cop/lint/block_alignment_spec.rb +52 -52
- data/spec/rubocop/cop/lint/condition_position_spec.rb +7 -7
- data/spec/rubocop/cop/lint/debugger_spec.rb +10 -10
- data/spec/rubocop/cop/lint/deprecated_class_methods_spec.rb +33 -0
- data/spec/rubocop/cop/lint/else_layout_spec.rb +7 -7
- data/spec/rubocop/cop/lint/empty_ensure_spec.rb +4 -4
- data/spec/rubocop/cop/lint/end_alignment_spec.rb +33 -34
- data/spec/rubocop/cop/lint/end_in_method_spec.rb +5 -5
- data/spec/rubocop/cop/lint/ensure_return_spec.rb +4 -4
- data/spec/rubocop/cop/lint/eval_spec.rb +8 -8
- data/spec/rubocop/cop/lint/handle_exceptions_spec.rb +4 -4
- data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +3 -3
- data/spec/rubocop/cop/lint/literal_in_condition_spec.rb +65 -10
- data/spec/rubocop/cop/lint/literal_in_interpolation_spec.rb +21 -0
- data/spec/rubocop/cop/lint/loop_spec.rb +6 -6
- data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +14 -14
- data/spec/rubocop/cop/lint/require_parentheses_spec.rb +15 -15
- data/spec/rubocop/cop/lint/rescue_exception_spec.rb +21 -21
- data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +16 -16
- data/spec/rubocop/cop/lint/string_conversion_in_interpolation_spec.rb +27 -0
- data/spec/rubocop/cop/lint/syntax_spec.rb +11 -11
- data/spec/rubocop/cop/lint/unreachable_code_spec.rb +8 -8
- data/spec/rubocop/cop/lint/useless_assignment_spec.rb +207 -169
- data/spec/rubocop/cop/lint/useless_comparison_spec.rb +5 -5
- data/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb +4 -4
- data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +17 -17
- data/spec/rubocop/cop/lint/void_spec.rb +8 -8
- data/spec/rubocop/cop/{offence_spec.rb → offense_spec.rb} +17 -17
- data/spec/rubocop/cop/rails/action_filter_spec.rb +69 -0
- data/spec/rubocop/cop/rails/default_scope_spec.rb +9 -9
- data/spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb +2 -2
- data/spec/rubocop/cop/rails/output_spec.rb +8 -18
- data/spec/rubocop/cop/rails/read_attribute_spec.rb +2 -2
- data/spec/rubocop/cop/rails/scope_args_spec.rb +25 -0
- data/spec/rubocop/cop/rails/validation_spec.rb +3 -3
- data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +38 -38
- data/spec/rubocop/cop/style/accessor_method_name_spec.rb +14 -14
- data/spec/rubocop/cop/style/alias_spec.rb +11 -11
- data/spec/rubocop/cop/style/align_array_spec.rb +23 -7
- data/spec/rubocop/cop/style/align_hash_spec.rb +111 -30
- data/spec/rubocop/cop/style/align_parameters_spec.rb +260 -187
- data/spec/rubocop/cop/style/and_or_spec.rb +6 -6
- data/spec/rubocop/cop/style/ascii_comments_spec.rb +3 -3
- data/spec/rubocop/cop/style/ascii_identifiers_spec.rb +5 -5
- data/spec/rubocop/cop/style/attr_spec.rb +2 -2
- data/spec/rubocop/cop/style/begin_block_spec.rb +2 -2
- data/spec/rubocop/cop/style/block_comments_spec.rb +3 -3
- data/spec/rubocop/cop/style/block_nesting_spec.rb +26 -26
- data/spec/rubocop/cop/style/blocks_spec.rb +8 -8
- data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +8 -8
- data/spec/rubocop/cop/style/case_equality_spec.rb +2 -2
- data/spec/rubocop/cop/style/case_indentation_spec.rb +21 -21
- data/spec/rubocop/cop/style/character_literal_spec.rb +6 -6
- data/spec/rubocop/cop/style/class_and_module_camel_case_spec.rb +4 -4
- data/spec/rubocop/cop/style/class_and_module_children_spec.rb +129 -0
- data/spec/rubocop/cop/style/class_length_spec.rb +9 -9
- data/spec/rubocop/cop/style/class_methods_spec.rb +8 -8
- data/spec/rubocop/cop/style/class_vars_spec.rb +4 -4
- data/spec/rubocop/cop/style/collection_methods_spec.rb +6 -6
- data/spec/rubocop/cop/style/colon_method_call_spec.rb +16 -16
- data/spec/rubocop/cop/style/comment_annotation_spec.rb +16 -16
- data/spec/rubocop/cop/style/constant_name_spec.rb +12 -12
- data/spec/rubocop/cop/style/cyclomatic_complexity_spec.rb +16 -16
- data/spec/rubocop/cop/style/def_with_parentheses_spec.rb +6 -6
- data/spec/rubocop/cop/style/documentation_spec.rb +14 -14
- data/spec/rubocop/cop/style/dot_position_spec.rb +23 -26
- data/spec/rubocop/cop/style/double_negation_spec.rb +22 -0
- data/spec/rubocop/cop/style/empty_line_between_defs_spec.rb +22 -14
- data/spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb +4 -4
- data/spec/rubocop/cop/style/empty_lines_around_body_spec.rb +20 -20
- data/spec/rubocop/cop/style/empty_lines_spec.rb +17 -6
- data/spec/rubocop/cop/style/empty_literal_spec.rb +20 -20
- data/spec/rubocop/cop/style/encoding_spec.rb +5 -5
- data/spec/rubocop/cop/style/end_block_spec.rb +2 -2
- data/spec/rubocop/cop/style/end_of_line_spec.rb +4 -4
- data/spec/rubocop/cop/style/even_odd_spec.rb +18 -18
- data/spec/rubocop/cop/style/favor_join_spec.rb +7 -7
- data/spec/rubocop/cop/style/favor_unless_over_negated_if_spec.rb +7 -7
- data/spec/rubocop/cop/style/favor_until_over_negated_while_spec.rb +3 -3
- data/spec/rubocop/cop/style/file_name_spec.rb +71 -0
- data/spec/rubocop/cop/style/final_newline_spec.rb +4 -4
- data/spec/rubocop/cop/style/flip_flop_spec.rb +4 -4
- data/spec/rubocop/cop/style/for_spec.rb +13 -13
- data/spec/rubocop/cop/style/format_string_spec.rb +136 -0
- data/spec/rubocop/cop/style/global_vars_spec.rb +7 -7
- data/spec/rubocop/cop/style/hash_methods_spec.rb +6 -6
- data/spec/rubocop/cop/style/hash_syntax_spec.rb +11 -11
- data/spec/rubocop/cop/style/if_unless_modifier_spec.rb +29 -11
- data/spec/rubocop/cop/style/if_with_semicolon_spec.rb +1 -1
- data/spec/rubocop/cop/style/indent_array_spec.rb +136 -0
- data/spec/rubocop/cop/style/indent_hash_spec.rb +238 -0
- data/spec/rubocop/cop/style/indentation_consistency_spec.rb +69 -49
- data/spec/rubocop/cop/style/indentation_width_spec.rb +264 -128
- data/spec/rubocop/cop/style/lambda_call_spec.rb +14 -14
- data/spec/rubocop/cop/style/lambda_spec.rb +7 -7
- data/spec/rubocop/cop/style/leading_comment_space_spec.rb +15 -15
- data/spec/rubocop/cop/style/line_end_concatenation_spec.rb +11 -4
- data/spec/rubocop/cop/style/line_length_spec.rb +5 -5
- data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +5 -5
- data/spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb +9 -9
- data/spec/rubocop/cop/style/method_def_parentheses_spec.rb +19 -19
- data/spec/rubocop/cop/style/method_length_spec.rb +17 -17
- data/spec/rubocop/cop/style/method_name_spec.rb +21 -21
- data/spec/rubocop/cop/style/module_function_spec.rb +3 -3
- data/spec/rubocop/cop/style/multiline_block_chain_spec.rb +13 -13
- data/spec/rubocop/cop/style/multiline_if_then_spec.rb +10 -10
- data/spec/rubocop/cop/style/multiline_ternary_operator_spec.rb +3 -3
- data/spec/rubocop/cop/style/nested_ternary_operator_spec.rb +3 -3
- data/spec/rubocop/cop/style/nil_comparison_spec.rb +7 -7
- data/spec/rubocop/cop/style/not_spec.rb +6 -11
- data/spec/rubocop/cop/style/numeric_literals_spec.rb +8 -8
- data/spec/rubocop/cop/style/one_line_conditional_spec.rb +1 -1
- data/spec/rubocop/cop/style/op_method_spec.rb +13 -13
- data/spec/rubocop/cop/style/parameter_lists_spec.rb +6 -6
- data/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +11 -10
- data/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb +250 -0
- data/spec/rubocop/cop/style/perl_backrefs_spec.rb +2 -2
- data/spec/rubocop/cop/style/predicate_name_spec.rb +3 -3
- data/spec/rubocop/cop/style/proc_spec.rb +4 -4
- data/spec/rubocop/cop/style/raise_args_spec.rb +20 -20
- data/spec/rubocop/cop/style/redundant_begin_spec.rb +6 -6
- data/spec/rubocop/cop/style/redundant_exception_spec.rb +6 -6
- data/spec/rubocop/cop/style/redundant_return_spec.rb +22 -22
- data/spec/rubocop/cop/style/redundant_self_spec.rb +14 -14
- data/spec/rubocop/cop/style/regexp_literal_spec.rb +88 -67
- data/spec/rubocop/cop/style/rescue_modifier_spec.rb +17 -17
- data/spec/rubocop/cop/style/self_assignment_spec.rb +43 -0
- data/spec/rubocop/cop/style/semicolon_spec.rb +31 -17
- data/spec/rubocop/cop/style/signal_exception_spec.rb +29 -29
- data/spec/rubocop/cop/style/single_line_block_params_spec.rb +6 -6
- data/spec/rubocop/cop/style/single_line_methods_spec.rb +44 -6
- data/spec/rubocop/cop/style/space_after_colon_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_after_comma_spec.rb +3 -3
- data/spec/rubocop/cop/style/space_after_control_keyword_spec.rb +12 -12
- data/spec/rubocop/cop/style/space_after_method_name_spec.rb +8 -8
- data/spec/rubocop/cop/style/space_after_not_spec.rb +3 -3
- data/spec/rubocop/cop/style/space_after_semicolon_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_around_equals_in_parameter_default_spec.rb +63 -21
- data/spec/rubocop/cop/style/space_around_operators_spec.rb +24 -24
- data/spec/rubocop/cop/style/space_before_block_braces_spec.rb +72 -0
- data/spec/rubocop/cop/style/space_before_modifier_keyword_spec.rb +4 -4
- data/spec/rubocop/cop/style/{space_around_block_braces_spec.rb → space_inside_block_braces_spec.rb} +39 -41
- data/spec/rubocop/cop/style/space_inside_brackets_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_inside_hash_literal_braces_spec.rb +15 -15
- data/spec/rubocop/cop/style/space_inside_parens_spec.rb +1 -1
- data/spec/rubocop/cop/style/special_global_vars_spec.rb +10 -10
- data/spec/rubocop/cop/style/string_literals_spec.rb +31 -31
- data/spec/rubocop/cop/style/symbol_array_spec.rb +9 -9
- data/spec/rubocop/cop/style/tab_spec.rb +3 -3
- data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +3 -3
- data/spec/rubocop/cop/style/trailing_comma_spec.rb +32 -32
- data/spec/rubocop/cop/style/trailing_whitespace_spec.rb +5 -5
- data/spec/rubocop/cop/style/trivial_accessors_spec.rb +39 -39
- data/spec/rubocop/cop/style/unless_else_spec.rb +1 -1
- data/spec/rubocop/cop/style/variable_interpolation_spec.rb +12 -12
- data/spec/rubocop/cop/style/variable_name_spec.rb +21 -21
- data/spec/rubocop/cop/style/when_then_spec.rb +1 -1
- data/spec/rubocop/cop/style/while_until_do_spec.rb +8 -8
- data/spec/rubocop/cop/style/while_until_modifier_spec.rb +25 -7
- data/spec/rubocop/cop/style/word_array_spec.rb +23 -23
- data/spec/rubocop/cop/team_spec.rb +14 -14
- data/spec/rubocop/file_inspector_spec.rb +14 -12
- data/spec/rubocop/formatter/base_formatter_spec.rb +19 -19
- data/spec/rubocop/formatter/clang_style_formatter_spec.rb +14 -14
- data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +7 -7
- data/spec/rubocop/formatter/emacs_style_formatter_spec.rb +7 -7
- data/spec/rubocop/formatter/file_list_formatter_spec.rb +4 -4
- data/spec/rubocop/formatter/fuubar_style_formatter_spec.rb +129 -0
- data/spec/rubocop/formatter/json_formatter_spec.rb +23 -19
- data/spec/rubocop/formatter/offense_count_formatter_spec.rb +77 -0
- data/spec/rubocop/formatter/progress_formatter_spec.rb +27 -27
- data/spec/rubocop/formatter/simple_text_formatter_spec.rb +16 -16
- data/spec/rubocop/options_spec.rb +7 -8
- data/spec/rubocop/source_parser_spec.rb +0 -54
- data/spec/spec_helper.rb +11 -7
- data/spec/support/file_helper.rb +1 -1
- data/spec/support/mri_syntax_checker.rb +4 -4
- data/spec/support/shared_examples.rb +6 -6
- data/spec/support/statement_modifier_helper.rb +3 -3
- metadata +76 -16
- data/lib/rubocop/cop/style/favor_sprintf.rb +0 -26
- data/lib/rubocop/formatter/offence_count_formatter.rb +0 -49
- data/spec/rubocop/cop/style/favor_sprintf_spec.rb +0 -47
- data/spec/rubocop/formatter/offence_count_formatter_spec.rb +0 -52
@@ -18,12 +18,12 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
18
18
|
]
|
19
19
|
end
|
20
20
|
|
21
|
-
it 'registers an
|
21
|
+
it 'registers an offense' do
|
22
22
|
inspect_source(cop, source)
|
23
|
-
expect(cop.
|
24
|
-
expect(cop.
|
23
|
+
expect(cop.offenses.size).to eq(1)
|
24
|
+
expect(cop.offenses.first.message)
|
25
25
|
.to include('Shadowing outer local variable - foo')
|
26
|
-
expect(cop.
|
26
|
+
expect(cop.offenses.first.line).to eq(4)
|
27
27
|
end
|
28
28
|
|
29
29
|
include_examples 'mimics MRI 2.1'
|
@@ -42,12 +42,12 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
42
42
|
]
|
43
43
|
end
|
44
44
|
|
45
|
-
it 'registers an
|
45
|
+
it 'registers an offense' do
|
46
46
|
inspect_source(cop, source)
|
47
|
-
expect(cop.
|
48
|
-
expect(cop.
|
47
|
+
expect(cop.offenses.size).to eq(1)
|
48
|
+
expect(cop.offenses.first.message)
|
49
49
|
.to include('Shadowing outer local variable - foo')
|
50
|
-
expect(cop.
|
50
|
+
expect(cop.offenses.first.line).to eq(4)
|
51
51
|
end
|
52
52
|
|
53
53
|
include_examples 'mimics MRI 2.1'
|
@@ -68,12 +68,12 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
68
68
|
]
|
69
69
|
end
|
70
70
|
|
71
|
-
it 'registers an
|
71
|
+
it 'registers an offense' do
|
72
72
|
inspect_source(cop, source)
|
73
|
-
expect(cop.
|
74
|
-
expect(cop.
|
73
|
+
expect(cop.offenses.size).to eq(1)
|
74
|
+
expect(cop.offenses.first.message)
|
75
75
|
.to include('Shadowing outer local variable - foo')
|
76
|
-
expect(cop.
|
76
|
+
expect(cop.offenses.first.line).to eq(4)
|
77
77
|
end
|
78
78
|
|
79
79
|
include_examples 'mimics MRI 2.1'
|
@@ -93,12 +93,12 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
93
93
|
]
|
94
94
|
end
|
95
95
|
|
96
|
-
it 'registers an
|
96
|
+
it 'registers an offense' do
|
97
97
|
inspect_source(cop, source)
|
98
|
-
expect(cop.
|
99
|
-
expect(cop.
|
98
|
+
expect(cop.offenses.size).to eq(1)
|
99
|
+
expect(cop.offenses.first.message)
|
100
100
|
.to include('Shadowing outer local variable - foo')
|
101
|
-
expect(cop.
|
101
|
+
expect(cop.offenses.first.line).to eq(4)
|
102
102
|
end
|
103
103
|
|
104
104
|
include_examples 'mimics MRI 2.1', 'shadowing'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Rubocop::Cop::Lint::StringConversionInInterpolation do
|
6
|
+
subject(:cop) { described_class.new }
|
7
|
+
|
8
|
+
it 'registers an offense for #to_s in interpolation' do
|
9
|
+
inspect_source(cop, '"this is the #{result.to_s}"')
|
10
|
+
expect(cop.offenses.size).to eq(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'detects #to_s in an interpolation with several expressions' do
|
14
|
+
inspect_source(cop, '"this is the #{top; result.to_s}"')
|
15
|
+
expect(cop.offenses.size).to eq(1)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'accepts #to_s with arguments in an interpolation' do
|
19
|
+
inspect_source(cop, '"this is a #{result.to_s(8)}"')
|
20
|
+
expect(cop.offenses).to be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'accepts interpolation without #to_s' do
|
24
|
+
inspect_source(cop, '"this is the #{result}"')
|
25
|
+
expect(cop.offenses).to be_empty
|
26
|
+
end
|
27
|
+
end
|
@@ -3,32 +3,32 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Rubocop::Cop::Lint::Syntax do
|
6
|
-
describe '.
|
7
|
-
subject(:
|
6
|
+
describe '.offense_from_diagnostic' do
|
7
|
+
subject(:offense) { described_class.offense_from_diagnostic(diagnostic) }
|
8
8
|
let(:diagnostic) { Parser::Diagnostic.new(level, reason, args, location) }
|
9
9
|
let(:level) { :warning }
|
10
10
|
let(:reason) { :odd_hash }
|
11
11
|
let(:args) { [] }
|
12
12
|
let(:location) { double('location').as_null_object }
|
13
13
|
|
14
|
-
it 'returns an
|
15
|
-
expect(
|
14
|
+
it 'returns an offense' do
|
15
|
+
expect(offense).to be_a(Rubocop::Cop::Offense)
|
16
16
|
end
|
17
17
|
|
18
|
-
it "sets diagnostic's level to
|
19
|
-
expect(
|
18
|
+
it "sets diagnostic's level to offense's severity" do
|
19
|
+
expect(offense.severity).to eq(level)
|
20
20
|
end
|
21
21
|
|
22
|
-
it "sets diagnostic's message to
|
23
|
-
expect(
|
22
|
+
it "sets diagnostic's message to offense's message" do
|
23
|
+
expect(offense.message).to eq('odd number of entries for a hash')
|
24
24
|
end
|
25
25
|
|
26
|
-
it "sets diagnostic's location to
|
27
|
-
expect(
|
26
|
+
it "sets diagnostic's location to offense's location" do
|
27
|
+
expect(offense.location).to eq(location)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'sets Syntax as a cop name' do
|
31
|
-
expect(
|
31
|
+
expect(offense.cop_name).to eq('Syntax')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -6,13 +6,13 @@ describe Rubocop::Cop::Lint::UnreachableCode do
|
|
6
6
|
subject(:cop) { described_class.new }
|
7
7
|
|
8
8
|
described_class::NODE_TYPES.each do |t|
|
9
|
-
it "registers an
|
9
|
+
it "registers an offense for #{t} before other statements" do
|
10
10
|
inspect_source(cop,
|
11
11
|
['foo = 5',
|
12
12
|
"#{t}",
|
13
13
|
'bar'
|
14
14
|
])
|
15
|
-
expect(cop.
|
15
|
+
expect(cop.offenses.size).to eq(1)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "accepts code with conditional #{t}" do
|
@@ -21,7 +21,7 @@ describe Rubocop::Cop::Lint::UnreachableCode do
|
|
21
21
|
"#{t} if test",
|
22
22
|
'bar'
|
23
23
|
])
|
24
|
-
expect(cop.
|
24
|
+
expect(cop.offenses).to be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it "accepts #{t} as the final expression" do
|
@@ -29,18 +29,18 @@ describe Rubocop::Cop::Lint::UnreachableCode do
|
|
29
29
|
['foo = 5',
|
30
30
|
"#{t} if test"
|
31
31
|
])
|
32
|
-
expect(cop.
|
32
|
+
expect(cop.offenses).to be_empty
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
described_class::FLOW_COMMANDS.each do |t|
|
37
|
-
it "registers an
|
37
|
+
it "registers an offense for #{t} before other statements" do
|
38
38
|
inspect_source(cop,
|
39
39
|
['foo = 5',
|
40
40
|
"#{t} something",
|
41
41
|
'bar'
|
42
42
|
])
|
43
|
-
expect(cop.
|
43
|
+
expect(cop.offenses.size).to eq(1)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "accepts code with conditional #{t}" do
|
@@ -49,7 +49,7 @@ describe Rubocop::Cop::Lint::UnreachableCode do
|
|
49
49
|
"#{t} something if test",
|
50
50
|
'bar'
|
51
51
|
])
|
52
|
-
expect(cop.
|
52
|
+
expect(cop.offenses).to be_empty
|
53
53
|
end
|
54
54
|
|
55
55
|
it "accepts #{t} as the final expression" do
|
@@ -57,7 +57,7 @@ describe Rubocop::Cop::Lint::UnreachableCode do
|
|
57
57
|
['foo = 5',
|
58
58
|
"#{t} something if test"
|
59
59
|
])
|
60
|
-
expect(cop.
|
60
|
+
expect(cop.offenses).to be_empty
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -20,12 +20,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
20
20
|
]
|
21
21
|
end
|
22
22
|
|
23
|
-
it 'registers an
|
23
|
+
it 'registers an offense' do
|
24
24
|
inspect_source(cop, source)
|
25
|
-
expect(cop.
|
26
|
-
expect(cop.
|
25
|
+
expect(cop.offenses.size).to eq(1)
|
26
|
+
expect(cop.offenses.first.message)
|
27
27
|
.to eq('Useless assignment to variable - foo')
|
28
|
-
expect(cop.
|
28
|
+
expect(cop.offenses.first.line).to eq(5)
|
29
29
|
expect(cop.highlights).to eq(['foo'])
|
30
30
|
end
|
31
31
|
|
@@ -48,12 +48,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
48
48
|
]
|
49
49
|
end
|
50
50
|
|
51
|
-
it 'registers an
|
51
|
+
it 'registers an offense' do
|
52
52
|
inspect_source(cop, source)
|
53
|
-
expect(cop.
|
54
|
-
expect(cop.
|
53
|
+
expect(cop.offenses.size).to eq(1)
|
54
|
+
expect(cop.offenses.first.message)
|
55
55
|
.to eq('Useless assignment to variable - foo')
|
56
|
-
expect(cop.
|
56
|
+
expect(cop.offenses.first.line).to eq(5)
|
57
57
|
expect(cop.highlights).to eq(['foo'])
|
58
58
|
end
|
59
59
|
|
@@ -77,12 +77,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
77
77
|
]
|
78
78
|
end
|
79
79
|
|
80
|
-
it 'registers an
|
80
|
+
it 'registers an offense' do
|
81
81
|
inspect_source(cop, source)
|
82
|
-
expect(cop.
|
83
|
-
expect(cop.
|
82
|
+
expect(cop.offenses.size).to eq(1)
|
83
|
+
expect(cop.offenses.first.message)
|
84
84
|
.to eq('Useless assignment to variable - foo')
|
85
|
-
expect(cop.
|
85
|
+
expect(cop.offenses.first.line).to eq(6)
|
86
86
|
expect(cop.highlights).to eq(['foo'])
|
87
87
|
end
|
88
88
|
|
@@ -104,12 +104,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
104
104
|
]
|
105
105
|
end
|
106
106
|
|
107
|
-
it 'registers an
|
107
|
+
it 'registers an offense' do
|
108
108
|
inspect_source(cop, source)
|
109
|
-
expect(cop.
|
110
|
-
expect(cop.
|
109
|
+
expect(cop.offenses.size).to eq(1)
|
110
|
+
expect(cop.offenses.first.message)
|
111
111
|
.to eq('Useless assignment to variable - foo')
|
112
|
-
expect(cop.
|
112
|
+
expect(cop.offenses.first.line).to eq(5)
|
113
113
|
expect(cop.highlights).to eq(['foo'])
|
114
114
|
end
|
115
115
|
|
@@ -133,12 +133,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
133
133
|
]
|
134
134
|
end
|
135
135
|
|
136
|
-
it 'registers an
|
136
|
+
it 'registers an offense' do
|
137
137
|
inspect_source(cop, source)
|
138
|
-
expect(cop.
|
139
|
-
expect(cop.
|
138
|
+
expect(cop.offenses.size).to eq(1)
|
139
|
+
expect(cop.offenses.first.message)
|
140
140
|
.to eq('Useless assignment to variable - foo')
|
141
|
-
expect(cop.
|
141
|
+
expect(cop.offenses.first.line).to eq(6)
|
142
142
|
expect(cop.highlights).to eq(['foo'])
|
143
143
|
end
|
144
144
|
|
@@ -162,12 +162,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
162
162
|
]
|
163
163
|
end
|
164
164
|
|
165
|
-
it 'registers an
|
165
|
+
it 'registers an offense' do
|
166
166
|
inspect_source(cop, source)
|
167
|
-
expect(cop.
|
168
|
-
expect(cop.
|
167
|
+
expect(cop.offenses.size).to eq(1)
|
168
|
+
expect(cop.offenses.first.message)
|
169
169
|
.to eq('Useless assignment to variable - foo')
|
170
|
-
expect(cop.
|
170
|
+
expect(cop.offenses.first.line).to eq(6)
|
171
171
|
expect(cop.highlights).to eq(['foo'])
|
172
172
|
end
|
173
173
|
|
@@ -189,12 +189,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
189
189
|
]
|
190
190
|
end
|
191
191
|
|
192
|
-
it 'registers an
|
192
|
+
it 'registers an offense' do
|
193
193
|
inspect_source(cop, source)
|
194
|
-
expect(cop.
|
195
|
-
expect(cop.
|
194
|
+
expect(cop.offenses.size).to eq(1)
|
195
|
+
expect(cop.offenses.first.message)
|
196
196
|
.to eq('Useless assignment to variable - foo')
|
197
|
-
expect(cop.
|
197
|
+
expect(cop.offenses.first.line).to eq(5)
|
198
198
|
expect(cop.highlights).to eq(['foo'])
|
199
199
|
end
|
200
200
|
|
@@ -210,12 +210,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
210
210
|
]
|
211
211
|
end
|
212
212
|
|
213
|
-
it 'registers an
|
213
|
+
it 'registers an offense' do
|
214
214
|
inspect_source(cop, source)
|
215
|
-
expect(cop.
|
216
|
-
expect(cop.
|
215
|
+
expect(cop.offenses.size).to eq(1)
|
216
|
+
expect(cop.offenses.first.message)
|
217
217
|
.to eq('Useless assignment to variable - foo')
|
218
|
-
expect(cop.
|
218
|
+
expect(cop.offenses.first.line).to eq(1)
|
219
219
|
expect(cop.highlights).to eq(['foo'])
|
220
220
|
end
|
221
221
|
|
@@ -230,12 +230,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
230
230
|
]
|
231
231
|
end
|
232
232
|
|
233
|
-
it 'registers an
|
233
|
+
it 'registers an offense' do
|
234
234
|
inspect_source(cop, source)
|
235
|
-
expect(cop.
|
236
|
-
expect(cop.
|
235
|
+
expect(cop.offenses.size).to eq(1)
|
236
|
+
expect(cop.offenses.first.message)
|
237
237
|
.to eq('Useless assignment to variable - foo. Use just operator ||.')
|
238
|
-
expect(cop.
|
238
|
+
expect(cop.offenses.first.line).to eq(1)
|
239
239
|
expect(cop.highlights).to eq(['foo'])
|
240
240
|
end
|
241
241
|
end
|
@@ -253,17 +253,17 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
253
253
|
]
|
254
254
|
end
|
255
255
|
|
256
|
-
it 'registers
|
256
|
+
it 'registers offenses for each asignment' do
|
257
257
|
inspect_source(cop, source)
|
258
|
-
expect(cop.
|
258
|
+
expect(cop.offenses.size).to eq(2)
|
259
259
|
|
260
|
-
expect(cop.
|
260
|
+
expect(cop.offenses[0].message)
|
261
261
|
.to eq('Useless assignment to variable - foo')
|
262
|
-
expect(cop.
|
262
|
+
expect(cop.offenses[0].line).to eq(2)
|
263
263
|
|
264
|
-
expect(cop.
|
264
|
+
expect(cop.offenses[1].message)
|
265
265
|
.to eq('Useless assignment to variable - foo')
|
266
|
-
expect(cop.
|
266
|
+
expect(cop.offenses[1].line).to eq(4)
|
267
267
|
|
268
268
|
expect(cop.highlights).to eq(%w(foo foo))
|
269
269
|
end
|
@@ -281,12 +281,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
281
281
|
]
|
282
282
|
end
|
283
283
|
|
284
|
-
it 'registers an
|
284
|
+
it 'registers an offense for the non-re-referenced assignment' do
|
285
285
|
inspect_source(cop, source)
|
286
|
-
expect(cop.
|
287
|
-
expect(cop.
|
286
|
+
expect(cop.offenses.size).to eq(1)
|
287
|
+
expect(cop.offenses.first.message)
|
288
288
|
.to eq('Useless assignment to variable - foo')
|
289
|
-
expect(cop.
|
289
|
+
expect(cop.offenses.first.line).to eq(4)
|
290
290
|
expect(cop.highlights).to eq(['foo'])
|
291
291
|
end
|
292
292
|
end
|
@@ -303,12 +303,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
303
303
|
]
|
304
304
|
end
|
305
305
|
|
306
|
-
it 'registers an
|
306
|
+
it 'registers an offense for the unreferenced assignment' do
|
307
307
|
inspect_source(cop, source)
|
308
|
-
expect(cop.
|
309
|
-
expect(cop.
|
308
|
+
expect(cop.offenses.size).to eq(1)
|
309
|
+
expect(cop.offenses.first.message)
|
310
310
|
.to eq('Useless assignment to variable - foo')
|
311
|
-
expect(cop.
|
311
|
+
expect(cop.offenses.first.line).to eq(2)
|
312
312
|
expect(cop.highlights).to eq(['foo'])
|
313
313
|
end
|
314
314
|
end
|
@@ -362,12 +362,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
362
362
|
]
|
363
363
|
end
|
364
364
|
|
365
|
-
it 'registers an
|
365
|
+
it 'registers an offense for the declaration' do
|
366
366
|
inspect_source(cop, source)
|
367
|
-
expect(cop.
|
368
|
-
expect(cop.
|
367
|
+
expect(cop.offenses.size).to eq(1)
|
368
|
+
expect(cop.offenses.first.message)
|
369
369
|
.to eq('Useless assignment to variable - foo')
|
370
|
-
expect(cop.
|
370
|
+
expect(cop.offenses.first.line).to eq(1)
|
371
371
|
expect(cop.highlights).to eq(['foo'])
|
372
372
|
end
|
373
373
|
|
@@ -383,12 +383,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
383
383
|
]
|
384
384
|
end
|
385
385
|
|
386
|
-
it 'registers
|
386
|
+
it 'registers offenses for the assignment' do
|
387
387
|
inspect_source(cop, source)
|
388
|
-
expect(cop.
|
389
|
-
expect(cop.
|
388
|
+
expect(cop.offenses.size).to eq(1)
|
389
|
+
expect(cop.offenses.first.message)
|
390
390
|
.to eq('Useless assignment to variable - foo')
|
391
|
-
expect(cop.
|
391
|
+
expect(cop.offenses.first.line).to eq(2)
|
392
392
|
expect(cop.highlights).to eq(['foo'])
|
393
393
|
end
|
394
394
|
end
|
@@ -404,12 +404,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
404
404
|
]
|
405
405
|
end
|
406
406
|
|
407
|
-
it 'registers an
|
407
|
+
it 'registers an offense' do
|
408
408
|
inspect_source(cop, source)
|
409
|
-
expect(cop.
|
410
|
-
expect(cop.
|
409
|
+
expect(cop.offenses.size).to eq(1)
|
410
|
+
expect(cop.offenses.first.message)
|
411
411
|
.to eq('Useless assignment to variable - foo')
|
412
|
-
expect(cop.
|
412
|
+
expect(cop.offenses.first.line).to eq(3)
|
413
413
|
expect(cop.highlights).to eq(['foo'])
|
414
414
|
end
|
415
415
|
|
@@ -460,6 +460,23 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
460
460
|
include_examples 'mimics MRI 2.1'
|
461
461
|
end
|
462
462
|
|
463
|
+
context 'when a setter is invoked with operator assignment in loop body' do
|
464
|
+
let(:source) do
|
465
|
+
[
|
466
|
+
'def some_method',
|
467
|
+
' obj = {}',
|
468
|
+
'',
|
469
|
+
' while obj[:count] < 100',
|
470
|
+
' obj[:count] += 1',
|
471
|
+
' end',
|
472
|
+
'end'
|
473
|
+
]
|
474
|
+
end
|
475
|
+
|
476
|
+
include_examples 'accepts'
|
477
|
+
include_examples 'mimics MRI 2.1'
|
478
|
+
end
|
479
|
+
|
463
480
|
context "when a variable is reassigned in loop body but won't " \
|
464
481
|
'be referenced either next iteration or loop condition' do
|
465
482
|
let(:source) do
|
@@ -478,12 +495,14 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
478
495
|
]
|
479
496
|
end
|
480
497
|
|
481
|
-
it 'registers an
|
498
|
+
it 'registers an offense' do
|
499
|
+
pending 'Requires an advanced logic that checks whether the return ' \
|
500
|
+
'value of an operator assignment is used or not.'
|
482
501
|
inspect_source(cop, source)
|
483
|
-
expect(cop.
|
484
|
-
expect(cop.
|
502
|
+
expect(cop.offenses.size).to eq(1)
|
503
|
+
expect(cop.offenses.first.message)
|
485
504
|
.to eq('Useless assignment to variable - foo')
|
486
|
-
expect(cop.
|
505
|
+
expect(cop.offenses.first.line).to eq(7)
|
487
506
|
expect(cop.highlights).to eq(['foo'])
|
488
507
|
end
|
489
508
|
end
|
@@ -502,12 +521,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
502
521
|
]
|
503
522
|
end
|
504
523
|
|
505
|
-
it 'registers an
|
524
|
+
it 'registers an offense' do
|
506
525
|
inspect_source(cop, source)
|
507
|
-
expect(cop.
|
508
|
-
expect(cop.
|
526
|
+
expect(cop.offenses.size).to eq(1)
|
527
|
+
expect(cop.offenses.first.message)
|
509
528
|
.to eq('Useless assignment to variable - foo')
|
510
|
-
expect(cop.
|
529
|
+
expect(cop.offenses.first.line).to eq(5)
|
511
530
|
expect(cop.highlights).to eq(['foo'])
|
512
531
|
end
|
513
532
|
end
|
@@ -527,12 +546,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
527
546
|
]
|
528
547
|
end
|
529
548
|
|
530
|
-
it 'registers an
|
549
|
+
it 'registers an offense' do
|
531
550
|
inspect_source(cop, source)
|
532
|
-
expect(cop.
|
533
|
-
expect(cop.
|
551
|
+
expect(cop.offenses.size).to eq(1)
|
552
|
+
expect(cop.offenses.first.message)
|
534
553
|
.to eq('Useless assignment to variable - foo')
|
535
|
-
expect(cop.
|
554
|
+
expect(cop.offenses.first.line).to eq(6)
|
536
555
|
expect(cop.highlights).to eq(['foo'])
|
537
556
|
end
|
538
557
|
end
|
@@ -549,12 +568,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
549
568
|
]
|
550
569
|
end
|
551
570
|
|
552
|
-
it 'registers an
|
571
|
+
it 'registers an offense' do
|
553
572
|
inspect_source(cop, source)
|
554
|
-
expect(cop.
|
555
|
-
expect(cop.
|
573
|
+
expect(cop.offenses.size).to eq(1)
|
574
|
+
expect(cop.offenses.first.message)
|
556
575
|
.to eq('Useless assignment to variable - foo')
|
557
|
-
expect(cop.
|
576
|
+
expect(cop.offenses.first.line).to eq(3)
|
558
577
|
expect(cop.highlights).to eq(['foo'])
|
559
578
|
end
|
560
579
|
|
@@ -576,12 +595,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
576
595
|
]
|
577
596
|
end
|
578
597
|
|
579
|
-
it 'registers an
|
598
|
+
it 'registers an offense for the unreferenced assignment' do
|
580
599
|
inspect_source(cop, source)
|
581
|
-
expect(cop.
|
582
|
-
expect(cop.
|
600
|
+
expect(cop.offenses.size).to eq(1)
|
601
|
+
expect(cop.offenses.first.message)
|
583
602
|
.to eq('Useless assignment to variable - foo')
|
584
|
-
expect(cop.
|
603
|
+
expect(cop.offenses.first.line).to eq(3)
|
585
604
|
expect(cop.highlights).to eq(['foo'])
|
586
605
|
end
|
587
606
|
end
|
@@ -641,12 +660,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
641
660
|
]
|
642
661
|
end
|
643
662
|
|
644
|
-
it 'registers an
|
663
|
+
it 'registers an offense for the unreferenced assignment' do
|
645
664
|
inspect_source(cop, source)
|
646
|
-
expect(cop.
|
647
|
-
expect(cop.
|
665
|
+
expect(cop.offenses.size).to eq(1)
|
666
|
+
expect(cop.offenses.first.message)
|
648
667
|
.to eq('Useless assignment to variable - foo')
|
649
|
-
expect(cop.
|
668
|
+
expect(cop.offenses.first.line).to eq(2)
|
650
669
|
expect(cop.highlights).to eq(['foo'])
|
651
670
|
end
|
652
671
|
end
|
@@ -666,18 +685,18 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
666
685
|
]
|
667
686
|
end
|
668
687
|
|
669
|
-
it 'registers an
|
688
|
+
it 'registers an offense for the assignment in the if branch' do
|
670
689
|
inspect_source(cop, source)
|
671
|
-
expect(cop.
|
672
|
-
expect(cop.
|
690
|
+
expect(cop.offenses.size).to eq(1)
|
691
|
+
expect(cop.offenses.first.message)
|
673
692
|
.to eq('Useless assignment to variable - foo')
|
674
|
-
expect(cop.
|
693
|
+
expect(cop.offenses.first.line).to eq(3)
|
675
694
|
expect(cop.highlights).to eq(['foo'])
|
676
695
|
end
|
677
696
|
end
|
678
697
|
|
679
698
|
context 'when a variable is assigned in branch of modifier if ' \
|
680
|
-
'that references the variable in its conditional clause'
|
699
|
+
'that references the variable in its conditional clause' \
|
681
700
|
'and referenced after the branching' do
|
682
701
|
let(:source) do
|
683
702
|
[
|
@@ -693,7 +712,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
693
712
|
end
|
694
713
|
|
695
714
|
context 'when a variable is assigned in branch of modifier if ' \
|
696
|
-
'that references the variable in its conditional clause'
|
715
|
+
'that references the variable in its conditional clause' \
|
697
716
|
'and unreferenced' do
|
698
717
|
let(:source) do
|
699
718
|
[
|
@@ -703,12 +722,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
703
722
|
]
|
704
723
|
end
|
705
724
|
|
706
|
-
it 'registers an
|
725
|
+
it 'registers an offense' do
|
707
726
|
inspect_source(cop, source)
|
708
|
-
expect(cop.
|
709
|
-
expect(cop.
|
727
|
+
expect(cop.offenses.size).to eq(1)
|
728
|
+
expect(cop.offenses.first.message)
|
710
729
|
.to eq('Useless assignment to variable - foo')
|
711
|
-
expect(cop.
|
730
|
+
expect(cop.offenses.first.line).to eq(2)
|
712
731
|
expect(cop.highlights).to eq(['foo'])
|
713
732
|
end
|
714
733
|
end
|
@@ -740,12 +759,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
740
759
|
]
|
741
760
|
end
|
742
761
|
|
743
|
-
it 'registers an
|
762
|
+
it 'registers an offense for the unreferenced assignment' do
|
744
763
|
inspect_source(cop, source)
|
745
|
-
expect(cop.
|
746
|
-
expect(cop.
|
764
|
+
expect(cop.offenses.size).to eq(1)
|
765
|
+
expect(cop.offenses.first.message)
|
747
766
|
.to eq('Useless assignment to variable - foo')
|
748
|
-
expect(cop.
|
767
|
+
expect(cop.offenses.first.line).to eq(2)
|
749
768
|
expect(cop.highlights).to eq(['foo'])
|
750
769
|
end
|
751
770
|
end
|
@@ -815,7 +834,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
815
834
|
end
|
816
835
|
|
817
836
|
context 'when a variable is reassigned with binary operator ' \
|
818
|
-
'assignment while assigning to itself in rhs '
|
837
|
+
'assignment while assigning to itself in rhs ' \
|
819
838
|
'then referenced' do
|
820
839
|
let(:source) do
|
821
840
|
[
|
@@ -827,12 +846,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
827
846
|
]
|
828
847
|
end
|
829
848
|
|
830
|
-
it 'registers an
|
849
|
+
it 'registers an offense for the assignment in rhs' do
|
831
850
|
inspect_source(cop, source)
|
832
|
-
expect(cop.
|
833
|
-
expect(cop.
|
851
|
+
expect(cop.offenses.size).to eq(1)
|
852
|
+
expect(cop.offenses.first.message)
|
834
853
|
.to eq('Useless assignment to variable - foo')
|
835
|
-
expect(cop.
|
854
|
+
expect(cop.offenses.first.line).to eq(3)
|
836
855
|
expect(cop.highlights).to eq(['foo'])
|
837
856
|
end
|
838
857
|
end
|
@@ -862,13 +881,13 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
862
881
|
]
|
863
882
|
end
|
864
883
|
|
865
|
-
it 'registers an
|
884
|
+
it 'registers an offense' do
|
866
885
|
inspect_source(cop, source)
|
867
|
-
expect(cop.
|
868
|
-
expect(cop.
|
886
|
+
expect(cop.offenses.size).to eq(1)
|
887
|
+
expect(cop.offenses.first.message).to eq(
|
869
888
|
'Useless assignment to variable - foo. Use just operator ||.'
|
870
889
|
)
|
871
|
-
expect(cop.
|
890
|
+
expect(cop.offenses.first.line).to eq(3)
|
872
891
|
expect(cop.highlights).to eq(['foo'])
|
873
892
|
end
|
874
893
|
end
|
@@ -885,12 +904,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
885
904
|
]
|
886
905
|
end
|
887
906
|
|
888
|
-
it 'registers an
|
907
|
+
it 'registers an offense' do
|
889
908
|
inspect_source(cop, source)
|
890
|
-
expect(cop.
|
891
|
-
expect(cop.
|
909
|
+
expect(cop.offenses.size).to eq(1)
|
910
|
+
expect(cop.offenses.first.message)
|
892
911
|
.to eq('Useless assignment to variable - foo')
|
893
|
-
expect(cop.
|
912
|
+
expect(cop.offenses.first.line).to eq(3)
|
894
913
|
expect(cop.highlights).to eq(['foo'])
|
895
914
|
end
|
896
915
|
end
|
@@ -906,15 +925,15 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
906
925
|
]
|
907
926
|
end
|
908
927
|
|
909
|
-
it 'registers an
|
928
|
+
it 'registers an offense' do
|
910
929
|
inspect_source(cop, source)
|
911
|
-
expect(cop.
|
912
|
-
expect(cop.
|
930
|
+
expect(cop.offenses.size).to eq(1)
|
931
|
+
expect(cop.offenses.first.message).to eq(
|
913
932
|
'Useless assignment to variable - bar. ' \
|
914
|
-
'Use _ or _bar as a variable name '
|
933
|
+
'Use _ or _bar as a variable name ' \
|
915
934
|
"to indicate that it won't be used."
|
916
935
|
)
|
917
|
-
expect(cop.
|
936
|
+
expect(cop.offenses.first.line).to eq(2)
|
918
937
|
expect(cop.highlights).to eq(['bar'])
|
919
938
|
end
|
920
939
|
|
@@ -980,12 +999,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
980
999
|
]
|
981
1000
|
end
|
982
1001
|
|
983
|
-
it 'registers an
|
1002
|
+
it 'registers an offense' do
|
984
1003
|
inspect_source(cop, source)
|
985
|
-
expect(cop.
|
986
|
-
expect(cop.
|
1004
|
+
expect(cop.offenses.size).to eq(1)
|
1005
|
+
expect(cop.offenses.first.message)
|
987
1006
|
.to eq('Useless assignment to variable - foo')
|
988
|
-
expect(cop.
|
1007
|
+
expect(cop.offenses.first.line).to eq(3)
|
989
1008
|
expect(cop.highlights).to eq(['foo'])
|
990
1009
|
end
|
991
1010
|
|
@@ -1094,12 +1113,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1094
1113
|
]
|
1095
1114
|
end
|
1096
1115
|
|
1097
|
-
it 'registers an
|
1116
|
+
it 'registers an offense' do
|
1098
1117
|
inspect_source(cop, source)
|
1099
|
-
expect(cop.
|
1100
|
-
expect(cop.
|
1118
|
+
expect(cop.offenses.size).to eq(1)
|
1119
|
+
expect(cop.offenses.first.message)
|
1101
1120
|
.to eq('Useless assignment to variable - foo')
|
1102
|
-
expect(cop.
|
1121
|
+
expect(cop.offenses.first.line).to eq(6)
|
1103
1122
|
expect(cop.highlights).to eq(['foo'])
|
1104
1123
|
end
|
1105
1124
|
end
|
@@ -1123,12 +1142,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1123
1142
|
]
|
1124
1143
|
end
|
1125
1144
|
|
1126
|
-
it 'registers an
|
1145
|
+
it 'registers an offense' do
|
1127
1146
|
inspect_source(cop, source)
|
1128
|
-
expect(cop.
|
1129
|
-
expect(cop.
|
1147
|
+
expect(cop.offenses.size).to eq(1)
|
1148
|
+
expect(cop.offenses.first.message)
|
1130
1149
|
.to eq('Useless assignment to variable - foo')
|
1131
|
-
expect(cop.
|
1150
|
+
expect(cop.offenses.first.line).to eq(6)
|
1132
1151
|
expect(cop.highlights).to eq(['foo'])
|
1133
1152
|
end
|
1134
1153
|
end
|
@@ -1150,12 +1169,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1150
1169
|
]
|
1151
1170
|
end
|
1152
1171
|
|
1153
|
-
it 'registers an
|
1172
|
+
it 'registers an offense' do
|
1154
1173
|
inspect_source(cop, source)
|
1155
|
-
expect(cop.
|
1156
|
-
expect(cop.
|
1174
|
+
expect(cop.offenses.size).to eq(1)
|
1175
|
+
expect(cop.offenses.first.message)
|
1157
1176
|
.to eq('Useless assignment to variable - foo')
|
1158
|
-
expect(cop.
|
1177
|
+
expect(cop.offenses.first.line).to eq(6)
|
1159
1178
|
expect(cop.highlights).to eq(['foo'])
|
1160
1179
|
end
|
1161
1180
|
end
|
@@ -1180,8 +1199,27 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1180
1199
|
include_examples 'mimics MRI 2.1'
|
1181
1200
|
end
|
1182
1201
|
|
1202
|
+
context 'when a variable is assigned with operator assignment ' \
|
1203
|
+
'in rescue and would be referenced with retry' do
|
1204
|
+
let(:source) do
|
1205
|
+
[
|
1206
|
+
'retry_count = 0',
|
1207
|
+
'',
|
1208
|
+
'begin',
|
1209
|
+
' do_something',
|
1210
|
+
'rescue',
|
1211
|
+
' fail if (retry_count += 1) > 3',
|
1212
|
+
' retry',
|
1213
|
+
'end'
|
1214
|
+
]
|
1215
|
+
end
|
1216
|
+
|
1217
|
+
include_examples 'accepts'
|
1218
|
+
include_examples 'mimics MRI 2.1'
|
1219
|
+
end
|
1220
|
+
|
1183
1221
|
context 'when a variable is assigned ' \
|
1184
|
-
'in main body of begin, rescue and else '
|
1222
|
+
'in main body of begin, rescue and else ' \
|
1185
1223
|
'and reassigned in ensure then referenced after the begin' do
|
1186
1224
|
let(:source) do
|
1187
1225
|
[
|
@@ -1202,14 +1240,14 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1202
1240
|
]
|
1203
1241
|
end
|
1204
1242
|
|
1205
|
-
it 'registers
|
1243
|
+
it 'registers offenses for each assignment before ensure' do
|
1206
1244
|
inspect_source(cop, source)
|
1207
|
-
expect(cop.
|
1245
|
+
expect(cop.offenses.size).to eq(4)
|
1208
1246
|
|
1209
|
-
expect(cop.
|
1210
|
-
expect(cop.
|
1211
|
-
expect(cop.
|
1212
|
-
expect(cop.
|
1247
|
+
expect(cop.offenses[0].line).to eq(3)
|
1248
|
+
expect(cop.offenses[1].line).to eq(5)
|
1249
|
+
expect(cop.offenses[2].line).to eq(7)
|
1250
|
+
expect(cop.offenses[3].line).to eq(9)
|
1213
1251
|
end
|
1214
1252
|
end
|
1215
1253
|
|
@@ -1239,12 +1277,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1239
1277
|
]
|
1240
1278
|
end
|
1241
1279
|
|
1242
|
-
it 'registers an
|
1280
|
+
it 'registers an offense' do
|
1243
1281
|
inspect_source(cop, source)
|
1244
|
-
expect(cop.
|
1245
|
-
expect(cop.
|
1282
|
+
expect(cop.offenses.size).to eq(1)
|
1283
|
+
expect(cop.offenses.first.message)
|
1246
1284
|
.to eq('Useless assignment to variable - foo')
|
1247
|
-
expect(cop.
|
1285
|
+
expect(cop.offenses.first.line).to eq(2)
|
1248
1286
|
expect(cop.highlights).to eq(['foo'])
|
1249
1287
|
end
|
1250
1288
|
|
@@ -1262,12 +1300,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1262
1300
|
]
|
1263
1301
|
end
|
1264
1302
|
|
1265
|
-
it 'registers an
|
1303
|
+
it 'registers an offense' do
|
1266
1304
|
inspect_source(cop, source)
|
1267
|
-
expect(cop.
|
1268
|
-
expect(cop.
|
1305
|
+
expect(cop.offenses.size).to eq(1)
|
1306
|
+
expect(cop.offenses.first.message)
|
1269
1307
|
.to eq('Useless assignment to variable - foo')
|
1270
|
-
expect(cop.
|
1308
|
+
expect(cop.offenses.first.line).to eq(2)
|
1271
1309
|
expect(cop.highlights).to eq(['foo'])
|
1272
1310
|
end
|
1273
1311
|
end
|
@@ -1279,12 +1317,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1279
1317
|
]
|
1280
1318
|
end
|
1281
1319
|
|
1282
|
-
it 'registers an
|
1320
|
+
it 'registers an offense' do
|
1283
1321
|
inspect_source(cop, source)
|
1284
|
-
expect(cop.
|
1285
|
-
expect(cop.
|
1322
|
+
expect(cop.offenses.size).to eq(1)
|
1323
|
+
expect(cop.offenses.first.message)
|
1286
1324
|
.to eq('Useless assignment to variable - foo')
|
1287
|
-
expect(cop.
|
1325
|
+
expect(cop.offenses.first.line).to eq(1)
|
1288
1326
|
end
|
1289
1327
|
|
1290
1328
|
include_examples 'mimics MRI 2.1'
|
@@ -1300,12 +1338,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1300
1338
|
]
|
1301
1339
|
end
|
1302
1340
|
|
1303
|
-
it 'registers an
|
1341
|
+
it 'registers an offense' do
|
1304
1342
|
inspect_source(cop, source)
|
1305
|
-
expect(cop.
|
1306
|
-
expect(cop.
|
1343
|
+
expect(cop.offenses.size).to eq(1)
|
1344
|
+
expect(cop.offenses.first.message)
|
1307
1345
|
.to eq('Useless assignment to variable - foo')
|
1308
|
-
expect(cop.
|
1346
|
+
expect(cop.offenses.first.line).to eq(2)
|
1309
1347
|
expect(cop.highlights).to eq(["/(?<foo>\w+)/"])
|
1310
1348
|
end
|
1311
1349
|
|
@@ -1374,12 +1412,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1374
1412
|
]
|
1375
1413
|
end
|
1376
1414
|
|
1377
|
-
it 'registers an
|
1415
|
+
it 'registers an offense' do
|
1378
1416
|
inspect_source(cop, source)
|
1379
|
-
expect(cop.
|
1380
|
-
expect(cop.
|
1417
|
+
expect(cop.offenses.size).to eq(1)
|
1418
|
+
expect(cop.offenses.first.message)
|
1381
1419
|
.to eq('Useless assignment to variable - foo')
|
1382
|
-
expect(cop.
|
1420
|
+
expect(cop.offenses.first.line).to eq(2)
|
1383
1421
|
expect(cop.highlights).to eq(['foo'])
|
1384
1422
|
end
|
1385
1423
|
|
@@ -1505,12 +1543,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1505
1543
|
]
|
1506
1544
|
end
|
1507
1545
|
|
1508
|
-
it 'registers an
|
1546
|
+
it 'registers an offense' do
|
1509
1547
|
inspect_source(cop, source)
|
1510
|
-
expect(cop.
|
1511
|
-
expect(cop.
|
1548
|
+
expect(cop.offenses.size).to eq(1)
|
1549
|
+
expect(cop.offenses.first.message)
|
1512
1550
|
.to eq('Useless assignment to variable - foo')
|
1513
|
-
expect(cop.
|
1551
|
+
expect(cop.offenses.first.line).to eq(1)
|
1514
1552
|
expect(cop.highlights).to eq(['foo'])
|
1515
1553
|
end
|
1516
1554
|
|
@@ -1541,12 +1579,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1541
1579
|
]
|
1542
1580
|
end
|
1543
1581
|
|
1544
|
-
it 'registers an
|
1582
|
+
it 'registers an offense' do
|
1545
1583
|
inspect_source(cop, source)
|
1546
|
-
expect(cop.
|
1547
|
-
expect(cop.
|
1584
|
+
expect(cop.offenses.size).to eq(1)
|
1585
|
+
expect(cop.offenses.first.message)
|
1548
1586
|
.to eq('Useless assignment to variable - foo')
|
1549
|
-
expect(cop.
|
1587
|
+
expect(cop.offenses.first.line).to eq(1)
|
1550
1588
|
expect(cop.highlights).to eq(['foo'])
|
1551
1589
|
end
|
1552
1590
|
|