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
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe RuboCop::CommentConfig do
|
6
6
|
subject(:comment_config) { described_class.new(parse_source(source)) }
|
7
7
|
|
8
8
|
describe '#cop_enabled_at_line?' do
|
@@ -10,33 +10,34 @@ describe Rubocop::CommentConfig do
|
|
10
10
|
[
|
11
11
|
'# encoding: utf-8',
|
12
12
|
'',
|
13
|
-
'# rubocop:disable MethodLength',
|
13
|
+
'# rubocop:disable Style/MethodLength',
|
14
14
|
'def some_method',
|
15
15
|
" puts 'foo'",
|
16
16
|
'end',
|
17
|
-
'# rubocop:enable MethodLength',
|
17
|
+
'# rubocop:enable Style/MethodLength',
|
18
18
|
'',
|
19
19
|
'# rubocop:disable all',
|
20
20
|
'some_method',
|
21
21
|
'# rubocop:enable all',
|
22
22
|
'',
|
23
23
|
"code = 'This is evil.'",
|
24
|
-
'eval(code) # rubocop:disable Eval',
|
24
|
+
'eval(code) # rubocop:disable Lint/Eval',
|
25
25
|
"puts 'This is not evil.'",
|
26
26
|
'',
|
27
27
|
'def some_method',
|
28
|
-
" puts 'Disabling indented single line' # rubocop:disable
|
28
|
+
" puts 'Disabling indented single line' # rubocop:disable " \
|
29
|
+
'Style/LineLength',
|
29
30
|
'end',
|
30
31
|
'',
|
31
32
|
'string = <<END',
|
32
|
-
'This is a string not a real comment # rubocop:disable Loop',
|
33
|
+
'This is a string not a real comment # rubocop:disable Style/Loop',
|
33
34
|
'END',
|
34
35
|
'',
|
35
|
-
'foo # rubocop:disable MethodCallParentheses',
|
36
|
+
'foo # rubocop:disable Style/MethodCallParentheses',
|
36
37
|
'',
|
37
|
-
'# rubocop:enable Void',
|
38
|
+
'# rubocop:enable Style/Void',
|
38
39
|
'',
|
39
|
-
'# rubocop:disable For',
|
40
|
+
'# rubocop:disable Style/For',
|
40
41
|
'foo'
|
41
42
|
]
|
42
43
|
end
|
@@ -49,33 +50,34 @@ describe Rubocop::CommentConfig do
|
|
49
50
|
end
|
50
51
|
|
51
52
|
it 'supports disabling multiple lines with a pair of directive' do
|
52
|
-
method_length_disabled_lines =
|
53
|
+
method_length_disabled_lines =
|
54
|
+
disabled_lines_of_cop('Style/MethodLength')
|
53
55
|
expected_part = (3..6).to_a
|
54
56
|
expect(method_length_disabled_lines & expected_part)
|
55
57
|
.to eq(expected_part)
|
56
58
|
end
|
57
59
|
|
58
60
|
it 'supports disabling all lines after a directive' do
|
59
|
-
for_disabled_lines = disabled_lines_of_cop('For')
|
61
|
+
for_disabled_lines = disabled_lines_of_cop('Style/For')
|
60
62
|
expected_part = (29..source.size).to_a
|
61
63
|
expect(for_disabled_lines & expected_part)
|
62
64
|
.to eq(expected_part)
|
63
65
|
end
|
64
66
|
|
65
67
|
it 'just ignores unpaired enabling directives' do
|
66
|
-
void_disabled_lines = disabled_lines_of_cop('Void')
|
68
|
+
void_disabled_lines = disabled_lines_of_cop('Lint/Void')
|
67
69
|
expected_part = (27..source.size).to_a
|
68
70
|
expect(void_disabled_lines & expected_part).to be_empty
|
69
71
|
end
|
70
72
|
|
71
73
|
it 'supports disabling single line with a direcive at end of line' do
|
72
|
-
eval_disabled_lines = disabled_lines_of_cop('Eval')
|
74
|
+
eval_disabled_lines = disabled_lines_of_cop('Lint/Eval')
|
73
75
|
expect(eval_disabled_lines).to include(14)
|
74
76
|
expect(eval_disabled_lines).not_to include(15)
|
75
77
|
end
|
76
78
|
|
77
79
|
it 'handles indented single line' do
|
78
|
-
line_length_disabled_lines = disabled_lines_of_cop('LineLength')
|
80
|
+
line_length_disabled_lines = disabled_lines_of_cop('Style/LineLength')
|
79
81
|
expect(line_length_disabled_lines).to include(18)
|
80
82
|
expect(line_length_disabled_lines).not_to include(19)
|
81
83
|
end
|
@@ -89,7 +91,7 @@ describe Rubocop::CommentConfig do
|
|
89
91
|
it 'supports disabling all cops with keyword all' do
|
90
92
|
expected_part = (9..10).to_a
|
91
93
|
|
92
|
-
|
94
|
+
RuboCop::Cop::Cop.all.each do |cop|
|
93
95
|
disabled_lines = disabled_lines_of_cop(cop)
|
94
96
|
expect(disabled_lines & expected_part).to eq(expected_part)
|
95
97
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe RuboCop::ConfigLoader do
|
6
6
|
include FileHelper
|
7
7
|
|
8
8
|
let(:default_config) { described_class.default_configuration }
|
@@ -68,14 +68,14 @@ describe Rubocop::ConfigLoader do
|
|
68
68
|
let(:file_path) { '.rubocop.yml' }
|
69
69
|
|
70
70
|
before do
|
71
|
-
create_file(file_path, ['Encoding:',
|
71
|
+
create_file(file_path, ['Style/Encoding:',
|
72
72
|
' Enabled: false'])
|
73
73
|
end
|
74
74
|
it 'returns a configuration inheriting from default.yml' do
|
75
|
-
config = default_config['Encoding'].dup
|
75
|
+
config = default_config['Style/Encoding'].dup
|
76
76
|
config['Enabled'] = false
|
77
77
|
expect(configuration_from_file)
|
78
|
-
.to eql(default_config.merge('Encoding' => config))
|
78
|
+
.to eql(default_config.merge('Style/Encoding' => config))
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -161,14 +161,14 @@ describe Rubocop::ConfigLoader do
|
|
161
161
|
create_file('dir/subdir/example.rb', '')
|
162
162
|
|
163
163
|
create_file('.rubocop.yml',
|
164
|
-
['LineLength:',
|
164
|
+
['Style/LineLength:',
|
165
165
|
' Enabled: false',
|
166
166
|
' Max: 77'])
|
167
167
|
|
168
168
|
create_file('dir/.rubocop.yml',
|
169
169
|
['inherit_from: ../.rubocop.yml',
|
170
170
|
'',
|
171
|
-
'MethodLength:',
|
171
|
+
'Style/MethodLength:',
|
172
172
|
' Enabled: true',
|
173
173
|
' CountComments: false',
|
174
174
|
' Max: 10'
|
@@ -177,29 +177,30 @@ describe Rubocop::ConfigLoader do
|
|
177
177
|
create_file(file_path,
|
178
178
|
['inherit_from: ../.rubocop.yml',
|
179
179
|
'',
|
180
|
-
'LineLength:',
|
180
|
+
'Style/LineLength:',
|
181
181
|
' Enabled: true',
|
182
182
|
'',
|
183
|
-
'MethodLength:',
|
183
|
+
'Style/MethodLength:',
|
184
184
|
' Max: 5'
|
185
185
|
])
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'returns the ancestor configuration plus local overrides' do
|
189
|
-
config =
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
189
|
+
config =
|
190
|
+
default_config
|
191
|
+
.merge('Style/LineLength' => {
|
192
|
+
'Description' =>
|
193
|
+
default_config['Style/LineLength']['Description'],
|
194
|
+
'Enabled' => true,
|
195
|
+
'Max' => 77
|
196
|
+
},
|
197
|
+
'Style/MethodLength' => {
|
198
|
+
'Description' =>
|
199
|
+
default_config['Style/MethodLength']['Description'],
|
200
|
+
'Enabled' => true,
|
201
|
+
'CountComments' => false,
|
202
|
+
'Max' => 5
|
203
|
+
})
|
203
204
|
expect(configuration_from_file).to eq(config)
|
204
205
|
end
|
205
206
|
end
|
@@ -211,13 +212,13 @@ describe Rubocop::ConfigLoader do
|
|
211
212
|
create_file('example.rb', '')
|
212
213
|
|
213
214
|
create_file('normal.yml',
|
214
|
-
['MethodLength:',
|
215
|
+
['Style/MethodLength:',
|
215
216
|
' Enabled: false',
|
216
217
|
' CountComments: true',
|
217
218
|
' Max: 80'])
|
218
219
|
|
219
220
|
create_file('special.yml',
|
220
|
-
['MethodLength:',
|
221
|
+
['Style/MethodLength:',
|
221
222
|
' Enabled: false',
|
222
223
|
' Max: 200'])
|
223
224
|
|
@@ -226,7 +227,7 @@ describe Rubocop::ConfigLoader do
|
|
226
227
|
' - normal.yml',
|
227
228
|
' - special.yml',
|
228
229
|
'',
|
229
|
-
'MethodLength:',
|
230
|
+
'Style/MethodLength:',
|
230
231
|
' Enabled: true'
|
231
232
|
])
|
232
233
|
end
|
@@ -235,7 +236,7 @@ describe Rubocop::ConfigLoader do
|
|
235
236
|
expected = { 'Enabled' => true, # overridden in .rubocop.yml
|
236
237
|
'CountComments' => true, # only defined in normal.yml
|
237
238
|
'Max' => 200 } # special.yml takes precedence
|
238
|
-
expect(configuration_from_file['MethodLength'].to_set)
|
239
|
+
expect(configuration_from_file['Style/MethodLength'].to_set)
|
239
240
|
.to be_superset(expected.to_set)
|
240
241
|
end
|
241
242
|
end
|
@@ -250,11 +251,11 @@ describe Rubocop::ConfigLoader do
|
|
250
251
|
|
251
252
|
it 'returns a configuration loaded from the passed path' do
|
252
253
|
create_file(configuration_path, [
|
253
|
-
'Encoding:',
|
254
|
+
'Style/Encoding:',
|
254
255
|
' Enabled: true'
|
255
256
|
])
|
256
257
|
configuration = load_file
|
257
|
-
expect(configuration['Encoding']).to eq(
|
258
|
+
expect(configuration['Style/Encoding']).to eq(
|
258
259
|
'Enabled' => true
|
259
260
|
)
|
260
261
|
end
|
@@ -291,27 +292,27 @@ describe Rubocop::ConfigLoader do
|
|
291
292
|
|
292
293
|
context 'when no config file exists for the target file' do
|
293
294
|
it 'is disabled' do
|
294
|
-
expect(config.cop_enabled?('SymbolArray')).to be_false
|
295
|
+
expect(config.cop_enabled?('Style/SymbolArray')).to be_false
|
295
296
|
end
|
296
297
|
end
|
297
298
|
|
298
299
|
context 'when a config file which does not mention SymbolArray exists' do
|
299
300
|
it 'is disabled' do
|
300
301
|
create_file('.rubocop.yml', [
|
301
|
-
'LineLength:',
|
302
|
+
'Style/LineLength:',
|
302
303
|
' Max: 80'
|
303
304
|
])
|
304
|
-
expect(config.cop_enabled?('SymbolArray')).to be_false
|
305
|
+
expect(config.cop_enabled?('Style/SymbolArray')).to be_false
|
305
306
|
end
|
306
307
|
end
|
307
308
|
|
308
309
|
context 'when a config file which explicitly enables SymbolArray exists' do
|
309
310
|
it 'is enabled' do
|
310
311
|
create_file('.rubocop.yml', [
|
311
|
-
'SymbolArray:',
|
312
|
+
'Style/SymbolArray:',
|
312
313
|
' Enabled: true'
|
313
314
|
])
|
314
|
-
expect(config.cop_enabled?('SymbolArray')).to be_true
|
315
|
+
expect(config.cop_enabled?('Style/SymbolArray')).to be_true
|
315
316
|
end
|
316
317
|
end
|
317
318
|
end
|
@@ -320,9 +321,25 @@ describe Rubocop::ConfigLoader do
|
|
320
321
|
describe 'AllowSafeAssignment' do
|
321
322
|
it 'is enabled by default' do
|
322
323
|
default_config = described_class.default_configuration
|
323
|
-
symbol_name_config =
|
324
|
+
symbol_name_config =
|
325
|
+
default_config.for_cop('Lint/AssignmentInCondition')
|
324
326
|
expect(symbol_name_config['AllowSafeAssignment']).to be_true
|
325
327
|
end
|
326
328
|
end
|
327
329
|
end
|
330
|
+
|
331
|
+
describe 'when a requirement is defined', :isolated_environment do
|
332
|
+
let(:required_file_path) { './required_file.rb' }
|
333
|
+
|
334
|
+
before do
|
335
|
+
create_file('.rubocop.yml', ['require:', " - #{required_file_path}"])
|
336
|
+
create_file(required_file_path, ['class MyClass', 'end'])
|
337
|
+
end
|
338
|
+
|
339
|
+
it 'requires the passed path' do
|
340
|
+
config_path = described_class.configuration_file_for('.')
|
341
|
+
described_class.configuration_from_file(config_path)
|
342
|
+
expect(defined?(MyClass)).to be_true
|
343
|
+
end
|
344
|
+
end
|
328
345
|
end
|
data/spec/rubocop/config_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe RuboCop::Config do
|
6
6
|
include FileHelper
|
7
7
|
|
8
8
|
subject(:configuration) { described_class.new(hash, loaded_path) }
|
@@ -17,7 +17,7 @@ describe Rubocop::Config do
|
|
17
17
|
after(:each) { $stderr = STDERR }
|
18
18
|
|
19
19
|
subject(:configuration) do
|
20
|
-
|
20
|
+
RuboCop::ConfigLoader.load_file(configuration_path)
|
21
21
|
end
|
22
22
|
|
23
23
|
let(:configuration_path) { '.rubocop.yml' }
|
@@ -41,7 +41,7 @@ describe Rubocop::Config do
|
|
41
41
|
context 'when the configuration includes any unrecognized parameter' do
|
42
42
|
before do
|
43
43
|
create_file(configuration_path, [
|
44
|
-
'LineLength:',
|
44
|
+
'Style/LineLength:',
|
45
45
|
' Enabled: true',
|
46
46
|
' Min: 10'
|
47
47
|
])
|
@@ -50,7 +50,7 @@ describe Rubocop::Config do
|
|
50
50
|
it 'raises validation error' do
|
51
51
|
expect { configuration.validate }
|
52
52
|
.to raise_error(described_class::ValidationError,
|
53
|
-
/^unrecognized parameter LineLength:Min/)
|
53
|
+
/^unrecognized parameter Style\/LineLength:Min/)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -59,7 +59,7 @@ describe Rubocop::Config do
|
|
59
59
|
# configuration, but are nonetheless allowed for any cop.
|
60
60
|
before do
|
61
61
|
create_file(configuration_path, [
|
62
|
-
'LineLength:',
|
62
|
+
'Style/LineLength:',
|
63
63
|
' Exclude:',
|
64
64
|
' - lib/file.rb',
|
65
65
|
' Include:',
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe RuboCop::ConfigStore do
|
6
6
|
subject(:config_store) { described_class.new }
|
7
7
|
|
8
8
|
before do
|
9
|
-
allow(
|
9
|
+
allow(RuboCop::ConfigLoader).to receive(:configuration_file_for) do |arg|
|
10
10
|
# File tree:
|
11
11
|
# file1
|
12
12
|
# dir/.rubocop.yml
|
@@ -14,11 +14,11 @@ describe Rubocop::ConfigStore do
|
|
14
14
|
# dir/subdir/file3
|
15
15
|
(arg =~ /dir/ ? 'dir' : '.') + '/.rubocop.yml'
|
16
16
|
end
|
17
|
-
allow(
|
17
|
+
allow(RuboCop::ConfigLoader)
|
18
18
|
.to receive(:configuration_from_file) { |arg| arg }
|
19
|
-
allow(
|
20
|
-
.to receive(:load_file) { |arg|
|
21
|
-
allow(
|
19
|
+
allow(RuboCop::ConfigLoader)
|
20
|
+
.to receive(:load_file) { |arg| RuboCop::Config.new(arg) }
|
21
|
+
allow(RuboCop::ConfigLoader)
|
22
22
|
.to receive(:merge_with_default) { |config| "merged #{config}" }
|
23
23
|
end
|
24
24
|
|
@@ -30,12 +30,12 @@ describe Rubocop::ConfigStore do
|
|
30
30
|
|
31
31
|
context 'when no config specified in command line' do
|
32
32
|
it 'gets config path and config from cache if available' do
|
33
|
-
expect(
|
33
|
+
expect(RuboCop::ConfigLoader).to receive(:configuration_file_for).once
|
34
34
|
.with('dir')
|
35
|
-
expect(
|
35
|
+
expect(RuboCop::ConfigLoader).to receive(:configuration_file_for).once
|
36
36
|
.with('dir/subdir')
|
37
37
|
# The stub returns the same config path for dir and dir/subdir.
|
38
|
-
expect(
|
38
|
+
expect(RuboCop::ConfigLoader).to receive(:configuration_from_file).once
|
39
39
|
.with('dir/.rubocop.yml')
|
40
40
|
|
41
41
|
config_store.for('dir/file2')
|
@@ -44,8 +44,8 @@ describe Rubocop::ConfigStore do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'searches for config path if not available in cache' do
|
47
|
-
expect(
|
48
|
-
expect(
|
47
|
+
expect(RuboCop::ConfigLoader).to receive(:configuration_file_for).once
|
48
|
+
expect(RuboCop::ConfigLoader).to receive(:configuration_from_file).once
|
49
49
|
config_store.for('file1')
|
50
50
|
end
|
51
51
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
# rubocop:disable LineLength
|
2
|
+
# rubocop:disable Style/LineLength
|
3
3
|
|
4
4
|
require 'spec_helper'
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe RuboCop::Cop::Commissioner do
|
7
7
|
describe '#investigate' do
|
8
|
-
let(:cop) { double(
|
9
|
-
let(:force) { double(
|
8
|
+
let(:cop) { double(RuboCop::Cop, offenses: []).as_null_object }
|
9
|
+
let(:force) { double(RuboCop::Cop::Force).as_null_object }
|
10
10
|
|
11
11
|
it 'returns all offenses found by the cops' do
|
12
12
|
allow(cop).to receive(:offenses).and_return([1])
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe RuboCop::Cop::Cop do
|
6
6
|
subject(:cop) { described_class.new }
|
7
7
|
let(:location) do
|
8
8
|
source_buffer = Parser::Source::Buffer.new('test', 1)
|
@@ -14,6 +14,29 @@ describe Rubocop::Cop::Cop do
|
|
14
14
|
expect(cop.offenses).to be_empty
|
15
15
|
end
|
16
16
|
|
17
|
+
describe '.qualified_cop_name' do
|
18
|
+
it 'adds namespace if the cop name is found in exactly one namespace' do
|
19
|
+
expect(described_class.qualified_cop_name('LineLength', '--only'))
|
20
|
+
.to eq('Style/LineLength')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns the given cop name if it is not found in any namespace' do
|
24
|
+
expect(described_class.qualified_cop_name('UnknownCop', '--only'))
|
25
|
+
.to eq('UnknownCop')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the given cop name if it already has a namespace' do
|
29
|
+
expect(described_class.qualified_cop_name('Style/LineLength', '--only'))
|
30
|
+
.to eq('Style/LineLength')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raises an error if the cop name is in more than one namespace' do
|
34
|
+
pending 'Example needs a cop with same name in two namespaces'
|
35
|
+
expect { described_class.qualified_cop_name('ExampleCop', '--only') }
|
36
|
+
.to raise_error(RuboCop::Cop::AmbiguousCopName)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
17
40
|
it 'keeps track of offenses' do
|
18
41
|
cop.add_offense(nil, location, 'message')
|
19
42
|
|
@@ -46,32 +69,32 @@ describe Rubocop::Cop::Cop do
|
|
46
69
|
end
|
47
70
|
|
48
71
|
it 'registers offense with its name' do
|
49
|
-
cop =
|
72
|
+
cop = RuboCop::Cop::Style::For.new
|
50
73
|
cop.add_offense(nil, location, 'message')
|
51
|
-
expect(cop.offenses.first.cop_name).to eq('For')
|
74
|
+
expect(cop.offenses.first.cop_name).to eq('Style/For')
|
52
75
|
end
|
53
76
|
|
54
77
|
context 'with no submodule' do
|
55
78
|
subject(:cop) { described_class }
|
56
|
-
it('has right name') { expect(cop.cop_name).to eq('Cop') }
|
79
|
+
it('has right name') { expect(cop.cop_name).to eq('Cop/Cop') }
|
57
80
|
it('has right type') { expect(cop.cop_type).to eq(:cop) }
|
58
81
|
end
|
59
82
|
|
60
83
|
context 'with style cops' do
|
61
|
-
subject(:cop) {
|
62
|
-
it('has right name') { expect(cop.cop_name).to eq('For') }
|
84
|
+
subject(:cop) { RuboCop::Cop::Style::For }
|
85
|
+
it('has right name') { expect(cop.cop_name).to eq('Style/For') }
|
63
86
|
it('has right type') { expect(cop.cop_type).to eq(:style) }
|
64
87
|
end
|
65
88
|
|
66
89
|
context 'with lint cops' do
|
67
|
-
subject(:cop) {
|
68
|
-
it('has right name') { expect(cop.cop_name).to eq('Loop') }
|
90
|
+
subject(:cop) { RuboCop::Cop::Lint::Loop }
|
91
|
+
it('has right name') { expect(cop.cop_name).to eq('Lint/Loop') }
|
69
92
|
it('has right type') { expect(cop.cop_type).to eq(:lint) }
|
70
93
|
end
|
71
94
|
|
72
95
|
context 'with rails cops' do
|
73
|
-
subject(:cop) {
|
74
|
-
it('has right name') { expect(cop.cop_name).to eq('Validation') }
|
96
|
+
subject(:cop) { RuboCop::Cop::Rails::Validation }
|
97
|
+
it('has right name') { expect(cop.cop_name).to eq('Rails/Validation') }
|
75
98
|
it('has right type') { expect(cop.cop_type).to eq(:rails) }
|
76
99
|
end
|
77
100
|
|