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
@@ -3,18 +3,25 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Rubocop::Cop::Style::IndentationWidth do
|
6
|
-
subject(:cop) { described_class.new }
|
6
|
+
subject(:cop) { described_class.new(config) }
|
7
|
+
let(:config) do
|
8
|
+
Rubocop::Config.new('EndAlignment' => end_alignment_config)
|
9
|
+
end
|
10
|
+
let(:end_alignment_config) do
|
11
|
+
{ 'Enabled' => true, 'AlignWith' => 'variable' }
|
12
|
+
end
|
7
13
|
|
8
14
|
context 'with if statement' do
|
9
|
-
it 'registers an
|
15
|
+
it 'registers an offense for bad indentation of an if body' do
|
10
16
|
inspect_source(cop,
|
11
17
|
['if cond',
|
12
18
|
' func',
|
13
19
|
'end'])
|
14
20
|
expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
|
21
|
+
expect(cop.highlights).to eq([' '])
|
15
22
|
end
|
16
23
|
|
17
|
-
it 'registers an
|
24
|
+
it 'registers an offense for bad indentation of an else body' do
|
18
25
|
inspect_source(cop,
|
19
26
|
['if cond',
|
20
27
|
' func1',
|
@@ -22,9 +29,10 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
22
29
|
' func2',
|
23
30
|
'end'])
|
24
31
|
expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
|
32
|
+
expect(cop.highlights).to eq([' '])
|
25
33
|
end
|
26
34
|
|
27
|
-
it 'registers an
|
35
|
+
it 'registers an offense for bad indentation of an elsif body' do
|
28
36
|
inspect_source(cop,
|
29
37
|
['if a1',
|
30
38
|
' b1',
|
@@ -36,7 +44,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
36
44
|
expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
|
37
45
|
end
|
38
46
|
|
39
|
-
it 'registers
|
47
|
+
it 'registers offense for bad indentation of ternary inside else' do
|
40
48
|
inspect_source(cop,
|
41
49
|
['if a',
|
42
50
|
' b',
|
@@ -45,9 +53,10 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
45
53
|
'end'])
|
46
54
|
expect(cop.messages)
|
47
55
|
.to eq(['Use 2 (not 5) spaces for indentation.'])
|
56
|
+
expect(cop.highlights).to eq([' '])
|
48
57
|
end
|
49
58
|
|
50
|
-
it 'registers
|
59
|
+
it 'registers offense for bad indentation of modifier if in else' do
|
51
60
|
inspect_source(cop,
|
52
61
|
['if a',
|
53
62
|
' b',
|
@@ -58,10 +67,31 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
58
67
|
.to eq(['Use 2 (not 3) spaces for indentation.'])
|
59
68
|
end
|
60
69
|
|
70
|
+
it 'autocorrects bad indentation' do
|
71
|
+
corrected = autocorrect_source(cop,
|
72
|
+
['if a1',
|
73
|
+
' b1',
|
74
|
+
' b1',
|
75
|
+
'elsif a2',
|
76
|
+
' b2',
|
77
|
+
'else',
|
78
|
+
' c',
|
79
|
+
'end'])
|
80
|
+
expect(corrected)
|
81
|
+
.to eq ['if a1',
|
82
|
+
' b1',
|
83
|
+
' b1', # Will be corrected by IndentationConsistency.
|
84
|
+
'elsif a2',
|
85
|
+
' b2',
|
86
|
+
'else',
|
87
|
+
' c',
|
88
|
+
'end'].join("\n")
|
89
|
+
end
|
90
|
+
|
61
91
|
it 'accepts a one line if statement' do
|
62
92
|
inspect_source(cop,
|
63
93
|
['if cond then func1 else func2 end'])
|
64
|
-
expect(cop.
|
94
|
+
expect(cop.offenses).to be_empty
|
65
95
|
end
|
66
96
|
|
67
97
|
it 'accepts a correctly aligned if/elsif/else/end' do
|
@@ -73,7 +103,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
73
103
|
'else',
|
74
104
|
' c',
|
75
105
|
'end'])
|
76
|
-
expect(cop.
|
106
|
+
expect(cop.offenses).to be_empty
|
77
107
|
end
|
78
108
|
|
79
109
|
it 'accepts if/elsif/else/end laid out as a table' do
|
@@ -83,7 +113,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
83
113
|
'elsif @io == $stderr then str << "$stderr"',
|
84
114
|
'else str << @io.class.to_s',
|
85
115
|
'end'])
|
86
|
-
expect(cop.
|
116
|
+
expect(cop.offenses).to be_empty
|
87
117
|
end
|
88
118
|
|
89
119
|
it 'accepts if/then/else/end laid out as another table' do
|
@@ -92,7 +122,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
92
122
|
'then ConfigTable.load',
|
93
123
|
'else ConfigTable.new',
|
94
124
|
'end'])
|
95
|
-
expect(cop.
|
125
|
+
expect(cop.offenses).to be_empty
|
96
126
|
end
|
97
127
|
|
98
128
|
it 'accepts an empty if' do
|
@@ -100,95 +130,201 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
100
130
|
['if a',
|
101
131
|
'else',
|
102
132
|
'end'])
|
103
|
-
expect(cop.
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
133
|
+
expect(cop.offenses).to be_empty
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'with assignment' do
|
137
|
+
context 'when alignment style is variable' do
|
138
|
+
context 'and end is aligned with variable' do
|
139
|
+
it 'accepts an if with end aligned with variable' do
|
140
|
+
inspect_source(cop,
|
141
|
+
['var = if a',
|
142
|
+
' 0',
|
143
|
+
'end',
|
144
|
+
'@var = if a',
|
145
|
+
' 0',
|
146
|
+
'end',
|
147
|
+
'$var = if a',
|
148
|
+
' 0',
|
149
|
+
'end',
|
150
|
+
'var ||= if a',
|
151
|
+
' 0',
|
152
|
+
'end',
|
153
|
+
'var &&= if a',
|
154
|
+
' 0',
|
155
|
+
'end',
|
156
|
+
'var -= if a',
|
157
|
+
' 0',
|
158
|
+
'end',
|
159
|
+
'VAR = if a',
|
160
|
+
' 0',
|
161
|
+
'end'])
|
162
|
+
expect(cop.offenses).to be_empty
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'accepts an if/else' do
|
166
|
+
inspect_source(cop,
|
167
|
+
['var = if a',
|
168
|
+
' 0',
|
169
|
+
'else',
|
170
|
+
' 1',
|
171
|
+
'end'])
|
172
|
+
expect(cop.offenses).to be_empty
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'accepts an if/else with chaining after the end' do
|
176
|
+
inspect_source(cop,
|
177
|
+
['var = if a',
|
178
|
+
' 0',
|
179
|
+
'else',
|
180
|
+
' 1',
|
181
|
+
'end.abc.join("")'])
|
182
|
+
expect(cop.offenses).to be_empty
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'accepts an if/else with chaining with a block after the end' do
|
186
|
+
inspect_source(cop,
|
187
|
+
['var = if a',
|
188
|
+
' 0',
|
189
|
+
'else',
|
190
|
+
' 1',
|
191
|
+
'end.abc.tap {}'])
|
192
|
+
expect(cop.offenses).to be_empty
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'and end is aligned with keyword' do
|
197
|
+
it 'registers an offense for an if' do
|
198
|
+
inspect_source(cop,
|
199
|
+
['var = if a',
|
200
|
+
' 0',
|
201
|
+
' end'])
|
202
|
+
expect(cop.messages)
|
203
|
+
.to eq(['Use 2 (not 8) spaces for indentation.'])
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'registers an offense for a while' do
|
207
|
+
inspect_source(cop,
|
208
|
+
['var = while a',
|
209
|
+
' b',
|
210
|
+
' end'])
|
211
|
+
expect(cop.messages)
|
212
|
+
.to eq(['Use 2 (not 8) spaces for indentation.'])
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'registers an offense for an until' do
|
216
|
+
inspect_source(cop,
|
217
|
+
['var = until a',
|
218
|
+
' b',
|
219
|
+
' end'])
|
220
|
+
expect(cop.messages)
|
221
|
+
.to eq(['Use 2 (not 8) spaces for indentation.'])
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
shared_examples 'assignment and if with keyword alignment' do
|
227
|
+
context 'and end is aligned with variable' do
|
228
|
+
it 'registers an offense for an if' do
|
229
|
+
inspect_source(cop,
|
230
|
+
['var = if a',
|
231
|
+
' 0',
|
232
|
+
'end'])
|
233
|
+
expect(cop.messages)
|
234
|
+
.to eq(['Use 2 (not -4) spaces for indentation.'])
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'registers an offense for a while' do
|
238
|
+
inspect_source(cop,
|
239
|
+
['var = while a',
|
240
|
+
' b',
|
241
|
+
'end'])
|
242
|
+
expect(cop.messages)
|
243
|
+
.to eq(['Use 2 (not -4) spaces for indentation.'])
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'autocorrects bad indentation' do
|
247
|
+
corrected = autocorrect_source(cop,
|
248
|
+
['var = if a',
|
249
|
+
' b',
|
250
|
+
'end',
|
251
|
+
'',
|
252
|
+
'var = while a',
|
253
|
+
' b',
|
254
|
+
'end'])
|
255
|
+
expect(corrected).to eq ['var = if a',
|
256
|
+
' b',
|
257
|
+
'end', # Not this cop's job to fix end.
|
258
|
+
'',
|
259
|
+
'var = while a',
|
260
|
+
' b',
|
261
|
+
'end'].join("\n")
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
context 'and end is aligned with keyword' do
|
266
|
+
it 'accepts an if in assignment' do
|
267
|
+
inspect_source(cop,
|
268
|
+
['var = if a',
|
269
|
+
' 0',
|
270
|
+
' end'])
|
271
|
+
expect(cop.offenses).to be_empty
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'accepts an if/else in assignment' do
|
275
|
+
inspect_source(cop,
|
276
|
+
['var = if a',
|
277
|
+
' 0',
|
278
|
+
' else',
|
279
|
+
' 1',
|
280
|
+
' end'])
|
281
|
+
expect(cop.offenses).to be_empty
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'accepts an if/else in assignment on next line' do
|
285
|
+
inspect_source(cop,
|
286
|
+
['var =',
|
287
|
+
' if a',
|
288
|
+
' 0',
|
289
|
+
' else',
|
290
|
+
' 1',
|
291
|
+
' end'])
|
292
|
+
expect(cop.offenses).to be_empty
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'accepts a while in assignment' do
|
296
|
+
inspect_source(cop,
|
297
|
+
['var = while a',
|
298
|
+
' b',
|
299
|
+
' end'])
|
300
|
+
expect(cop.offenses).to be_empty
|
301
|
+
end
|
302
|
+
|
303
|
+
it 'accepts an until in assignment' do
|
304
|
+
inspect_source(cop,
|
305
|
+
['var = until a',
|
306
|
+
' b',
|
307
|
+
' end'])
|
308
|
+
expect(cop.offenses).to be_empty
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
context 'when alignment style is keyword by choice' do
|
314
|
+
let(:end_alignment_config) do
|
315
|
+
{ 'Enabled' => true, 'AlignWith' => 'keyword' }
|
316
|
+
end
|
317
|
+
|
318
|
+
include_examples 'assignment and if with keyword alignment'
|
319
|
+
end
|
320
|
+
|
321
|
+
context 'when alignment style is keyword by default' do
|
322
|
+
let(:end_alignment_config) do
|
323
|
+
{ 'Enabled' => false, 'AlignWith' => 'variable' }
|
324
|
+
end
|
325
|
+
|
326
|
+
include_examples 'assignment and if with keyword alignment'
|
327
|
+
end
|
192
328
|
end
|
193
329
|
|
194
330
|
it 'accepts an if/else branches with rescue clauses' do
|
@@ -200,12 +336,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
200
336
|
'else',
|
201
337
|
' a rescue nil',
|
202
338
|
'end'])
|
203
|
-
expect(cop.
|
339
|
+
expect(cop.offenses).to be_empty
|
204
340
|
end
|
205
341
|
end
|
206
342
|
|
207
343
|
context 'with unless' do
|
208
|
-
it 'registers an
|
344
|
+
it 'registers an offense for bad indentation of an unless body' do
|
209
345
|
inspect_source(cop,
|
210
346
|
['unless cond',
|
211
347
|
' func',
|
@@ -218,12 +354,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
218
354
|
['unless a',
|
219
355
|
'else',
|
220
356
|
'end'])
|
221
|
-
expect(cop.
|
357
|
+
expect(cop.offenses).to be_empty
|
222
358
|
end
|
223
359
|
end
|
224
360
|
|
225
361
|
context 'with case' do
|
226
|
-
it 'registers an
|
362
|
+
it 'registers an offense for bad indentation in a case/when body' do
|
227
363
|
inspect_source(cop,
|
228
364
|
['case a',
|
229
365
|
'when b',
|
@@ -232,7 +368,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
232
368
|
expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
|
233
369
|
end
|
234
370
|
|
235
|
-
it 'registers an
|
371
|
+
it 'registers an offense for bad indentation in a case/else body' do
|
236
372
|
inspect_source(cop,
|
237
373
|
['case a',
|
238
374
|
'when b',
|
@@ -255,7 +391,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
255
391
|
'else',
|
256
392
|
' f',
|
257
393
|
'end'])
|
258
|
-
expect(cop.
|
394
|
+
expect(cop.offenses).to be_empty
|
259
395
|
end
|
260
396
|
|
261
397
|
it 'accepts case/when/else laid out as a table' do
|
@@ -265,7 +401,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
265
401
|
"when 'unless' then cond, _else, body = *sexp",
|
266
402
|
'else cond, body = *sexp',
|
267
403
|
'end'])
|
268
|
-
expect(cop.
|
404
|
+
expect(cop.offenses).to be_empty
|
269
405
|
end
|
270
406
|
|
271
407
|
it 'accepts case/when/else with then beginning a line' do
|
@@ -274,7 +410,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
274
410
|
"when 'if'",
|
275
411
|
'then cond, body, _else = *sexp',
|
276
412
|
'end'])
|
277
|
-
expect(cop.
|
413
|
+
expect(cop.offenses).to be_empty
|
278
414
|
end
|
279
415
|
|
280
416
|
it 'accepts indented when/else plus indented body' do
|
@@ -290,12 +426,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
290
426
|
' else',
|
291
427
|
" 'plain'",
|
292
428
|
'end'])
|
293
|
-
expect(cop.
|
429
|
+
expect(cop.offenses).to be_empty
|
294
430
|
end
|
295
431
|
end
|
296
432
|
|
297
433
|
context 'with while/until' do
|
298
|
-
it 'registers an
|
434
|
+
it 'registers an offense for bad indentation of a while body' do
|
299
435
|
inspect_source(cop,
|
300
436
|
['while cond',
|
301
437
|
' func',
|
@@ -303,7 +439,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
303
439
|
expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
|
304
440
|
end
|
305
441
|
|
306
|
-
it 'registers an
|
442
|
+
it 'registers an offense for bad indentation of begin/end/while' do
|
307
443
|
inspect_source(cop,
|
308
444
|
['something = begin',
|
309
445
|
' func1',
|
@@ -312,7 +448,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
312
448
|
expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
|
313
449
|
end
|
314
450
|
|
315
|
-
it 'registers an
|
451
|
+
it 'registers an offense for bad indentation of an until body' do
|
316
452
|
inspect_source(cop,
|
317
453
|
['until cond',
|
318
454
|
' func',
|
@@ -324,12 +460,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
324
460
|
inspect_source(cop,
|
325
461
|
['while a',
|
326
462
|
'end'])
|
327
|
-
expect(cop.
|
463
|
+
expect(cop.offenses).to be_empty
|
328
464
|
end
|
329
465
|
end
|
330
466
|
|
331
467
|
context 'with for' do
|
332
|
-
it 'registers an
|
468
|
+
it 'registers an offense for bad indentation of a for body' do
|
333
469
|
inspect_source(cop,
|
334
470
|
['for var in 1..10',
|
335
471
|
' func',
|
@@ -341,21 +477,21 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
341
477
|
inspect_source(cop,
|
342
478
|
['for var in 1..10',
|
343
479
|
'end'])
|
344
|
-
expect(cop.
|
480
|
+
expect(cop.offenses).to be_empty
|
345
481
|
end
|
346
482
|
end
|
347
483
|
|
348
484
|
context 'with def/defs' do
|
349
|
-
it 'registers an
|
485
|
+
it 'registers an offense for bad indentation of a def body' do
|
350
486
|
inspect_source(cop,
|
351
487
|
['def test',
|
352
488
|
' func1',
|
353
|
-
' func2', # No
|
489
|
+
' func2', # No offense registered for this.
|
354
490
|
'end'])
|
355
491
|
expect(cop.messages).to eq(['Use 2 (not 4) spaces for indentation.'])
|
356
492
|
end
|
357
493
|
|
358
|
-
it 'registers an
|
494
|
+
it 'registers an offense for bad indentation of a defs body' do
|
359
495
|
inspect_source(cop,
|
360
496
|
['def self.test',
|
361
497
|
' func',
|
@@ -367,19 +503,19 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
367
503
|
inspect_source(cop,
|
368
504
|
['def test',
|
369
505
|
'end'])
|
370
|
-
expect(cop.
|
506
|
+
expect(cop.offenses).to be_empty
|
371
507
|
end
|
372
508
|
|
373
509
|
it 'accepts an empty defs body' do
|
374
510
|
inspect_source(cop,
|
375
511
|
['def self.test',
|
376
512
|
'end'])
|
377
|
-
expect(cop.
|
513
|
+
expect(cop.offenses).to be_empty
|
378
514
|
end
|
379
515
|
end
|
380
516
|
|
381
517
|
context 'with class' do
|
382
|
-
it 'registers an
|
518
|
+
it 'registers an offense for bad indentation of a class body' do
|
383
519
|
inspect_source(cop,
|
384
520
|
['class Test',
|
385
521
|
' def func',
|
@@ -392,7 +528,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
392
528
|
inspect_source(cop,
|
393
529
|
['class Test',
|
394
530
|
'end'])
|
395
|
-
expect(cop.
|
531
|
+
expect(cop.offenses).to be_empty
|
396
532
|
end
|
397
533
|
|
398
534
|
it 'accepts indented public, protected, and private' do
|
@@ -413,12 +549,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
413
549
|
' def g',
|
414
550
|
' end',
|
415
551
|
'end'])
|
416
|
-
expect(cop.
|
552
|
+
expect(cop.offenses).to be_empty
|
417
553
|
end
|
418
554
|
end
|
419
555
|
|
420
556
|
context 'with module' do
|
421
|
-
it 'registers an
|
557
|
+
it 'registers an offense for bad indentation of a module body' do
|
422
558
|
inspect_source(cop,
|
423
559
|
['module Test',
|
424
560
|
' def func',
|
@@ -431,12 +567,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
431
567
|
inspect_source(cop,
|
432
568
|
['module Test',
|
433
569
|
'end'])
|
434
|
-
expect(cop.
|
570
|
+
expect(cop.offenses).to be_empty
|
435
571
|
end
|
436
572
|
end
|
437
573
|
|
438
574
|
context 'with block' do
|
439
|
-
it 'registers an
|
575
|
+
it 'registers an offense for bad indentation of a do/end body' do
|
440
576
|
inspect_source(cop,
|
441
577
|
['a = func do',
|
442
578
|
' b',
|
@@ -444,7 +580,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
444
580
|
expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
|
445
581
|
end
|
446
582
|
|
447
|
-
it 'registers an
|
583
|
+
it 'registers an offense for bad indentation of a {} body' do
|
448
584
|
inspect_source(cop,
|
449
585
|
['func {',
|
450
586
|
' b',
|
@@ -457,14 +593,14 @@ describe Rubocop::Cop::Style::IndentationWidth do
|
|
457
593
|
['a = func do',
|
458
594
|
' b',
|
459
595
|
'end'])
|
460
|
-
expect(cop.
|
596
|
+
expect(cop.offenses).to be_empty
|
461
597
|
end
|
462
598
|
|
463
599
|
it 'accepts an empty block body' do
|
464
600
|
inspect_source(cop,
|
465
601
|
['a = func do',
|
466
602
|
'end'])
|
467
|
-
expect(cop.
|
603
|
+
expect(cop.offenses).to be_empty
|
468
604
|
end
|
469
605
|
end
|
470
606
|
end
|