rubocop 0.22.0 → 0.23.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/.gitignore +3 -0
- data/.rubocop_todo.yml +7 -7
- data/CHANGELOG.md +34 -1
- data/Gemfile +1 -1
- data/README.md +86 -47
- data/Rakefile +2 -2
- data/bin/rubocop +1 -1
- data/config/default.yml +76 -74
- data/config/disabled.yml +6 -2
- data/config/enabled.yml +180 -180
- data/lib/rubocop.rb +1 -0
- data/lib/rubocop/cli.rb +7 -3
- data/lib/rubocop/comment_config.rb +4 -2
- data/lib/rubocop/config.rb +15 -3
- data/lib/rubocop/config_loader.rb +8 -3
- data/lib/rubocop/config_store.rb +1 -1
- data/lib/rubocop/cop/commissioner.rb +1 -1
- data/lib/rubocop/cop/cop.rb +16 -2
- data/lib/rubocop/cop/corrector.rb +1 -1
- data/lib/rubocop/cop/force.rb +1 -1
- data/lib/rubocop/cop/ignored_node.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +1 -1
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/block_alignment.rb +1 -1
- 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 +1 -1
- data/lib/rubocop/cop/lint/else_layout.rb +1 -1
- data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/end_alignment.rb +1 -1
- data/lib/rubocop/cop/lint/end_in_method.rb +1 -1
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
- data/lib/rubocop/cop/lint/eval.rb +1 -1
- data/lib/rubocop/cop/lint/handle_exceptions.rb +1 -1
- data/lib/rubocop/cop/lint/invalid_character_literal.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/loop.rb +1 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/require_parentheses.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -1
- data/lib/rubocop/cop/lint/space_before_first_arg.rb +1 -1
- data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/syntax.rb +1 -1
- data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/unused_block_argument.rb +1 -1
- data/lib/rubocop/cop/lint/unused_method_argument.rb +1 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -1
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -1
- data/lib/rubocop/cop/lint/useless_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +1 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +1 -1
- data/lib/rubocop/cop/mixin/annotation_comment.rb +2 -2
- data/lib/rubocop/cop/mixin/array_syntax.rb +1 -1
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +32 -3
- data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +1 -1
- data/lib/rubocop/cop/mixin/check_assignment.rb +1 -1
- data/lib/rubocop/cop/mixin/check_methods.rb +1 -1
- data/lib/rubocop/cop/mixin/code_length.rb +1 -1
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -1
- 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_node.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 +1 -1
- data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/safe_assignment.rb +14 -3
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/space_inside.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +2 -2
- data/lib/rubocop/cop/mixin/string_help.rb +1 -1
- data/lib/rubocop/cop/mixin/surrounding_space.rb +1 -1
- data/lib/rubocop/cop/mixin/unused_argument.rb +1 -1
- data/lib/rubocop/cop/offense.rb +3 -3
- data/lib/rubocop/cop/rails/action_filter.rb +1 -1
- data/lib/rubocop/cop/rails/default_scope.rb +1 -1
- data/lib/rubocop/cop/rails/delegate.rb +1 -1
- data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +1 -1
- data/lib/rubocop/cop/rails/output.rb +1 -1
- data/lib/rubocop/cop/rails/read_write_attribute.rb +1 -1
- data/lib/rubocop/cop/rails/scope_args.rb +1 -1
- data/lib/rubocop/cop/rails/validation.rb +1 -1
- data/lib/rubocop/cop/severity.rb +1 -1
- data/lib/rubocop/cop/style/access_modifier_indentation.rb +1 -1
- data/lib/rubocop/cop/style/accessor_method_name.rb +1 -1
- data/lib/rubocop/cop/style/alias.rb +1 -1
- data/lib/rubocop/cop/style/align_array.rb +1 -1
- data/lib/rubocop/cop/style/align_hash.rb +1 -1
- data/lib/rubocop/cop/style/align_parameters.rb +1 -1
- data/lib/rubocop/cop/style/and_or.rb +1 -1
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
- data/lib/rubocop/cop/style/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 +24 -3
- data/lib/rubocop/cop/style/block_nesting.rb +1 -1
- data/lib/rubocop/cop/style/blocks.rb +1 -1
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +1 -1
- data/lib/rubocop/cop/style/case_equality.rb +1 -1
- data/lib/rubocop/cop/style/case_indentation.rb +1 -1
- data/lib/rubocop/cop/style/character_literal.rb +1 -1
- data/lib/rubocop/cop/style/class_and_module_camel_case.rb +1 -1
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/class_length.rb +1 -1
- data/lib/rubocop/cop/style/class_methods.rb +1 -1
- data/lib/rubocop/cop/style/class_vars.rb +1 -1
- data/lib/rubocop/cop/style/collection_methods.rb +1 -1
- data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
- data/lib/rubocop/cop/style/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/style/constant_name.rb +1 -1
- data/lib/rubocop/cop/style/cyclomatic_complexity.rb +1 -1
- data/lib/rubocop/cop/style/def_with_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/deprecated_hash_methods.rb +1 -1
- data/lib/rubocop/cop/style/documentation.rb +4 -2
- data/lib/rubocop/cop/style/dot_position.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +21 -5
- data/lib/rubocop/cop/style/empty_line_between_defs.rb +1 -1
- data/lib/rubocop/cop/style/empty_lines.rb +1 -1
- 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 +1 -1
- 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 +12 -3
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/file_name.rb +1 -1
- data/lib/rubocop/cop/style/flip_flop.rb +1 -1
- data/lib/rubocop/cop/style/for.rb +1 -1
- data/lib/rubocop/cop/style/format_string.rb +1 -1
- data/lib/rubocop/cop/style/global_vars.rb +1 -1
- data/lib/rubocop/cop/style/guard_clause.rb +1 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +1 -1
- data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +1 -1
- data/lib/rubocop/cop/style/indent_array.rb +35 -12
- data/lib/rubocop/cop/style/indent_hash.rb +39 -23
- data/lib/rubocop/cop/style/indentation_consistency.rb +1 -1
- data/lib/rubocop/cop/style/indentation_width.rb +2 -2
- data/lib/rubocop/cop/style/inline_comment.rb +19 -0
- data/lib/rubocop/cop/style/lambda.rb +1 -1
- data/lib/rubocop/cop/style/lambda_call.rb +1 -1
- data/lib/rubocop/cop/style/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +1 -1
- data/lib/rubocop/cop/style/line_length.rb +1 -1
- data/lib/rubocop/cop/style/method_call_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +1 -1
- data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/method_length.rb +1 -1
- data/lib/rubocop/cop/style/method_name.rb +1 -1
- 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_if_then.rb +1 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/negated_if.rb +1 -1
- data/lib/rubocop/cop/style/negated_while.rb +1 -1
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/next.rb +2 -1
- data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +1 -1
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
- data/lib/rubocop/cop/style/op_method.rb +1 -1
- data/lib/rubocop/cop/style/parameter_lists.rb +1 -1
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +11 -1
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
- 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 +1 -1
- 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 +1 -1
- data/lib/rubocop/cop/style/regexp_literal.rb +13 -5
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/semicolon.rb +1 -1
- data/lib/rubocop/cop/style/signal_exception.rb +1 -1
- data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +1 -1
- data/lib/rubocop/cop/style/single_space_before_first_arg.rb +1 -1
- data/lib/rubocop/cop/style/space_after_colon.rb +1 -1
- 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 +1 -1
- 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 +1 -1
- data/lib/rubocop/cop/style/space_around_operators.rb +1 -1
- data/lib/rubocop/cop/style/space_before_block_braces.rb +3 -2
- data/lib/rubocop/cop/style/space_before_comment.rb +1 -1
- data/lib/rubocop/cop/style/space_before_modifier_keyword.rb +1 -1
- data/lib/rubocop/cop/style/space_inside_block_braces.rb +3 -2
- data/lib/rubocop/cop/style/space_inside_brackets.rb +1 -1
- data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +1 -1
- data/lib/rubocop/cop/style/space_inside_parens.rb +1 -1
- 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 +1 -1
- data/lib/rubocop/cop/style/trailing_comma.rb +16 -3
- data/lib/rubocop/cop/style/trailing_whitespace.rb +1 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +40 -9
- data/lib/rubocop/cop/style/unless_else.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_percent_x.rb +1 -1
- data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/variable_name.rb +1 -1
- data/lib/rubocop/cop/style/when_then.rb +1 -1
- data/lib/rubocop/cop/style/while_until_do.rb +1 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
- data/lib/rubocop/cop/style/word_array.rb +1 -1
- data/lib/rubocop/cop/team.rb +12 -2
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/variable_force.rb +4 -4
- data/lib/rubocop/cop/variable_force/assignment.rb +1 -1
- data/lib/rubocop/cop/variable_force/locatable.rb +1 -1
- data/lib/rubocop/cop/variable_force/reference.rb +1 -1
- data/lib/rubocop/cop/variable_force/scope.rb +1 -1
- data/lib/rubocop/cop/variable_force/variable.rb +1 -1
- data/lib/rubocop/cop/variable_force/variable_table.rb +1 -1
- data/lib/rubocop/file_inspector.rb +3 -3
- data/lib/rubocop/formatter/base_formatter.rb +6 -6
- data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/colorizable.rb +1 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -2
- data/lib/rubocop/formatter/disabled_lines_formatter.rb +1 -1
- data/lib/rubocop/formatter/emacs_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/file_list_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +1 -1
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/json_formatter.rb +2 -2
- data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
- data/lib/rubocop/formatter/progress_formatter.rb +1 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
- data/lib/rubocop/options.rb +6 -4
- data/lib/rubocop/path_util.rb +1 -1
- data/lib/rubocop/processed_source.rb +1 -1
- data/lib/rubocop/rake_task.rb +3 -3
- data/lib/rubocop/source_parser.rb +2 -2
- data/lib/rubocop/target_finder.rb +2 -6
- data/lib/rubocop/token.rb +1 -1
- data/lib/rubocop/version.rb +2 -2
- data/relnotes/v0.21.0.md +1 -1
- data/relnotes/v0.23.0.md +79 -0
- data/rubocop.gemspec +1 -1
- data/spec/.rubocop.yml +1 -1
- data/spec/isolated_environment_spec.rb +1 -1
- data/spec/project_spec.rb +3 -3
- data/spec/rubocop/cli_spec.rb +242 -94
- data/spec/rubocop/comment_config_spec.rb +17 -15
- data/spec/rubocop/config_loader_spec.rb +51 -34
- data/spec/rubocop/config_spec.rb +5 -5
- data/spec/rubocop/config_store_spec.rb +11 -11
- data/spec/rubocop/cop/commissioner_spec.rb +4 -4
- data/spec/rubocop/cop/cop_spec.rb +33 -10
- data/spec/rubocop/cop/corrector_spec.rb +1 -1
- data/spec/rubocop/cop/force_spec.rb +2 -2
- data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +1 -1
- data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +1 -1
- data/spec/rubocop/cop/lint/assignment_in_condition_spec.rb +1 -1
- data/spec/rubocop/cop/lint/block_alignment_spec.rb +2 -2
- data/spec/rubocop/cop/lint/condition_position_spec.rb +4 -4
- data/spec/rubocop/cop/lint/debugger_spec.rb +1 -1
- data/spec/rubocop/cop/lint/deprecated_class_methods_spec.rb +1 -1
- data/spec/rubocop/cop/lint/else_layout_spec.rb +5 -5
- data/spec/rubocop/cop/lint/empty_ensure_spec.rb +1 -1
- data/spec/rubocop/cop/lint/empty_interpolation_spec.rb +1 -1
- data/spec/rubocop/cop/lint/end_alignment_spec.rb +1 -1
- data/spec/rubocop/cop/lint/end_in_method_spec.rb +1 -1
- data/spec/rubocop/cop/lint/ensure_return_spec.rb +1 -1
- data/spec/rubocop/cop/lint/eval_spec.rb +1 -1
- data/spec/rubocop/cop/lint/handle_exceptions_spec.rb +1 -1
- data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +1 -1
- data/spec/rubocop/cop/lint/literal_in_condition_spec.rb +1 -1
- data/spec/rubocop/cop/lint/literal_in_interpolation_spec.rb +1 -1
- data/spec/rubocop/cop/lint/loop_spec.rb +1 -1
- data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +1 -1
- data/spec/rubocop/cop/lint/require_parentheses_spec.rb +1 -1
- data/spec/rubocop/cop/lint/rescue_exception_spec.rb +2 -2
- data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +1 -1
- data/spec/rubocop/cop/lint/space_before_first_arg_spec.rb +1 -1
- data/spec/rubocop/cop/lint/string_conversion_in_interpolation_spec.rb +1 -1
- data/spec/rubocop/cop/lint/syntax_spec.rb +2 -2
- data/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb +1 -1
- data/spec/rubocop/cop/lint/unreachable_code_spec.rb +1 -1
- data/spec/rubocop/cop/lint/unused_block_argument_spec.rb +1 -1
- data/spec/rubocop/cop/lint/unused_method_argument_spec.rb +1 -1
- data/spec/rubocop/cop/lint/useless_access_modifier_spec.rb +1 -1
- data/spec/rubocop/cop/lint/useless_assignment_spec.rb +1 -1
- data/spec/rubocop/cop/lint/useless_comparison_spec.rb +1 -1
- data/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb +1 -1
- data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +1 -1
- data/spec/rubocop/cop/lint/void_spec.rb +1 -1
- data/spec/rubocop/cop/offense_spec.rb +2 -2
- data/spec/rubocop/cop/rails/action_filter_spec.rb +1 -1
- data/spec/rubocop/cop/rails/default_scope_spec.rb +1 -1
- data/spec/rubocop/cop/rails/delegate_spec.rb +1 -1
- data/spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb +1 -1
- data/spec/rubocop/cop/rails/output_spec.rb +1 -1
- data/spec/rubocop/cop/rails/read_write_attribute_spec.rb +1 -1
- data/spec/rubocop/cop/rails/scope_args_spec.rb +1 -1
- data/spec/rubocop/cop/rails/validation_spec.rb +1 -1
- data/spec/rubocop/cop/severity_spec.rb +1 -1
- data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +1 -1
- data/spec/rubocop/cop/style/accessor_method_name_spec.rb +1 -1
- data/spec/rubocop/cop/style/alias_spec.rb +1 -1
- data/spec/rubocop/cop/style/align_array_spec.rb +33 -1
- data/spec/rubocop/cop/style/align_hash_spec.rb +1 -1
- data/spec/rubocop/cop/style/align_parameters_spec.rb +1 -1
- data/spec/rubocop/cop/style/and_or_spec.rb +1 -1
- data/spec/rubocop/cop/style/array_join_spec.rb +1 -1
- data/spec/rubocop/cop/style/ascii_comments_spec.rb +1 -1
- data/spec/rubocop/cop/style/ascii_identifiers_spec.rb +1 -1
- data/spec/rubocop/cop/style/attr_spec.rb +1 -1
- data/spec/rubocop/cop/style/begin_block_spec.rb +1 -1
- data/spec/rubocop/cop/style/block_comments_spec.rb +25 -1
- data/spec/rubocop/cop/style/block_nesting_spec.rb +1 -1
- data/spec/rubocop/cop/style/blocks_spec.rb +1 -1
- data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +1 -1
- data/spec/rubocop/cop/style/case_equality_spec.rb +1 -1
- data/spec/rubocop/cop/style/case_indentation_spec.rb +4 -4
- data/spec/rubocop/cop/style/character_literal_spec.rb +1 -1
- data/spec/rubocop/cop/style/class_and_module_camel_case_spec.rb +1 -1
- data/spec/rubocop/cop/style/class_and_module_children_spec.rb +1 -1
- data/spec/rubocop/cop/style/class_length_spec.rb +1 -1
- data/spec/rubocop/cop/style/class_methods_spec.rb +1 -1
- data/spec/rubocop/cop/style/class_vars_spec.rb +1 -1
- data/spec/rubocop/cop/style/collection_methods_spec.rb +1 -1
- data/spec/rubocop/cop/style/colon_method_call_spec.rb +1 -1
- data/spec/rubocop/cop/style/comment_annotation_spec.rb +2 -2
- data/spec/rubocop/cop/style/comment_indentation_spec.rb +1 -1
- data/spec/rubocop/cop/style/constant_name_spec.rb +2 -2
- data/spec/rubocop/cop/style/cyclomatic_complexity_spec.rb +1 -1
- data/spec/rubocop/cop/style/def_with_parentheses_spec.rb +1 -1
- data/spec/rubocop/cop/style/deprecated_hash_methods_spec.rb +1 -1
- data/spec/rubocop/cop/style/documentation_spec.rb +26 -2
- data/spec/rubocop/cop/style/dot_position_spec.rb +1 -1
- data/spec/rubocop/cop/style/double_negation_spec.rb +1 -1
- data/spec/rubocop/cop/style/each_with_object_spec.rb +31 -7
- data/spec/rubocop/cop/style/empty_line_between_defs_spec.rb +1 -1
- data/spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb +1 -1
- data/spec/rubocop/cop/style/empty_lines_around_body_spec.rb +1 -1
- data/spec/rubocop/cop/style/empty_lines_spec.rb +1 -1
- data/spec/rubocop/cop/style/empty_literal_spec.rb +1 -1
- data/spec/rubocop/cop/style/encoding_spec.rb +1 -1
- data/spec/rubocop/cop/style/end_block_spec.rb +1 -1
- data/spec/rubocop/cop/style/end_of_line_spec.rb +13 -1
- data/spec/rubocop/cop/style/even_odd_spec.rb +1 -1
- data/spec/rubocop/cop/style/file_name_spec.rb +2 -2
- data/spec/rubocop/cop/style/flip_flop_spec.rb +1 -1
- data/spec/rubocop/cop/style/for_spec.rb +1 -1
- data/spec/rubocop/cop/style/format_string_spec.rb +1 -1
- data/spec/rubocop/cop/style/global_vars_spec.rb +1 -1
- data/spec/rubocop/cop/style/guard_clause_spec.rb +1 -1
- data/spec/rubocop/cop/style/hash_syntax_spec.rb +9 -5
- data/spec/rubocop/cop/style/if_unless_modifier_spec.rb +6 -6
- data/spec/rubocop/cop/style/if_with_semicolon_spec.rb +1 -1
- data/spec/rubocop/cop/style/indent_array_spec.rb +37 -2
- data/spec/rubocop/cop/style/indent_hash_spec.rb +64 -8
- data/spec/rubocop/cop/style/indentation_consistency_spec.rb +1 -1
- data/spec/rubocop/cop/style/indentation_width_spec.rb +84 -21
- data/spec/rubocop/cop/style/inline_comment_spec.rb +13 -0
- data/spec/rubocop/cop/style/lambda_call_spec.rb +1 -1
- data/spec/rubocop/cop/style/lambda_spec.rb +1 -1
- data/spec/rubocop/cop/style/leading_comment_space_spec.rb +1 -1
- data/spec/rubocop/cop/style/line_end_concatenation_spec.rb +1 -1
- data/spec/rubocop/cop/style/line_length_spec.rb +1 -1
- data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +3 -3
- data/spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb +1 -1
- data/spec/rubocop/cop/style/method_def_parentheses_spec.rb +1 -1
- data/spec/rubocop/cop/style/method_length_spec.rb +1 -1
- data/spec/rubocop/cop/style/method_name_spec.rb +1 -1
- data/spec/rubocop/cop/style/module_function_spec.rb +1 -1
- data/spec/rubocop/cop/style/multiline_block_chain_spec.rb +1 -1
- data/spec/rubocop/cop/style/multiline_if_then_spec.rb +1 -1
- data/spec/rubocop/cop/style/multiline_ternary_operator_spec.rb +1 -1
- data/spec/rubocop/cop/style/negated_if_spec.rb +1 -1
- data/spec/rubocop/cop/style/negated_while_spec.rb +1 -1
- data/spec/rubocop/cop/style/nested_ternary_operator_spec.rb +1 -1
- data/spec/rubocop/cop/style/next_spec.rb +10 -1
- data/spec/rubocop/cop/style/nil_comparison_spec.rb +1 -1
- data/spec/rubocop/cop/style/non_nil_check_spec.rb +1 -1
- data/spec/rubocop/cop/style/not_spec.rb +1 -1
- data/spec/rubocop/cop/style/numeric_literals_spec.rb +1 -1
- data/spec/rubocop/cop/style/one_line_conditional_spec.rb +1 -1
- data/spec/rubocop/cop/style/op_method_spec.rb +1 -1
- data/spec/rubocop/cop/style/parameter_lists_spec.rb +1 -1
- data/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +16 -1
- data/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb +1 -1
- data/spec/rubocop/cop/style/perl_backrefs_spec.rb +1 -1
- data/spec/rubocop/cop/style/predicate_name_spec.rb +1 -1
- data/spec/rubocop/cop/style/proc_spec.rb +1 -1
- data/spec/rubocop/cop/style/raise_args_spec.rb +1 -1
- data/spec/rubocop/cop/style/redundant_begin_spec.rb +1 -1
- data/spec/rubocop/cop/style/redundant_exception_spec.rb +1 -1
- data/spec/rubocop/cop/style/redundant_return_spec.rb +1 -1
- data/spec/rubocop/cop/style/redundant_self_spec.rb +1 -1
- data/spec/rubocop/cop/style/regexp_literal_spec.rb +15 -1
- data/spec/rubocop/cop/style/rescue_modifier_spec.rb +1 -1
- data/spec/rubocop/cop/style/self_assignment_spec.rb +1 -1
- data/spec/rubocop/cop/style/semicolon_spec.rb +1 -1
- data/spec/rubocop/cop/style/signal_exception_spec.rb +1 -1
- data/spec/rubocop/cop/style/single_line_block_params_spec.rb +1 -1
- data/spec/rubocop/cop/style/single_line_methods_spec.rb +1 -1
- data/spec/rubocop/cop/style/single_space_before_first_arg_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_after_colon_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_after_comma_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_after_control_keyword_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_after_method_name_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_after_not_spec.rb +1 -1
- 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 +1 -1
- data/spec/rubocop/cop/style/space_around_operators_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_before_block_braces_spec.rb +5 -5
- data/spec/rubocop/cop/style/space_before_comment_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_before_modifier_keyword_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_inside_block_braces_spec.rb +7 -7
- data/spec/rubocop/cop/style/space_inside_brackets_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_inside_hash_literal_braces_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_inside_parens_spec.rb +1 -1
- data/spec/rubocop/cop/style/special_global_vars_spec.rb +1 -1
- data/spec/rubocop/cop/style/string_literals_spec.rb +1 -1
- data/spec/rubocop/cop/style/symbol_array_spec.rb +1 -1
- data/spec/rubocop/cop/style/tab_spec.rb +1 -1
- data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +1 -1
- data/spec/rubocop/cop/style/trailing_comma_spec.rb +36 -10
- data/spec/rubocop/cop/style/trailing_whitespace_spec.rb +1 -1
- data/spec/rubocop/cop/style/trivial_accessors_spec.rb +51 -3
- data/spec/rubocop/cop/style/unless_else_spec.rb +1 -1
- data/spec/rubocop/cop/style/unneeded_capital_w_spec.rb +1 -1
- data/spec/rubocop/cop/style/unneeded_percent_x_spec.rb +1 -1
- data/spec/rubocop/cop/style/variable_interpolation_spec.rb +1 -1
- data/spec/rubocop/cop/style/variable_name_spec.rb +1 -1
- data/spec/rubocop/cop/style/when_then_spec.rb +1 -1
- data/spec/rubocop/cop/style/while_until_do_spec.rb +1 -1
- data/spec/rubocop/cop/style/while_until_modifier_spec.rb +6 -6
- data/spec/rubocop/cop/style/word_array_spec.rb +1 -1
- data/spec/rubocop/cop/team_spec.rb +23 -23
- data/spec/rubocop/cop/util_spec.rb +1 -1
- data/spec/rubocop/cop/variable_force/assignment_spec.rb +4 -4
- data/spec/rubocop/cop/variable_force/locatable_spec.rb +4 -4
- data/spec/rubocop/cop/variable_force/scope_spec.rb +3 -3
- data/spec/rubocop/cop/variable_force/variable_spec.rb +2 -2
- data/spec/rubocop/cop/variable_force/variable_table_spec.rb +1 -1
- data/spec/rubocop/cop/variable_force_spec.rb +1 -1
- data/spec/rubocop/file_inspector_spec.rb +3 -3
- data/spec/rubocop/formatter/base_formatter_spec.rb +2 -2
- data/spec/rubocop/formatter/clang_style_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/colorizable_spec.rb +1 -1
- data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +3 -3
- data/spec/rubocop/formatter/disabled_lines_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/emacs_style_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/file_list_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/formatter_set_spec.rb +5 -5
- data/spec/rubocop/formatter/fuubar_style_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/json_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/offense_count_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/progress_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/simple_text_formatter_spec.rb +1 -1
- data/spec/rubocop/options_spec.rb +5 -5
- data/spec/rubocop/path_util_spec.rb +1 -1
- data/spec/rubocop/processed_source_spec.rb +1 -1
- data/spec/rubocop/source_parser_spec.rb +3 -3
- data/spec/rubocop/target_finder_spec.rb +2 -2
- data/spec/rubocop/token_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -8
- data/spec/support/isolated_environment.rb +1 -1
- data/spec/support/mri_syntax_checker.rb +1 -1
- data/spec/support/offenses_matcher.rb +30 -0
- data/spec/support/shared_context.rb +3 -3
- metadata +8 -2
data/spec/rubocop/cli_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require 'tmpdir'
|
|
5
5
|
require 'spec_helper'
|
6
6
|
require 'timeout'
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe RuboCop::CLI, :isolated_environment do
|
9
9
|
include FileHelper
|
10
10
|
|
11
11
|
subject(:cli) { described_class.new }
|
@@ -13,7 +13,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
13
13
|
before(:each) do
|
14
14
|
$stdout = StringIO.new
|
15
15
|
$stderr = StringIO.new
|
16
|
-
|
16
|
+
RuboCop::ConfigLoader.debug = false
|
17
17
|
end
|
18
18
|
|
19
19
|
after(:each) do
|
@@ -30,7 +30,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
30
30
|
it 'exits cleanly' do
|
31
31
|
expect { cli.run ['-v'] }.to exit_with_code(0)
|
32
32
|
expect { cli.run ['--version'] }.to exit_with_code(0)
|
33
|
-
expect($stdout.string).to eq((
|
33
|
+
expect($stdout.string).to eq((RuboCop::Version::STRING + "\n") * 2)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -39,7 +39,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
39
39
|
source = ['# encoding: utf-8',
|
40
40
|
'puts %x(ls)']
|
41
41
|
create_file('example.rb', source)
|
42
|
-
create_file('.rubocop.yml', ['UnneededPercentX:',
|
42
|
+
create_file('.rubocop.yml', ['Style/UnneededPercentX:',
|
43
43
|
' Exclude:',
|
44
44
|
' - example.rb'])
|
45
45
|
expect(cli.run(['--auto-correct'])).to eq(0)
|
@@ -47,6 +47,94 @@ describe Rubocop::CLI, :isolated_environment do
|
|
47
47
|
expect(IO.read('example.rb')).to eq(source.join("\n") + "\n")
|
48
48
|
end
|
49
49
|
|
50
|
+
it 'corrects code with indentation problems' do
|
51
|
+
create_file('example.rb', ['# encoding: utf-8',
|
52
|
+
'module Bar',
|
53
|
+
'class Goo',
|
54
|
+
' def something',
|
55
|
+
' first call',
|
56
|
+
" do_other 'things'",
|
57
|
+
' if other > 34',
|
58
|
+
' more_work',
|
59
|
+
' end',
|
60
|
+
' end',
|
61
|
+
'end',
|
62
|
+
'end',
|
63
|
+
'',
|
64
|
+
'module Foo',
|
65
|
+
'class Bar',
|
66
|
+
'',
|
67
|
+
' stuff = [',
|
68
|
+
' {',
|
69
|
+
" some: 'hash',",
|
70
|
+
' },',
|
71
|
+
' {',
|
72
|
+
" another: 'hash',",
|
73
|
+
" with: 'more'",
|
74
|
+
' },',
|
75
|
+
' ]',
|
76
|
+
'end',
|
77
|
+
'end'
|
78
|
+
])
|
79
|
+
expect(cli.run(['--auto-correct'])).to eq(1)
|
80
|
+
expect(IO.read('example.rb'))
|
81
|
+
.to eq(['# encoding: utf-8',
|
82
|
+
'module Bar',
|
83
|
+
' class Goo',
|
84
|
+
' def something',
|
85
|
+
' first call',
|
86
|
+
" do_other 'things'",
|
87
|
+
' if other > 34',
|
88
|
+
' more_work',
|
89
|
+
' end',
|
90
|
+
' end',
|
91
|
+
' end',
|
92
|
+
'end',
|
93
|
+
'',
|
94
|
+
'module Foo',
|
95
|
+
' class Bar',
|
96
|
+
' stuff = [',
|
97
|
+
' {',
|
98
|
+
" some: 'hash',",
|
99
|
+
' },',
|
100
|
+
' {',
|
101
|
+
" another: 'hash',",
|
102
|
+
" with: 'more'",
|
103
|
+
' },',
|
104
|
+
' ]',
|
105
|
+
' end',
|
106
|
+
'end'].join("\n") + "\n")
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'can change block comments and indent them' do
|
110
|
+
create_file('example.rb', ['# encoding: utf-8',
|
111
|
+
'module Foo',
|
112
|
+
'class Bar',
|
113
|
+
'=begin',
|
114
|
+
'This is a nice long',
|
115
|
+
'comment',
|
116
|
+
'which spans a few lines',
|
117
|
+
'=end',
|
118
|
+
' def baz',
|
119
|
+
' do_something',
|
120
|
+
' end',
|
121
|
+
'end',
|
122
|
+
'end'])
|
123
|
+
expect(cli.run(['--auto-correct'])).to eq(1)
|
124
|
+
expect(IO.read('example.rb'))
|
125
|
+
.to eq(['# encoding: utf-8',
|
126
|
+
'module Foo',
|
127
|
+
' class Bar',
|
128
|
+
' # This is a nice long',
|
129
|
+
' # comment',
|
130
|
+
' # which spans a few lines',
|
131
|
+
' def baz',
|
132
|
+
' do_something',
|
133
|
+
' end',
|
134
|
+
' end',
|
135
|
+
'end'].join("\n") + "\n")
|
136
|
+
end
|
137
|
+
|
50
138
|
it 'can correct two problems with blocks' do
|
51
139
|
# {} should be do..end and space is missing.
|
52
140
|
create_file('example.rb', ['# encoding: utf-8',
|
@@ -123,8 +211,8 @@ describe Rubocop::CLI, :isolated_environment do
|
|
123
211
|
'comment.',
|
124
212
|
"#{e}:3:1: C: [Corrected] Indent access modifiers like " \
|
125
213
|
'`private`.',
|
126
|
-
"#{e}:3:3: C: Keep a blank line before and after `private`.",
|
127
214
|
"#{e}:3:3: W: Useless `private` access modifier.",
|
215
|
+
"#{e}:3:3: C: Keep a blank line before and after `private`.",
|
128
216
|
"#{e}:4:7: C: [Corrected] Use `%w` or `%W` " \
|
129
217
|
'for array of words.',
|
130
218
|
"#{e}:4:8: C: [Corrected] Prefer single-quoted strings " \
|
@@ -164,11 +252,11 @@ describe Rubocop::CLI, :isolated_environment do
|
|
164
252
|
'end',
|
165
253
|
''].join("\n"))
|
166
254
|
expect($stdout.string).to eq(['',
|
167
|
-
'6 TrailingWhitespace',
|
168
|
-
'4 Semicolon',
|
169
|
-
'2 SingleLineMethods',
|
170
|
-
'1 DefWithParentheses',
|
171
|
-
'1 EmptyLineBetweenDefs',
|
255
|
+
'6 Style/TrailingWhitespace',
|
256
|
+
'4 Style/Semicolon',
|
257
|
+
'2 Style/SingleLineMethods',
|
258
|
+
'1 Style/DefWithParentheses',
|
259
|
+
'1 Style/EmptyLineBetweenDefs',
|
172
260
|
'--',
|
173
261
|
'14 Total',
|
174
262
|
'',
|
@@ -264,11 +352,12 @@ describe Rubocop::CLI, :isolated_environment do
|
|
264
352
|
'',
|
265
353
|
'Offenses:',
|
266
354
|
'',
|
267
|
-
'example.rb:2:12: C: [Corrected]
|
355
|
+
'example.rb:2:12: C: [Corrected] ' \
|
356
|
+
'Style/MethodDefParentheses: ' \
|
268
357
|
'Use def with parentheses when there are parameters.',
|
269
358
|
'def primes limit',
|
270
359
|
' ^^^^^',
|
271
|
-
'example.rb:3:17: C: [Corrected] CollectionMethods: ' \
|
360
|
+
'example.rb:3:17: C: [Corrected] Style/CollectionMethods: ' \
|
272
361
|
'Prefer select over find_all.',
|
273
362
|
' 1.upto(limit).find_all { |i| is_prime[i] }',
|
274
363
|
' ^^^^^^^^',
|
@@ -286,8 +375,8 @@ describe Rubocop::CLI, :isolated_environment do
|
|
286
375
|
expect(cli.run(%w(-D --auto-correct --format o))).to eq(1)
|
287
376
|
expect($stdout.string)
|
288
377
|
.to eq(['',
|
289
|
-
'4 SpaceAfterComma',
|
290
|
-
'2 WordArray',
|
378
|
+
'4 Style/SpaceAfterComma',
|
379
|
+
'2 Style/WordArray',
|
291
380
|
'--',
|
292
381
|
'6 Total',
|
293
382
|
'',
|
@@ -306,9 +395,9 @@ describe Rubocop::CLI, :isolated_environment do
|
|
306
395
|
expect(cli.run(%w(-D --auto-correct --format emacs))).to eq(1)
|
307
396
|
expect($stdout.string)
|
308
397
|
.to eq(["#{abs('example.rb')}:2:21: C: [Corrected] " \
|
309
|
-
'SpaceAfterComma: Space missing after comma.',
|
398
|
+
'Style/SpaceAfterComma: Space missing after comma.',
|
310
399
|
"#{abs('example.rb')}:2:22: C: [Corrected] " \
|
311
|
-
'HashSyntax: Use the new Ruby 1.9 hash syntax.',
|
400
|
+
'Style/HashSyntax: Use the new Ruby 1.9 hash syntax.',
|
312
401
|
''].join("\n"))
|
313
402
|
expect(IO.read('example.rb'))
|
314
403
|
.to eq(['# encoding: utf-8',
|
@@ -325,10 +414,10 @@ describe Rubocop::CLI, :isolated_environment do
|
|
325
414
|
'{ b: 1 }',
|
326
415
|
''].join("\n"))
|
327
416
|
expect($stdout.string)
|
328
|
-
.to eq(["#{abs('example.rb')}:2:3: C: [Corrected]
|
329
|
-
'the new Ruby 1.9 hash syntax.',
|
417
|
+
.to eq(["#{abs('example.rb')}:2:3: C: [Corrected] " \
|
418
|
+
'Style/HashSyntax: Use the new Ruby 1.9 hash syntax.',
|
330
419
|
"#{abs('example.rb')}:2:5: C: [Corrected] " \
|
331
|
-
'SpaceAroundOperators: Surrounding space missing for ' \
|
420
|
+
'Style/SpaceAroundOperators: Surrounding space missing for ' \
|
332
421
|
"operator '=>'.",
|
333
422
|
''].join("\n"))
|
334
423
|
end
|
@@ -337,7 +426,8 @@ describe Rubocop::CLI, :isolated_environment do
|
|
337
426
|
create_file('example.rb',
|
338
427
|
['# encoding: utf-8',
|
339
428
|
'{ :b=>1 }'])
|
340
|
-
expect(cli.run(%w(--auto-correct -f emacs
|
429
|
+
expect(cli.run(%w(--auto-correct -f emacs
|
430
|
+
--only Style/HashSyntax))).to eq(1)
|
341
431
|
expect($stderr.string).to eq('')
|
342
432
|
expect(IO.read('example.rb')).to eq(['# encoding: utf-8',
|
343
433
|
'{ b: 1 }',
|
@@ -392,7 +482,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
392
482
|
'failure_message_for_should_not: :failure_message_when',
|
393
483
|
'}'])
|
394
484
|
create_file('.rubocop.yml',
|
395
|
-
['AlignHash:',
|
485
|
+
['Style/AlignHash:',
|
396
486
|
' EnforcedColonStyle: separator'])
|
397
487
|
expect(cli.run(%w(--auto-correct))).to eq(1)
|
398
488
|
expect(IO.read('example.rb'))
|
@@ -463,23 +553,23 @@ describe Rubocop::CLI, :isolated_environment do
|
|
463
553
|
'#' * 85,
|
464
554
|
'y ',
|
465
555
|
'puts x'])
|
466
|
-
create_file('.rubocop_todo.yml', ['LineLength:',
|
556
|
+
create_file('.rubocop_todo.yml', ['Style/LineLength:',
|
467
557
|
' Enabled: false'])
|
468
558
|
create_file('.rubocop.yml', ['inherit_from: .rubocop_todo.yml'])
|
469
559
|
expect(cli.run(['--auto-gen-config'])).to eq(1)
|
470
560
|
expect(IO.readlines('.rubocop_todo.yml')[7..-1].map(&:chomp))
|
471
561
|
.to eq(['# Offense count: 1',
|
472
|
-
'LineLength:',
|
562
|
+
'Style/LineLength:',
|
473
563
|
' Max: 85',
|
474
564
|
'',
|
475
565
|
'# Offense count: 1',
|
476
566
|
'# Cop supports --auto-correct.',
|
477
|
-
'SpaceAroundOperators:',
|
567
|
+
'Style/SpaceAroundOperators:',
|
478
568
|
' Enabled: false',
|
479
569
|
'',
|
480
570
|
'# Offense count: 2',
|
481
571
|
'# Cop supports --auto-correct.',
|
482
|
-
'TrailingWhitespace:',
|
572
|
+
'Style/TrailingWhitespace:',
|
483
573
|
' Enabled: false'])
|
484
574
|
|
485
575
|
# Create new CLI instance to avoid using cached configuration.
|
@@ -531,35 +621,35 @@ describe Rubocop::CLI, :isolated_environment do
|
|
531
621
|
'',
|
532
622
|
'# Offense count: 1',
|
533
623
|
'# Cop supports --auto-correct.',
|
534
|
-
'CommentIndentation:',
|
624
|
+
'Style/CommentIndentation:',
|
535
625
|
' Enabled: false',
|
536
626
|
'',
|
537
627
|
'# Offense count: 1',
|
538
628
|
'# Configuration parameters: AllowedVariables.',
|
539
|
-
'GlobalVars:',
|
629
|
+
'Style/GlobalVars:',
|
540
630
|
' Enabled: false',
|
541
631
|
'',
|
542
632
|
'# Offense count: 1',
|
543
633
|
'# Cop supports --auto-correct.',
|
544
|
-
'IndentationConsistency:',
|
634
|
+
'Style/IndentationConsistency:',
|
545
635
|
' Enabled: false',
|
546
636
|
'',
|
547
637
|
'# Offense count: 2',
|
548
|
-
'LineLength:',
|
638
|
+
'Style/LineLength:',
|
549
639
|
' Max: 90',
|
550
640
|
'',
|
551
641
|
'# Offense count: 1',
|
552
642
|
'# Cop supports --auto-correct.',
|
553
|
-
'SpaceAroundOperators:',
|
643
|
+
'Style/SpaceAroundOperators:',
|
554
644
|
' Enabled: false',
|
555
645
|
'',
|
556
646
|
'# Offense count: 1',
|
557
|
-
'Tab:',
|
647
|
+
'Style/Tab:',
|
558
648
|
' Enabled: false',
|
559
649
|
'',
|
560
650
|
'# Offense count: 2',
|
561
651
|
'# Cop supports --auto-correct.',
|
562
|
-
'TrailingWhitespace:',
|
652
|
+
'Style/TrailingWhitespace:',
|
563
653
|
' Enabled: false']
|
564
654
|
actual = IO.read('.rubocop_todo.yml').split($RS)
|
565
655
|
expected.each_with_index do |line, ix|
|
@@ -591,16 +681,16 @@ describe Rubocop::CLI, :isolated_environment do
|
|
591
681
|
'',
|
592
682
|
'# Offense count: 1',
|
593
683
|
'# Cop supports --auto-correct.',
|
594
|
-
'CommentIndentation:',
|
684
|
+
'Style/CommentIndentation:',
|
595
685
|
' Enabled: false',
|
596
686
|
'',
|
597
687
|
'# Offense count: 1',
|
598
688
|
'# Cop supports --auto-correct.',
|
599
|
-
'IndentationConsistency:',
|
689
|
+
'Style/IndentationConsistency:',
|
600
690
|
' Enabled: false',
|
601
691
|
'',
|
602
692
|
'# Offense count: 1',
|
603
|
-
'Tab:',
|
693
|
+
'Style/Tab:',
|
604
694
|
' Enabled: false']
|
605
695
|
actual = IO.read('.rubocop_todo.yml').split($RS)
|
606
696
|
expect(actual.length).to eq(expected.length)
|
@@ -632,7 +722,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
632
722
|
'again.',
|
633
723
|
'',
|
634
724
|
'# Offense count: 1',
|
635
|
-
'RegexpLiteral:',
|
725
|
+
'Style/RegexpLiteral:',
|
636
726
|
' MaxSlashes: 0']
|
637
727
|
actual = IO.read('.rubocop_todo.yml').split($RS)
|
638
728
|
expected.each_with_index do |line, ix|
|
@@ -658,7 +748,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
658
748
|
# IfUnlessModifier depends on the configuration of LineLength.
|
659
749
|
|
660
750
|
expect(cli.run(['--format', 'simple',
|
661
|
-
'--only', 'IfUnlessModifier',
|
751
|
+
'--only', 'Style/IfUnlessModifier',
|
662
752
|
'example.rb'])).to eq(1)
|
663
753
|
expect($stdout.string)
|
664
754
|
.to eq(['== example.rb ==',
|
@@ -670,17 +760,39 @@ describe Rubocop::CLI, :isolated_environment do
|
|
670
760
|
''].join("\n"))
|
671
761
|
end
|
672
762
|
|
763
|
+
context 'without using namespace' do
|
764
|
+
it 'runs just one cop' do
|
765
|
+
create_file('example.rb', ['if x== 0 ',
|
766
|
+
"\ty",
|
767
|
+
'end'])
|
768
|
+
|
769
|
+
expect(cli.run(['--format', 'simple',
|
770
|
+
'--display-cop-names',
|
771
|
+
'--only', 'IfUnlessModifier',
|
772
|
+
'example.rb'])).to eq(1)
|
773
|
+
expect($stdout.string)
|
774
|
+
.to eq(['== example.rb ==',
|
775
|
+
'C: 1: 1: Style/IfUnlessModifier: Favor modifier if ' \
|
776
|
+
'usage when having a single-line body. Another good ' \
|
777
|
+
'alternative is the usage of control flow &&/||.',
|
778
|
+
'',
|
779
|
+
'1 file inspected, 1 offense detected',
|
780
|
+
''].join("\n"))
|
781
|
+
end
|
782
|
+
end
|
783
|
+
|
673
784
|
it 'enables the given cop' do
|
674
|
-
create_file('example.rb',
|
675
|
-
|
676
|
-
|
677
|
-
|
785
|
+
create_file('example.rb',
|
786
|
+
['x = 0 ',
|
787
|
+
# Disabling comments still apply.
|
788
|
+
'# rubocop:disable Style/TrailingWhitespace',
|
789
|
+
'y = 1 '])
|
678
790
|
|
679
|
-
create_file('.rubocop.yml', ['TrailingWhitespace:',
|
791
|
+
create_file('.rubocop.yml', ['Style/TrailingWhitespace:',
|
680
792
|
' Enabled: false'])
|
681
793
|
|
682
794
|
expect(cli.run(['--format', 'simple',
|
683
|
-
'--only', 'TrailingWhitespace',
|
795
|
+
'--only', 'Style/TrailingWhitespace',
|
684
796
|
'example.rb'])).to eq(1)
|
685
797
|
expect($stderr.string).to eq('')
|
686
798
|
expect($stdout.string)
|
@@ -699,7 +811,8 @@ describe Rubocop::CLI, :isolated_environment do
|
|
699
811
|
'end'])
|
700
812
|
expect(cli.run(['--format', 'simple',
|
701
813
|
'--only',
|
702
|
-
'IfUnlessModifier,Tab,
|
814
|
+
'Style/IfUnlessModifier,Style/Tab,' \
|
815
|
+
'Style/SpaceAroundOperators',
|
703
816
|
'example.rb'])).to eq(1)
|
704
817
|
expect($stderr.string).to eq('')
|
705
818
|
expect($stdout.string)
|
@@ -719,10 +832,10 @@ describe Rubocop::CLI, :isolated_environment do
|
|
719
832
|
create_file('example.rb', ['if x== 100000000000000 ',
|
720
833
|
"\ty = 3",
|
721
834
|
' end'])
|
722
|
-
create_file('.rubocop.yml', ['EndAlignment:',
|
835
|
+
create_file('.rubocop.yml', ['Lint/EndAlignment:',
|
723
836
|
' Enabled: false'])
|
724
837
|
expect(cli.run(['--format', 'simple',
|
725
|
-
'--only', 'Tab,SpaceAroundOperators',
|
838
|
+
'--only', 'Style/Tab,Style/SpaceAroundOperators',
|
726
839
|
'--lint',
|
727
840
|
'example.rb'])).to eq(1)
|
728
841
|
expect($stdout.string)
|
@@ -777,7 +890,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
777
890
|
'--debug',
|
778
891
|
'example1.rb'])).to eq(1)
|
779
892
|
expect($stdout.string.lines.to_a[-1])
|
780
|
-
.to eq(["#{abs('example1.rb')}:1:1: C: Tab: Tab detected.",
|
893
|
+
.to eq(["#{abs('example1.rb')}:1:1: C: Style/Tab: Tab detected.",
|
781
894
|
''].join("\n"))
|
782
895
|
end
|
783
896
|
end
|
@@ -790,7 +903,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
790
903
|
'--debug',
|
791
904
|
'example1.rb'])).to eq(1)
|
792
905
|
expect($stdout.string.lines.to_a[-1])
|
793
|
-
.to eq(["#{abs('example1.rb')}:1:1: C: Tab: Tab detected.",
|
906
|
+
.to eq(["#{abs('example1.rb')}:1:1: C: Style/Tab: Tab detected.",
|
794
907
|
''].join("\n"))
|
795
908
|
end
|
796
909
|
end
|
@@ -810,18 +923,18 @@ describe Rubocop::CLI, :isolated_environment do
|
|
810
923
|
end
|
811
924
|
end
|
812
925
|
|
813
|
-
let(:cops) {
|
926
|
+
let(:cops) { RuboCop::Cop::Cop.all }
|
814
927
|
|
815
928
|
let(:global_conf) do
|
816
929
|
config_path =
|
817
|
-
|
818
|
-
|
930
|
+
RuboCop::ConfigLoader.configuration_file_for(Dir.pwd.to_s)
|
931
|
+
RuboCop::ConfigLoader.configuration_from_file(config_path)
|
819
932
|
end
|
820
933
|
|
821
934
|
let(:stdout) { $stdout.string }
|
822
935
|
|
823
936
|
before do
|
824
|
-
create_file('.rubocop.yml', ['LineLength:',
|
937
|
+
create_file('.rubocop.yml', ['Style/LineLength:',
|
825
938
|
' Max: 110'])
|
826
939
|
expect { cli.run ['--show-cops'] + cop_list }.to exit_with_code(0)
|
827
940
|
end
|
@@ -880,10 +993,10 @@ describe Rubocop::CLI, :isolated_environment do
|
|
880
993
|
end
|
881
994
|
|
882
995
|
context 'with one cop given' do
|
883
|
-
let(:cop_list) { ['Tab'] }
|
996
|
+
let(:cop_list) { ['Style/Tab'] }
|
884
997
|
|
885
998
|
it 'prints that cop and nothing else' do
|
886
|
-
expect(stdout).to eq(['Tab:',
|
999
|
+
expect(stdout).to eq(['Style/Tab:',
|
887
1000
|
' Description: No hard tabs.',
|
888
1001
|
' Enabled: true',
|
889
1002
|
'',
|
@@ -894,15 +1007,15 @@ describe Rubocop::CLI, :isolated_environment do
|
|
894
1007
|
end
|
895
1008
|
|
896
1009
|
context 'with two cops given' do
|
897
|
-
let(:cop_list) { ['Tab,LineLength'] }
|
1010
|
+
let(:cop_list) { ['Style/Tab,Style/LineLength'] }
|
898
1011
|
include_examples :prints_config
|
899
1012
|
end
|
900
1013
|
|
901
1014
|
context 'with one of the cops misspelled' do
|
902
|
-
let(:cop_list) { ['Tab,X123'] }
|
1015
|
+
let(:cop_list) { ['Style/Tab,Lint/X123'] }
|
903
1016
|
|
904
1017
|
it 'skips the unknown cop' do
|
905
|
-
expect(stdout).to eq(['Tab:',
|
1018
|
+
expect(stdout).to eq(['Style/Tab:',
|
906
1019
|
' Description: No hard tabs.',
|
907
1020
|
' Enabled: true',
|
908
1021
|
'',
|
@@ -1045,7 +1158,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1045
1158
|
context 'when a class name is specified' do
|
1046
1159
|
it 'uses the class as a formatter' do
|
1047
1160
|
module MyTool
|
1048
|
-
class
|
1161
|
+
class RuboCopFormatter < RuboCop::Formatter::BaseFormatter
|
1049
1162
|
def started(all_files)
|
1050
1163
|
output.puts "started: #{all_files.join(',')}"
|
1051
1164
|
end
|
@@ -1064,7 +1177,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1064
1177
|
end
|
1065
1178
|
end
|
1066
1179
|
|
1067
|
-
cli.run(['--format', 'MyTool::
|
1180
|
+
cli.run(['--format', 'MyTool::RuboCopFormatter', 'example.rb'])
|
1068
1181
|
expect($stdout.string).to eq(["started: #{target_file}",
|
1069
1182
|
"file_started: #{target_file}",
|
1070
1183
|
"file_finished: #{target_file}",
|
@@ -1283,7 +1396,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1283
1396
|
'x(123456)',
|
1284
1397
|
'y("123")',
|
1285
1398
|
'def func',
|
1286
|
-
' # rubocop: enable LineLength,
|
1399
|
+
' # rubocop: enable Style/LineLength,Style/StringLiterals',
|
1287
1400
|
' ' + '#' * 93,
|
1288
1401
|
' x(123456)',
|
1289
1402
|
' y("123")',
|
@@ -1302,13 +1415,14 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1302
1415
|
it 'can disable selected cops in a code section' do
|
1303
1416
|
create_file('example.rb',
|
1304
1417
|
['# encoding: utf-8',
|
1305
|
-
'# rubocop:disable LineLength,
|
1306
|
-
'StringLiterals',
|
1418
|
+
'# rubocop:disable Style/LineLength,' \
|
1419
|
+
'Style/NumericLiterals,Style/StringLiterals',
|
1307
1420
|
'#' * 90,
|
1308
1421
|
'x(123456)',
|
1309
1422
|
'y("123")',
|
1310
1423
|
'def func',
|
1311
|
-
' # rubocop: enable LineLength,
|
1424
|
+
' # rubocop: enable Style/LineLength, ' \
|
1425
|
+
'Style/StringLiterals',
|
1312
1426
|
' ' + '#' * 93,
|
1313
1427
|
' x(123456)',
|
1314
1428
|
' y("123")',
|
@@ -1335,9 +1449,10 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1335
1449
|
it 'can disable selected cops on a single line' do
|
1336
1450
|
create_file('example.rb',
|
1337
1451
|
['# encoding: utf-8',
|
1338
|
-
'a' * 90 + ' # rubocop:disable LineLength',
|
1452
|
+
'a' * 90 + ' # rubocop:disable Style/LineLength',
|
1339
1453
|
'#' * 95,
|
1340
|
-
'y("123") # rubocop:disable LineLength,
|
1454
|
+
'y("123") # rubocop:disable Style/LineLength,' \
|
1455
|
+
'Style/StringLiterals'
|
1341
1456
|
])
|
1342
1457
|
expect(cli.run(['--format', 'emacs', 'example.rb'])).to eq(1)
|
1343
1458
|
expect($stdout.string)
|
@@ -1345,6 +1460,22 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1345
1460
|
["#{abs('example.rb')}:3:81: C: Line is too long. [95/80]",
|
1346
1461
|
''].join("\n"))
|
1347
1462
|
end
|
1463
|
+
|
1464
|
+
context 'without using namespace' do
|
1465
|
+
it 'can disable selected cops on a single line' do
|
1466
|
+
create_file('example.rb',
|
1467
|
+
['# encoding: utf-8',
|
1468
|
+
'a' * 90 + ' # rubocop:disable LineLength',
|
1469
|
+
'#' * 95,
|
1470
|
+
'y("123") # rubocop:disable StringLiterals'
|
1471
|
+
])
|
1472
|
+
expect(cli.run(['--format', 'emacs', 'example.rb'])).to eq(1)
|
1473
|
+
expect($stdout.string)
|
1474
|
+
.to eq(
|
1475
|
+
["#{abs('example.rb')}:3:81: C: Line is too long. [95/80]",
|
1476
|
+
''].join("\n"))
|
1477
|
+
end
|
1478
|
+
end
|
1348
1479
|
end
|
1349
1480
|
|
1350
1481
|
it 'finds a file with no .rb extension but has a shebang line' do
|
@@ -1389,14 +1520,14 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1389
1520
|
create_file('dir1/.rubocop.yml', ['AllCops:',
|
1390
1521
|
' RunRailsCops: true',
|
1391
1522
|
'',
|
1392
|
-
'ReadWriteAttribute:',
|
1523
|
+
'Rails/ReadWriteAttribute:',
|
1393
1524
|
' Include:',
|
1394
1525
|
' - app/models/**/*.rb'])
|
1395
1526
|
create_file('dir2/app/models/example2.rb', source)
|
1396
1527
|
create_file('dir2/.rubocop.yml', ['AllCops:',
|
1397
1528
|
' RunRailsCops: false',
|
1398
1529
|
'',
|
1399
|
-
'ReadWriteAttribute:',
|
1530
|
+
'Rails/ReadWriteAttribute:',
|
1400
1531
|
' Include:',
|
1401
1532
|
' - app/models/**/*.rb'])
|
1402
1533
|
expect(cli.run(%w(--format simple dir1 dir2))).to eq(1)
|
@@ -1436,11 +1567,11 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1436
1567
|
create_file('dir1/.rubocop.yml', ['AllCops:',
|
1437
1568
|
' RunRailsCops: true',
|
1438
1569
|
'',
|
1439
|
-
'ReadWriteAttribute:',
|
1570
|
+
'Rails/ReadWriteAttribute:',
|
1440
1571
|
' Exclude:',
|
1441
1572
|
' - "**/example2.rb"',
|
1442
1573
|
'',
|
1443
|
-
'DefaultScope:',
|
1574
|
+
'Rails/DefaultScope:',
|
1444
1575
|
' Exclude:',
|
1445
1576
|
' - "**/example2.rb"'])
|
1446
1577
|
# No .rubocop.yml file in dir2 means that the paths from default.yml
|
@@ -1473,7 +1604,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1473
1604
|
'x = 0'])
|
1474
1605
|
create_file('dir/thing.rb', ['# encoding: utf-8',
|
1475
1606
|
'x = 0'])
|
1476
|
-
create_file('.rubocop.yml', ['UselessAssignment:',
|
1607
|
+
create_file('.rubocop.yml', ['Lint/UselessAssignment:',
|
1477
1608
|
' Exclude:',
|
1478
1609
|
' - example.rb',
|
1479
1610
|
' - !ruby/regexp /regexp.rb\z/',
|
@@ -1590,10 +1721,10 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1590
1721
|
|
1591
1722
|
it 'can be configured with option to disable a certain error' do
|
1592
1723
|
create_file('example1.rb', 'puts 0 ')
|
1593
|
-
create_file('rubocop.yml', ['Encoding:',
|
1724
|
+
create_file('rubocop.yml', ['Style/Encoding:',
|
1594
1725
|
' Enabled: false',
|
1595
1726
|
'',
|
1596
|
-
'CaseIndentation:',
|
1727
|
+
'Style/CaseIndentation:',
|
1597
1728
|
' Enabled: false'])
|
1598
1729
|
expect(cli.run(['--format', 'simple',
|
1599
1730
|
'-c', 'rubocop.yml', 'example1.rb'])).to eq(1)
|
@@ -1605,13 +1736,32 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1605
1736
|
''].join("\n"))
|
1606
1737
|
end
|
1607
1738
|
|
1739
|
+
context 'without using namespace' do
|
1740
|
+
it 'can be configured with option to disable a certain error' do
|
1741
|
+
create_file('example1.rb', 'puts 0 ')
|
1742
|
+
create_file('rubocop.yml', ['Encoding:',
|
1743
|
+
' Enabled: false',
|
1744
|
+
'',
|
1745
|
+
'CaseIndentation:',
|
1746
|
+
' Enabled: false'])
|
1747
|
+
expect(cli.run(['--format', 'simple',
|
1748
|
+
'-c', 'rubocop.yml', 'example1.rb'])).to eq(1)
|
1749
|
+
expect($stdout.string)
|
1750
|
+
.to eq(['== example1.rb ==',
|
1751
|
+
'C: 1: 7: Trailing whitespace detected.',
|
1752
|
+
'',
|
1753
|
+
'1 file inspected, 1 offense detected',
|
1754
|
+
''].join("\n"))
|
1755
|
+
end
|
1756
|
+
end
|
1757
|
+
|
1608
1758
|
it 'can disable parser-derived offenses with warning severity' do
|
1609
1759
|
# `-' interpreted as argument prefix
|
1610
1760
|
create_file('example.rb', 'puts -1')
|
1611
|
-
create_file('.rubocop.yml', ['Encoding:',
|
1761
|
+
create_file('.rubocop.yml', ['Style/Encoding:',
|
1612
1762
|
' Enabled: false',
|
1613
1763
|
'',
|
1614
|
-
'AmbiguousOperator:',
|
1764
|
+
'Lint/AmbiguousOperator:',
|
1615
1765
|
' Enabled: false'
|
1616
1766
|
])
|
1617
1767
|
expect(cli.run(['--format', 'emacs', 'example.rb'])).to eq(0)
|
@@ -1619,7 +1769,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1619
1769
|
|
1620
1770
|
it 'cannot disable Syntax offenses with fatal/error severity' do
|
1621
1771
|
create_file('example.rb', 'class Test')
|
1622
|
-
create_file('.rubocop.yml', ['Encoding:',
|
1772
|
+
create_file('.rubocop.yml', ['Style/Encoding:',
|
1623
1773
|
' Enabled: false',
|
1624
1774
|
'',
|
1625
1775
|
'Syntax:',
|
@@ -1637,7 +1787,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1637
1787
|
# We want to change the preferred delimiters for word arrays. The other
|
1638
1788
|
# settings from default.yml are unchanged.
|
1639
1789
|
create_file('rubocop.yml',
|
1640
|
-
['PercentLiteralDelimiters:',
|
1790
|
+
['Style/PercentLiteralDelimiters:',
|
1641
1791
|
' PreferredDelimiters:',
|
1642
1792
|
" '%w': '[]'",
|
1643
1793
|
" '%W': '[]'"])
|
@@ -1661,7 +1811,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1661
1811
|
# select over find_all. Other preferred methods appearing in the default
|
1662
1812
|
# config (e.g., map over collect) are kept.
|
1663
1813
|
create_file('rubocop.yml',
|
1664
|
-
['CollectionMethods:',
|
1814
|
+
['Style/CollectionMethods:',
|
1665
1815
|
' PreferredMethods:',
|
1666
1816
|
' select: find_all'])
|
1667
1817
|
cli.run(['--format', 'simple', '-c', 'rubocop.yml', 'example1.rb'])
|
@@ -1678,10 +1828,10 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1678
1828
|
create_file('example1.rb', ['if a',
|
1679
1829
|
' b',
|
1680
1830
|
'end'])
|
1681
|
-
create_file('rubocop.yml', ['Encoding:',
|
1831
|
+
create_file('rubocop.yml', ['Style/Encoding:',
|
1682
1832
|
' Enabled: false',
|
1683
1833
|
'',
|
1684
|
-
'LineLength:',
|
1834
|
+
'Style/LineLength:',
|
1685
1835
|
' Enabled: false'
|
1686
1836
|
])
|
1687
1837
|
result = cli.run(['--format', 'simple',
|
@@ -1699,10 +1849,10 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1699
1849
|
|
1700
1850
|
it 'can be configured with project config to disable a certain error' do
|
1701
1851
|
create_file('example_src/example1.rb', 'puts 0 ')
|
1702
|
-
create_file('example_src/.rubocop.yml', ['Encoding:',
|
1852
|
+
create_file('example_src/.rubocop.yml', ['Style/Encoding:',
|
1703
1853
|
' Enabled: false',
|
1704
1854
|
'',
|
1705
|
-
'CaseIndentation:',
|
1855
|
+
'Style/CaseIndentation:',
|
1706
1856
|
' Enabled: false'
|
1707
1857
|
])
|
1708
1858
|
expect(cli.run(['--format', 'simple',
|
@@ -1719,7 +1869,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1719
1869
|
create_file('example_src/example1.rb', ['# encoding: utf-8',
|
1720
1870
|
'#' * 90
|
1721
1871
|
])
|
1722
|
-
create_file('example_src/.rubocop.yml', ['LineLength:',
|
1872
|
+
create_file('example_src/.rubocop.yml', ['Style/LineLength:',
|
1723
1873
|
' Enabled: true',
|
1724
1874
|
' Max: 100'
|
1725
1875
|
])
|
@@ -1735,7 +1885,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1735
1885
|
'#' * 90
|
1736
1886
|
])
|
1737
1887
|
end
|
1738
|
-
create_file('example/src/.rubocop.yml', ['LineLength:',
|
1888
|
+
create_file('example/src/.rubocop.yml', ['Style/LineLength:',
|
1739
1889
|
' Enabled: true',
|
1740
1890
|
' Max: 100'
|
1741
1891
|
])
|
@@ -1752,11 +1902,11 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1752
1902
|
create_file('example_src/example1.rb', ['# encoding: utf-8',
|
1753
1903
|
'#' * 90
|
1754
1904
|
])
|
1755
|
-
create_file('example_src/.rubocop.yml', ['LineLength:',
|
1905
|
+
create_file('example_src/.rubocop.yml', ['Style/LineLength:',
|
1756
1906
|
' Enabled: true',
|
1757
1907
|
' Max: 100'
|
1758
1908
|
])
|
1759
|
-
create_file("#{Dir.home}/.rubocop.yml", ['LineLength:',
|
1909
|
+
create_file("#{Dir.home}/.rubocop.yml", ['Style/LineLength:',
|
1760
1910
|
' Enabled: true',
|
1761
1911
|
' Max: 80'
|
1762
1912
|
])
|
@@ -1876,14 +2026,13 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1876
2026
|
create_file('example/example1.rb', ['# encoding: utf-8',
|
1877
2027
|
'#' * 90])
|
1878
2028
|
|
1879
|
-
create_file('example/.rubocop.yml', ['LyneLenth:',
|
2029
|
+
create_file('example/.rubocop.yml', ['Style/LyneLenth:',
|
1880
2030
|
' Enabled: true',
|
1881
2031
|
' Max: 100'])
|
1882
2032
|
|
1883
2033
|
expect(cli.run(%w(--format simple example))).to eq(1)
|
1884
2034
|
expect($stderr.string)
|
1885
|
-
.to eq(
|
1886
|
-
['Warning: unrecognized cop LyneLenth found in ' +
|
2035
|
+
.to eq(['Warning: unrecognized cop Style/LyneLenth found in ' +
|
1887
2036
|
abs('example/.rubocop.yml'),
|
1888
2037
|
''].join("\n"))
|
1889
2038
|
end
|
@@ -1892,15 +2041,14 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1892
2041
|
create_file('example/example1.rb', ['# encoding: utf-8',
|
1893
2042
|
'#' * 90])
|
1894
2043
|
|
1895
|
-
create_file('example/.rubocop.yml', ['LineLength:',
|
2044
|
+
create_file('example/.rubocop.yml', ['Style/LineLength:',
|
1896
2045
|
' Enabled: true',
|
1897
2046
|
' Min: 10'])
|
1898
2047
|
|
1899
2048
|
expect(cli.run(%w(--format simple example))).to eq(1)
|
1900
2049
|
expect($stderr.string)
|
1901
|
-
.to eq(
|
1902
|
-
|
1903
|
-
abs('example/.rubocop.yml'),
|
2050
|
+
.to eq(['Warning: unrecognized parameter Style/LineLength:Min found ' \
|
2051
|
+
'in ' + abs('example/.rubocop.yml'),
|
1904
2052
|
''].join("\n"))
|
1905
2053
|
end
|
1906
2054
|
|
@@ -1938,7 +2086,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1938
2086
|
create_file('example/example1.rb', ['# encoding: utf-8',
|
1939
2087
|
'#' * 90])
|
1940
2088
|
|
1941
|
-
create_file('rubocop.yml', ['LineLength:',
|
2089
|
+
create_file('rubocop.yml', ['Style/LineLength:',
|
1942
2090
|
' Severity: error'])
|
1943
2091
|
|
1944
2092
|
cli.run(%w(--format simple -c rubocop.yml))
|
@@ -1955,7 +2103,7 @@ describe Rubocop::CLI, :isolated_environment do
|
|
1955
2103
|
create_file('example/example1.rb', ['# encoding: utf-8',
|
1956
2104
|
'#' * 90])
|
1957
2105
|
|
1958
|
-
create_file('rubocop.yml', ['LineLength:',
|
2106
|
+
create_file('rubocop.yml', ['Style/LineLength:',
|
1959
2107
|
' Severity: superbad'])
|
1960
2108
|
|
1961
2109
|
cli.run(%w(--format simple -c rubocop.yml))
|