rubocop 0.18.1 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +65 -1
- data/Gemfile +0 -3
- data/LICENSE.txt +1 -1
- data/README.md +179 -77
- data/Rakefile +8 -0
- data/config/default.yml +151 -14
- data/config/enabled.yml +65 -8
- data/lib/rubocop.rb +19 -4
- data/lib/rubocop/cli.rb +2 -1
- data/lib/rubocop/comment_config.rb +97 -0
- data/lib/rubocop/config.rb +1 -1
- data/lib/rubocop/config_loader.rb +3 -2
- data/lib/rubocop/config_store.rb +6 -2
- data/lib/rubocop/cop/commissioner.rb +2 -2
- data/lib/rubocop/cop/cop.rb +22 -26
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +2 -2
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +1 -1
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/block_alignment.rb +6 -6
- data/lib/rubocop/cop/lint/condition_position.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +1 -1
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +60 -0
- data/lib/rubocop/cop/lint/else_layout.rb +1 -1
- data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
- data/lib/rubocop/cop/lint/end_alignment.rb +14 -12
- data/lib/rubocop/cop/lint/end_in_method.rb +1 -1
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
- data/lib/rubocop/cop/lint/eval.rb +1 -1
- data/lib/rubocop/cop/lint/handle_exceptions.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_condition.rb +13 -2
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +28 -0
- data/lib/rubocop/cop/lint/loop.rb +4 -4
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/require_parentheses.rb +6 -6
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +2 -2
- data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +30 -0
- data/lib/rubocop/cop/lint/syntax.rb +5 -5
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/useless_assignment.rb +5 -5
- data/lib/rubocop/cop/lint/useless_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +5 -5
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +8 -5
- data/lib/rubocop/cop/mixin/code_length.rb +2 -2
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +7 -7
- data/lib/rubocop/cop/mixin/configurable_max.rb +1 -1
- data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
- data/lib/rubocop/cop/mixin/if_then_else.rb +1 -1
- data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
- data/lib/rubocop/cop/mixin/parser_diagnostic.rb +2 -2
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +3 -2
- data/lib/rubocop/cop/mixin/space_inside.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +1 -0
- data/lib/rubocop/cop/mixin/string_help.rb +4 -4
- data/lib/rubocop/cop/{offence.rb → offense.rb} +7 -7
- data/lib/rubocop/cop/rails/action_filter.rb +73 -0
- data/lib/rubocop/cop/rails/default_scope.rb +1 -1
- data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +1 -1
- data/lib/rubocop/cop/rails/output.rb +1 -10
- data/lib/rubocop/cop/rails/read_attribute.rb +1 -1
- data/lib/rubocop/cop/rails/scope_args.rb +33 -0
- data/lib/rubocop/cop/rails/validation.rb +1 -1
- data/lib/rubocop/cop/style/access_modifier_indentation.rb +1 -1
- data/lib/rubocop/cop/style/accessor_method_name.rb +2 -2
- data/lib/rubocop/cop/style/alias.rb +2 -2
- data/lib/rubocop/cop/style/align_array.rb +1 -1
- data/lib/rubocop/cop/style/align_hash.rb +29 -2
- data/lib/rubocop/cop/style/align_parameters.rb +16 -2
- data/lib/rubocop/cop/style/and_or.rb +2 -2
- data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
- data/lib/rubocop/cop/style/ascii_identifiers.rb +1 -1
- data/lib/rubocop/cop/style/attr.rb +1 -1
- data/lib/rubocop/cop/style/begin_block.rb +1 -1
- data/lib/rubocop/cop/style/block_comments.rb +1 -1
- data/lib/rubocop/cop/style/block_nesting.rb +1 -1
- data/lib/rubocop/cop/style/blocks.rb +2 -2
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +2 -2
- data/lib/rubocop/cop/style/case_equality.rb +1 -1
- data/lib/rubocop/cop/style/case_indentation.rb +2 -2
- data/lib/rubocop/cop/style/character_literal.rb +2 -2
- data/lib/rubocop/cop/style/class_and_module_camel_case.rb +1 -1
- data/lib/rubocop/cop/style/class_and_module_children.rb +69 -0
- data/lib/rubocop/cop/style/class_methods.rb +1 -1
- data/lib/rubocop/cop/style/class_vars.rb +3 -3
- data/lib/rubocop/cop/style/collection_methods.rb +4 -4
- data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
- data/lib/rubocop/cop/style/constant_name.rb +1 -1
- data/lib/rubocop/cop/style/cyclomatic_complexity.rb +2 -2
- data/lib/rubocop/cop/style/def_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/documentation.rb +1 -1
- data/lib/rubocop/cop/style/dot_position.rb +10 -11
- data/lib/rubocop/cop/style/double_negation.rb +40 -0
- data/lib/rubocop/cop/style/empty_line_between_defs.rb +8 -1
- data/lib/rubocop/cop/style/empty_lines.rb +3 -2
- data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +1 -1
- data/lib/rubocop/cop/style/empty_lines_around_body.rb +1 -1
- data/lib/rubocop/cop/style/empty_literal.rb +3 -3
- data/lib/rubocop/cop/style/encoding.rb +1 -1
- data/lib/rubocop/cop/style/end_block.rb +1 -1
- data/lib/rubocop/cop/style/end_of_line.rb +2 -2
- data/lib/rubocop/cop/style/even_odd.rb +2 -2
- data/lib/rubocop/cop/style/favor_join.rb +1 -1
- data/lib/rubocop/cop/style/file_name.rb +29 -0
- data/lib/rubocop/cop/style/final_newline.rb +1 -1
- data/lib/rubocop/cop/style/flip_flop.rb +2 -2
- data/lib/rubocop/cop/style/for.rb +2 -2
- data/lib/rubocop/cop/style/format_string.rb +66 -0
- data/lib/rubocop/cop/style/global_vars.rb +2 -2
- data/lib/rubocop/cop/style/hash_methods.rb +1 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +3 -3
- data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -1
- data/lib/rubocop/cop/style/indent_array.rb +41 -0
- data/lib/rubocop/cop/style/indent_hash.rb +119 -0
- data/lib/rubocop/cop/style/indentation_consistency.rb +3 -11
- data/lib/rubocop/cop/style/indentation_width.rb +44 -23
- data/lib/rubocop/cop/style/lambda.rb +2 -2
- data/lib/rubocop/cop/style/lambda_call.rb +3 -3
- data/lib/rubocop/cop/style/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +7 -3
- data/lib/rubocop/cop/style/line_length.rb +2 -2
- data/lib/rubocop/cop/style/method_call_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -2
- data/lib/rubocop/cop/style/method_def_parentheses.rb +9 -7
- data/lib/rubocop/cop/style/module_function.rb +1 -1
- data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +2 -2
- data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literals.rb +5 -5
- data/lib/rubocop/cop/style/op_method.rb +2 -2
- data/lib/rubocop/cop/style/parameter_lists.rb +1 -1
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +5 -4
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +143 -0
- data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
- data/lib/rubocop/cop/style/predicate_name.rb +1 -1
- data/lib/rubocop/cop/style/proc.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +2 -2
- data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +1 -1
- data/lib/rubocop/cop/style/redundant_return.rb +1 -1
- data/lib/rubocop/cop/style/redundant_self.rb +2 -2
- data/lib/rubocop/cop/style/regexp_literal.rb +45 -19
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +73 -0
- data/lib/rubocop/cop/style/semicolon.rb +12 -8
- data/lib/rubocop/cop/style/signal_exception.rb +2 -2
- data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +38 -1
- data/lib/rubocop/cop/style/space_after_colon.rb +3 -3
- data/lib/rubocop/cop/style/space_after_comma.rb +1 -1
- data/lib/rubocop/cop/style/space_after_control_keyword.rb +1 -1
- data/lib/rubocop/cop/style/space_after_method_name.rb +11 -3
- data/lib/rubocop/cop/style/space_after_not.rb +1 -1
- data/lib/rubocop/cop/style/space_after_semicolon.rb +1 -1
- data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +41 -6
- data/lib/rubocop/cop/style/space_around_operators.rb +4 -4
- data/lib/rubocop/cop/style/space_before_block_braces.rb +63 -0
- data/lib/rubocop/cop/style/space_before_modifier_keyword.rb +1 -1
- data/lib/rubocop/cop/style/{space_around_block_braces.rb → space_inside_block_braces.rb} +15 -24
- data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +14 -7
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
- data/lib/rubocop/cop/style/string_literals.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +1 -1
- data/lib/rubocop/cop/style/tab.rb +1 -1
- data/lib/rubocop/cop/style/trailing_blank_lines.rb +2 -2
- data/lib/rubocop/cop/style/trailing_comma.rb +4 -4
- data/lib/rubocop/cop/style/trailing_whitespace.rb +1 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +2 -2
- data/lib/rubocop/cop/style/unless_else.rb +1 -1
- data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/when_then.rb +1 -1
- data/lib/rubocop/cop/style/while_until_do.rb +1 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +2 -1
- data/lib/rubocop/cop/style/word_array.rb +2 -2
- data/lib/rubocop/cop/team.rb +24 -7
- data/lib/rubocop/cop/util.rb +3 -3
- data/lib/rubocop/cop/variable_inspector.rb +25 -13
- data/lib/rubocop/cop/variable_inspector/assignment.rb +1 -1
- data/lib/rubocop/cop/variable_inspector/reference.rb +1 -1
- data/lib/rubocop/cop/variable_inspector/scope.rb +1 -1
- data/lib/rubocop/cop/variable_inspector/variable.rb +2 -2
- data/lib/rubocop/cop/variable_inspector/variable_table.rb +1 -1
- data/lib/rubocop/file_inspector.rb +12 -13
- data/lib/rubocop/formatter/base_formatter.rb +4 -4
- data/lib/rubocop/formatter/clang_style_formatter.rb +2 -2
- data/lib/rubocop/formatter/disabled_config_formatter.rb +12 -12
- data/lib/rubocop/formatter/emacs_style_formatter.rb +3 -2
- data/lib/rubocop/formatter/file_list_formatter.rb +4 -4
- data/lib/rubocop/formatter/formatter_set.rb +2 -1
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +76 -0
- data/lib/rubocop/formatter/json_formatter.rb +17 -16
- data/lib/rubocop/formatter/offense_count_formatter.rb +54 -0
- data/lib/rubocop/formatter/progress_formatter.rb +16 -16
- data/lib/rubocop/formatter/simple_text_formatter.rb +25 -25
- data/lib/rubocop/options.rb +8 -7
- data/lib/rubocop/processed_source.rb +3 -2
- data/lib/rubocop/source_parser.rb +1 -59
- data/lib/rubocop/version.rb +3 -3
- data/relnotes/0.19.0.md +70 -0
- data/rubocop-todo.yml +6 -6
- data/rubocop.gemspec +2 -1
- data/spec/rubocop/cli_spec.rb +431 -268
- data/spec/rubocop/comment_config_spec.rb +103 -0
- data/spec/rubocop/config_loader_spec.rb +4 -4
- data/spec/rubocop/cop/commissioner_spec.rb +7 -7
- data/spec/rubocop/cop/cop_spec.rb +17 -17
- data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +16 -16
- data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +5 -5
- data/spec/rubocop/cop/lint/assignment_in_condition_spec.rb +19 -19
- data/spec/rubocop/cop/lint/block_alignment_spec.rb +52 -52
- data/spec/rubocop/cop/lint/condition_position_spec.rb +7 -7
- data/spec/rubocop/cop/lint/debugger_spec.rb +10 -10
- data/spec/rubocop/cop/lint/deprecated_class_methods_spec.rb +33 -0
- data/spec/rubocop/cop/lint/else_layout_spec.rb +7 -7
- data/spec/rubocop/cop/lint/empty_ensure_spec.rb +4 -4
- data/spec/rubocop/cop/lint/end_alignment_spec.rb +33 -34
- data/spec/rubocop/cop/lint/end_in_method_spec.rb +5 -5
- data/spec/rubocop/cop/lint/ensure_return_spec.rb +4 -4
- data/spec/rubocop/cop/lint/eval_spec.rb +8 -8
- data/spec/rubocop/cop/lint/handle_exceptions_spec.rb +4 -4
- data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +3 -3
- data/spec/rubocop/cop/lint/literal_in_condition_spec.rb +65 -10
- data/spec/rubocop/cop/lint/literal_in_interpolation_spec.rb +21 -0
- data/spec/rubocop/cop/lint/loop_spec.rb +6 -6
- data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +14 -14
- data/spec/rubocop/cop/lint/require_parentheses_spec.rb +15 -15
- data/spec/rubocop/cop/lint/rescue_exception_spec.rb +21 -21
- data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +16 -16
- data/spec/rubocop/cop/lint/string_conversion_in_interpolation_spec.rb +27 -0
- data/spec/rubocop/cop/lint/syntax_spec.rb +11 -11
- data/spec/rubocop/cop/lint/unreachable_code_spec.rb +8 -8
- data/spec/rubocop/cop/lint/useless_assignment_spec.rb +207 -169
- data/spec/rubocop/cop/lint/useless_comparison_spec.rb +5 -5
- data/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb +4 -4
- data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +17 -17
- data/spec/rubocop/cop/lint/void_spec.rb +8 -8
- data/spec/rubocop/cop/{offence_spec.rb → offense_spec.rb} +17 -17
- data/spec/rubocop/cop/rails/action_filter_spec.rb +69 -0
- data/spec/rubocop/cop/rails/default_scope_spec.rb +9 -9
- data/spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb +2 -2
- data/spec/rubocop/cop/rails/output_spec.rb +8 -18
- data/spec/rubocop/cop/rails/read_attribute_spec.rb +2 -2
- data/spec/rubocop/cop/rails/scope_args_spec.rb +25 -0
- data/spec/rubocop/cop/rails/validation_spec.rb +3 -3
- data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +38 -38
- data/spec/rubocop/cop/style/accessor_method_name_spec.rb +14 -14
- data/spec/rubocop/cop/style/alias_spec.rb +11 -11
- data/spec/rubocop/cop/style/align_array_spec.rb +23 -7
- data/spec/rubocop/cop/style/align_hash_spec.rb +111 -30
- data/spec/rubocop/cop/style/align_parameters_spec.rb +260 -187
- data/spec/rubocop/cop/style/and_or_spec.rb +6 -6
- data/spec/rubocop/cop/style/ascii_comments_spec.rb +3 -3
- data/spec/rubocop/cop/style/ascii_identifiers_spec.rb +5 -5
- data/spec/rubocop/cop/style/attr_spec.rb +2 -2
- data/spec/rubocop/cop/style/begin_block_spec.rb +2 -2
- data/spec/rubocop/cop/style/block_comments_spec.rb +3 -3
- data/spec/rubocop/cop/style/block_nesting_spec.rb +26 -26
- data/spec/rubocop/cop/style/blocks_spec.rb +8 -8
- data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +8 -8
- data/spec/rubocop/cop/style/case_equality_spec.rb +2 -2
- data/spec/rubocop/cop/style/case_indentation_spec.rb +21 -21
- data/spec/rubocop/cop/style/character_literal_spec.rb +6 -6
- data/spec/rubocop/cop/style/class_and_module_camel_case_spec.rb +4 -4
- data/spec/rubocop/cop/style/class_and_module_children_spec.rb +129 -0
- data/spec/rubocop/cop/style/class_length_spec.rb +9 -9
- data/spec/rubocop/cop/style/class_methods_spec.rb +8 -8
- data/spec/rubocop/cop/style/class_vars_spec.rb +4 -4
- data/spec/rubocop/cop/style/collection_methods_spec.rb +6 -6
- data/spec/rubocop/cop/style/colon_method_call_spec.rb +16 -16
- data/spec/rubocop/cop/style/comment_annotation_spec.rb +16 -16
- data/spec/rubocop/cop/style/constant_name_spec.rb +12 -12
- data/spec/rubocop/cop/style/cyclomatic_complexity_spec.rb +16 -16
- data/spec/rubocop/cop/style/def_with_parentheses_spec.rb +6 -6
- data/spec/rubocop/cop/style/documentation_spec.rb +14 -14
- data/spec/rubocop/cop/style/dot_position_spec.rb +23 -26
- data/spec/rubocop/cop/style/double_negation_spec.rb +22 -0
- data/spec/rubocop/cop/style/empty_line_between_defs_spec.rb +22 -14
- data/spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb +4 -4
- data/spec/rubocop/cop/style/empty_lines_around_body_spec.rb +20 -20
- data/spec/rubocop/cop/style/empty_lines_spec.rb +17 -6
- data/spec/rubocop/cop/style/empty_literal_spec.rb +20 -20
- data/spec/rubocop/cop/style/encoding_spec.rb +5 -5
- data/spec/rubocop/cop/style/end_block_spec.rb +2 -2
- data/spec/rubocop/cop/style/end_of_line_spec.rb +4 -4
- data/spec/rubocop/cop/style/even_odd_spec.rb +18 -18
- data/spec/rubocop/cop/style/favor_join_spec.rb +7 -7
- data/spec/rubocop/cop/style/favor_unless_over_negated_if_spec.rb +7 -7
- data/spec/rubocop/cop/style/favor_until_over_negated_while_spec.rb +3 -3
- data/spec/rubocop/cop/style/file_name_spec.rb +71 -0
- data/spec/rubocop/cop/style/final_newline_spec.rb +4 -4
- data/spec/rubocop/cop/style/flip_flop_spec.rb +4 -4
- data/spec/rubocop/cop/style/for_spec.rb +13 -13
- data/spec/rubocop/cop/style/format_string_spec.rb +136 -0
- data/spec/rubocop/cop/style/global_vars_spec.rb +7 -7
- data/spec/rubocop/cop/style/hash_methods_spec.rb +6 -6
- data/spec/rubocop/cop/style/hash_syntax_spec.rb +11 -11
- data/spec/rubocop/cop/style/if_unless_modifier_spec.rb +29 -11
- data/spec/rubocop/cop/style/if_with_semicolon_spec.rb +1 -1
- data/spec/rubocop/cop/style/indent_array_spec.rb +136 -0
- data/spec/rubocop/cop/style/indent_hash_spec.rb +238 -0
- data/spec/rubocop/cop/style/indentation_consistency_spec.rb +69 -49
- data/spec/rubocop/cop/style/indentation_width_spec.rb +264 -128
- data/spec/rubocop/cop/style/lambda_call_spec.rb +14 -14
- data/spec/rubocop/cop/style/lambda_spec.rb +7 -7
- data/spec/rubocop/cop/style/leading_comment_space_spec.rb +15 -15
- data/spec/rubocop/cop/style/line_end_concatenation_spec.rb +11 -4
- data/spec/rubocop/cop/style/line_length_spec.rb +5 -5
- data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +5 -5
- data/spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb +9 -9
- data/spec/rubocop/cop/style/method_def_parentheses_spec.rb +19 -19
- data/spec/rubocop/cop/style/method_length_spec.rb +17 -17
- data/spec/rubocop/cop/style/method_name_spec.rb +21 -21
- data/spec/rubocop/cop/style/module_function_spec.rb +3 -3
- data/spec/rubocop/cop/style/multiline_block_chain_spec.rb +13 -13
- data/spec/rubocop/cop/style/multiline_if_then_spec.rb +10 -10
- data/spec/rubocop/cop/style/multiline_ternary_operator_spec.rb +3 -3
- data/spec/rubocop/cop/style/nested_ternary_operator_spec.rb +3 -3
- data/spec/rubocop/cop/style/nil_comparison_spec.rb +7 -7
- data/spec/rubocop/cop/style/not_spec.rb +6 -11
- data/spec/rubocop/cop/style/numeric_literals_spec.rb +8 -8
- data/spec/rubocop/cop/style/one_line_conditional_spec.rb +1 -1
- data/spec/rubocop/cop/style/op_method_spec.rb +13 -13
- data/spec/rubocop/cop/style/parameter_lists_spec.rb +6 -6
- data/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +11 -10
- data/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb +250 -0
- data/spec/rubocop/cop/style/perl_backrefs_spec.rb +2 -2
- data/spec/rubocop/cop/style/predicate_name_spec.rb +3 -3
- data/spec/rubocop/cop/style/proc_spec.rb +4 -4
- data/spec/rubocop/cop/style/raise_args_spec.rb +20 -20
- data/spec/rubocop/cop/style/redundant_begin_spec.rb +6 -6
- data/spec/rubocop/cop/style/redundant_exception_spec.rb +6 -6
- data/spec/rubocop/cop/style/redundant_return_spec.rb +22 -22
- data/spec/rubocop/cop/style/redundant_self_spec.rb +14 -14
- data/spec/rubocop/cop/style/regexp_literal_spec.rb +88 -67
- data/spec/rubocop/cop/style/rescue_modifier_spec.rb +17 -17
- data/spec/rubocop/cop/style/self_assignment_spec.rb +43 -0
- data/spec/rubocop/cop/style/semicolon_spec.rb +31 -17
- data/spec/rubocop/cop/style/signal_exception_spec.rb +29 -29
- data/spec/rubocop/cop/style/single_line_block_params_spec.rb +6 -6
- data/spec/rubocop/cop/style/single_line_methods_spec.rb +44 -6
- data/spec/rubocop/cop/style/space_after_colon_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_after_comma_spec.rb +3 -3
- data/spec/rubocop/cop/style/space_after_control_keyword_spec.rb +12 -12
- data/spec/rubocop/cop/style/space_after_method_name_spec.rb +8 -8
- data/spec/rubocop/cop/style/space_after_not_spec.rb +3 -3
- data/spec/rubocop/cop/style/space_after_semicolon_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_around_equals_in_parameter_default_spec.rb +63 -21
- data/spec/rubocop/cop/style/space_around_operators_spec.rb +24 -24
- data/spec/rubocop/cop/style/space_before_block_braces_spec.rb +72 -0
- data/spec/rubocop/cop/style/space_before_modifier_keyword_spec.rb +4 -4
- data/spec/rubocop/cop/style/{space_around_block_braces_spec.rb → space_inside_block_braces_spec.rb} +39 -41
- data/spec/rubocop/cop/style/space_inside_brackets_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_inside_hash_literal_braces_spec.rb +15 -15
- data/spec/rubocop/cop/style/space_inside_parens_spec.rb +1 -1
- data/spec/rubocop/cop/style/special_global_vars_spec.rb +10 -10
- data/spec/rubocop/cop/style/string_literals_spec.rb +31 -31
- data/spec/rubocop/cop/style/symbol_array_spec.rb +9 -9
- data/spec/rubocop/cop/style/tab_spec.rb +3 -3
- data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +3 -3
- data/spec/rubocop/cop/style/trailing_comma_spec.rb +32 -32
- data/spec/rubocop/cop/style/trailing_whitespace_spec.rb +5 -5
- data/spec/rubocop/cop/style/trivial_accessors_spec.rb +39 -39
- data/spec/rubocop/cop/style/unless_else_spec.rb +1 -1
- data/spec/rubocop/cop/style/variable_interpolation_spec.rb +12 -12
- data/spec/rubocop/cop/style/variable_name_spec.rb +21 -21
- data/spec/rubocop/cop/style/when_then_spec.rb +1 -1
- data/spec/rubocop/cop/style/while_until_do_spec.rb +8 -8
- data/spec/rubocop/cop/style/while_until_modifier_spec.rb +25 -7
- data/spec/rubocop/cop/style/word_array_spec.rb +23 -23
- data/spec/rubocop/cop/team_spec.rb +14 -14
- data/spec/rubocop/file_inspector_spec.rb +14 -12
- data/spec/rubocop/formatter/base_formatter_spec.rb +19 -19
- data/spec/rubocop/formatter/clang_style_formatter_spec.rb +14 -14
- data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +7 -7
- data/spec/rubocop/formatter/emacs_style_formatter_spec.rb +7 -7
- data/spec/rubocop/formatter/file_list_formatter_spec.rb +4 -4
- data/spec/rubocop/formatter/fuubar_style_formatter_spec.rb +129 -0
- data/spec/rubocop/formatter/json_formatter_spec.rb +23 -19
- data/spec/rubocop/formatter/offense_count_formatter_spec.rb +77 -0
- data/spec/rubocop/formatter/progress_formatter_spec.rb +27 -27
- data/spec/rubocop/formatter/simple_text_formatter_spec.rb +16 -16
- data/spec/rubocop/options_spec.rb +7 -8
- data/spec/rubocop/source_parser_spec.rb +0 -54
- data/spec/spec_helper.rb +11 -7
- data/spec/support/file_helper.rb +1 -1
- data/spec/support/mri_syntax_checker.rb +4 -4
- data/spec/support/shared_examples.rb +6 -6
- data/spec/support/statement_modifier_helper.rb +3 -3
- metadata +76 -16
- data/lib/rubocop/cop/style/favor_sprintf.rb +0 -26
- data/lib/rubocop/formatter/offence_count_formatter.rb +0 -49
- data/spec/rubocop/cop/style/favor_sprintf_spec.rb +0 -47
- data/spec/rubocop/formatter/offence_count_formatter_spec.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82c2dad15c79e06c81a7f3bb945c2086d18ac7f6
|
4
|
+
data.tar.gz: ebe3136adc26d0eeddc507e977239efa9ac772b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c52ae88687c5aa6fd5048689592f311c0da53c89b8da0423f4632861bc11ea6b95a1759e0fccb4981a300a615a15aadae1e8bd8849231aeeeab3e91c26b92883
|
7
|
+
data.tar.gz: 9e844e818bf7891135442313b7807417ade15c002334e982c07fa49baaa82e6960e9cfe40056dc76f6552d501a75a8a4391167cac68a34f923cbdd412f6a56ff
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,66 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
### New features
|
6
|
+
|
7
|
+
* New cop `FileName` makes sure that source files have snake_case names. ([@bbatsov][])
|
8
|
+
* New cop `DeprecatedClassMethods` checks for deprecated class methods. ([@bbatsov][])
|
9
|
+
* New cop `StringConversionInInterpolation` checks for redundant `Object#to_s` in string interpolation. ([@bbatsov][])
|
10
|
+
* New cop `LiteralInInterpolation` checks for interpolated string literals. ([@bbatsov][])
|
11
|
+
* New cop `SelfAssignment` checks for places where the self-assignment shorthand should have been used. ([@bbatsov][])
|
12
|
+
* New cop `DoubleNegation` checks for uses of `!!`. ([@bbatsov][])
|
13
|
+
* New cop `PercentLiteralDelimiters` enforces consistent usage of `%`-literal delimiters. ([@hannestyden][])
|
14
|
+
* New Rails cop `ActionFilter` enforces the use of `_filter` or `_action` action filter methods. ([@bbatsov][])
|
15
|
+
* New Rails cop `ScopeArgs` makes sure you invoke the `scope` method properly. ([@bbatsov][])
|
16
|
+
* Add `with_fixed_indentation` style to `AlignParameters` cop. ([@hannestyden][])
|
17
|
+
* Add `IgnoreLastArgumentHash` option to `AlignHash` cop. ([@hannestyden][])
|
18
|
+
* [#743](https://github.com/bbatsov/rubocop/issues/743): `SingleLineMethods` cop does auto-correction. ([@jonas054][])
|
19
|
+
* [#743](https://github.com/bbatsov/rubocop/issues/743): `Semicolon` cop does auto-correction. ([@jonas054][])
|
20
|
+
* [#743](https://github.com/bbatsov/rubocop/issues/743): `EmptyLineBetweenDefs` cop does auto-correction. ([@jonas054][])
|
21
|
+
* [#743](https://github.com/bbatsov/rubocop/issues/743): `IndentationWidth` cop does auto-correction. ([@jonas054][])
|
22
|
+
* [#743](https://github.com/bbatsov/rubocop/issues/743): `IndentationConsistency` cop does auto-correction. ([@jonas054][])
|
23
|
+
* [#809](https://github.com/bbatsov/rubocop/issues/809): New formatter `fuubar` displays a progress bar and shows details of offenses as soon as they are detected. ([@yujinakayama][])
|
24
|
+
* [#797](https://github.com/bbatsov/rubocop/issues/797): New cop `IndentHash` checks the indentation of the first key in multi-line hash literals. ([@jonas054][])
|
25
|
+
* [#797](https://github.com/bbatsov/rubocop/issues/797): New cop `IndentArray` checks the indentation of the first element in multi-line array literals. ([@jonas054][])
|
26
|
+
* [#806](https://github.com/bbatsov/rubocop/issues/806): Now excludes files in `vendor/**` by default. ([@jeremyolliver][])
|
27
|
+
* [#795](https://github.com/bbatsov/rubocop/issues/795): `IfUnlessModifier` and `WhileUntilModifier` supports `MaxLineLength`, which is independent of `LineLength` parameter `Max`. ([@agrimm][])
|
28
|
+
* [#868](https://github.com/bbatsov/rubocop/issues/868): New cop `ClassAndModuleChildren` checks the style of children definitions at classes and modules: nested / compact. ([@geniou][])
|
29
|
+
|
30
|
+
### Changes
|
31
|
+
|
32
|
+
* [#793](https://github.com/bbatsov/rubocop/issues/793): Add printing total count when `rubocop --format offences`. ([@ma2gedev][])
|
33
|
+
* Remove `Ignore` param from the Rails `Output` cop. The standard `Exclude/Include` should be used instead. ([@bbatsov][])
|
34
|
+
* Renamed `FavorSprintf` to `FormatString` and made it configurable. ([@bbatsov][])
|
35
|
+
* Renamed `Offence` to `Offense`. ([@bbatsov][])
|
36
|
+
* Use `offense` in all messages instead of `offence`. ([@bbatsov][])
|
37
|
+
* For indentation of `if`/`unless`/`while`/`until` bodies when the result is assigned to a variable, instead of supporting two styles simultaneously, `IndentationWidth` now supports one style of indentation at a time, specified by `EndAlignment`/`AlignWith`. ([@jonas054][])
|
38
|
+
* Renamed `Style` param of `DotPosition` cop to `EnforcedStyle`. ([@bbatsov][])
|
39
|
+
* Add `length` value to locations of offense in JSON formatter. ([@yujinakayama][])
|
40
|
+
* `SpaceAroundBlockBraces` cop replaced by `SpaceBeforeBlockBraces` and `SpaceInsideBlockBraces`. ([@jonas054][])
|
41
|
+
* `SpaceAroundEqualsInParameterDefault` cop is now configurable with the `EnforcedStyle` option. ([@jonas054][])
|
42
|
+
|
43
|
+
### Bugs fixed
|
44
|
+
|
45
|
+
* [#790](https://github.com/bbatsov/rubocop/issues/790): Fix auto-correction interference problem between `MethodDefParentheses` and other cops. ([@jonas054][])
|
46
|
+
* [#794](https://github.com/bbatsov/rubocop/issues/794): Fix handling of modifier keywords with required parentheses in `ParenthesesAroundCondition`. ([@bbatsov][])
|
47
|
+
* [#804](https://github.com/bbatsov/rubocop/issues/804): Fix a false positive with operator assignments in a loop (including `begin..rescue..end` with `retry`) in `UselessAssignment`. ([@yujinakayama][])
|
48
|
+
* [#815](https://github.com/bbatsov/rubocop/issues/815): Fix a false positive for heredocs with blank lines in them in `EmptyLines`. ([@bbatsov][])
|
49
|
+
* Auto-correction is now more robust and less likely to die because of `RangeError` or "clobbering". ([@jonas054][])
|
50
|
+
* Offenses always reported in order of position in file, also during `--auto-correct` runs. ([@jonas054][])
|
51
|
+
* Fix problem with `[Corrected]` tag sometimes missing in output from `--auto-correct` runs. ([@jonas054][])
|
52
|
+
* Fix message from `EndAlignment` cop when `AlignWith` is `keyword`. ([@jonas054][])
|
53
|
+
* Handle `case` conditions in `LiteralInCondition`. ([@bbatsov][])
|
54
|
+
* [#822](https://github.com/bbatsov/rubocop/issues/822): Fix a false positive in `DotPosition` when enforced style is set to `trailing`. ([@bbatsov][])
|
55
|
+
* Handle properly dynamic strings in `LineEndConcatenation`. ([@bbatsov][])
|
56
|
+
* [#832](https://github.com/bbatsov/rubocop/issues/832): Fix auto-correction interference problem between `BracesAroundHashParameters` and `SpaceInsideHashLiteralBraces`. ([@jonas054][])
|
57
|
+
* Fix bug in auto-correction of alignment so that only space can be removed. ([@jonas054][])
|
58
|
+
* Fix bug in `IndentationWidth` auto-correction so it doesn't correct things that `IndentationConsistency` should correct. ([@jonas054][])
|
59
|
+
* [#847](https://github.com/bbatsov/rubocop/issues/847): Fix bug in `RegexpLiteral` concerning `--auto-gen-config`. ([@jonas054][])
|
60
|
+
* [#848](https://github.com/bbatsov/rubocop/issues/848): Fix bug in `--show-cops` that made it print the default configuration rather than the current configuration. ([@jonas054][])
|
61
|
+
* [#862](https://github.com/bbatsov/rubocop/issues/862): Fix a bug where single line `rubocop:disable` comments with indentations were treated as multiline cop disabling comments. ([@yujinakayama][])
|
62
|
+
* Fix a bug where `rubocop:disable` comments with a cop name including `all` (e.g. `MethodCallParentheses`) were disabling all cops. ([@yujinakayama][])
|
63
|
+
* Fix a bug where string and regexp literals including `# rubocop:disable` were confused with real comments. ([@yujinakayama][])
|
64
|
+
|
5
65
|
## 0.18.1 (02/02/2014)
|
6
66
|
|
7
67
|
### Bugs fixed
|
@@ -9,7 +69,7 @@
|
|
9
69
|
* Remove double reporting in `EmptyLinesAroundBody` of empty line inside otherwise empty class/module/method that caused crash in autocorrect. ([@jonas054][])
|
10
70
|
* [#779](https://github.com/bbatsov/rubocop/issues/779): Fix a false positive in `LineEndConcatenation`. ([@bbatsov][])
|
11
71
|
* [#751](https://github.com/bbatsov/rubocop/issues/751): Fix `Documentation` cop so that a comment followed by an empty line and then a class definition is not considered to be class documentation. ([@jonas054][])
|
12
|
-
* [#783](https://github.com/bbatsov/rubocop/issues/783): Fix a false positive in `
|
72
|
+
* [#783](https://github.com/bbatsov/rubocop/issues/783): Fix a false positive in `ParenthesesAroundCondition` when the parentheses are actually required. ([@bbatsov][])
|
13
73
|
* [#781](https://github.com/bbatsov/rubocop/issues/781): Fix problem with back-and-forth auto-correction in `AccessModifierIndentation`. ([@jonas054][])
|
14
74
|
* [#785](https://github.com/bbatsov/rubocop/issues/785): Fix false positive on `%w` arrays in `TrailingComma`. ([@jonas054][])
|
15
75
|
* [#782](https://github.com/bbatsov/rubocop/issues/782): Fix false positive in `AlignHash` for single line hashes. ([@jonas054][])
|
@@ -691,3 +751,7 @@
|
|
691
751
|
[@claco]: http://github.com/claco
|
692
752
|
[@rifraf]: http://github.com/rifraf
|
693
753
|
[@scottmatthewman]: https://github.com/scottmatthewman
|
754
|
+
[@ma2gedev]: http://github.com/ma2gedev
|
755
|
+
[@jeremyolliver]: https://github.com/jeremyolliver
|
756
|
+
[@hannestyden]: https://github.com/hannestyden
|
757
|
+
[@geniou]: https://github.com/geniou
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/bbatsov/rubocop.png?branch=master)](https://travis-ci.org/bbatsov/rubocop)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/bbatsov/rubocop/badge.png?branch=master)](https://coveralls.io/r/bbatsov/rubocop)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/bbatsov/rubocop.png)](https://codeclimate.com/github/bbatsov/rubocop)
|
6
|
+
[![Inline docs](http://inch-pages.github.io/github/bbatsov/rubocop.png)](http://inch-pages.github.io/github/bbatsov/rubocop)
|
6
7
|
|
7
8
|
# RuboCop
|
8
9
|
|
@@ -21,33 +22,38 @@ automatically fix some of the problems for you.
|
|
21
22
|
|
22
23
|
- [Installation](#installation)
|
23
24
|
- [Basic Usage](#basic-usage)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
- [Cops](#cops)
|
26
|
+
- [Style](#style)
|
27
|
+
- [Lint](#lint)
|
28
|
+
- [Rails](#rails)
|
28
29
|
- [Configuration](#configuration)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
- [Inheritance](#inheritance)
|
31
|
+
- [Defaults](#defaults)
|
32
|
+
- [Including/Excluding files](#includingexcluding-files)
|
33
|
+
- [Automatically Generated Configuration](#automatically-generated-configuration)
|
33
34
|
- [Disabling Cops within Source Code](#disabling-cops-within-source-code)
|
34
35
|
- [Formatters](#formatters)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
- [Progress Formatter (default)](#progress-formatter-default)
|
37
|
+
- [Clang Style Formatter](#clang-style-formatter)
|
38
|
+
- [Fuubar Style Formatter](#fuubar-style-formatter)
|
39
|
+
- [Emacs Style Formatter](#emacs-style-formatter)
|
40
|
+
- [Simple Formatter](#simple-formatter)
|
41
|
+
- [File List Formatter](#file-list-formatter)
|
42
|
+
- [JSON Formatter](#json-formatter)
|
43
|
+
- [Offense Count Formatter](#offense-count-formatter)
|
44
|
+
- [Custom Formatters](#custom-formatters)
|
45
|
+
- [Creating Custom Formatter](#creating-custom-formatter)
|
46
|
+
- [Using Custom Formatter in Command Line](#using-custom-formatter-in-command-line)
|
44
47
|
- [Compatibility](#compatibility)
|
45
48
|
- [Editor integration](#editor-integration)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
- [Emacs](#emacs)
|
50
|
+
- [Vim](#vim)
|
51
|
+
- [Sublime Text](#sublime-text)
|
52
|
+
- [Brackets](#brackets)
|
53
|
+
- [TextMate2](#textmate2)
|
54
|
+
- [Atom](#atom)
|
55
|
+
- [LightTable](#lighttable)
|
56
|
+
- [Other Editors](#other-editors)
|
51
57
|
- [Guard integration](#guard-integration)
|
52
58
|
- [Rake integration](#rake-integration)
|
53
59
|
- [Team](#team)
|
@@ -60,7 +66,7 @@ automatically fix some of the problems for you.
|
|
60
66
|
|
61
67
|
**RuboCop**'s installation is pretty standard:
|
62
68
|
|
63
|
-
```
|
69
|
+
```
|
64
70
|
$ gem install rubocop
|
65
71
|
```
|
66
72
|
|
@@ -69,13 +75,13 @@ $ gem install rubocop
|
|
69
75
|
Running `rubocop` with no arguments will check all Ruby source files
|
70
76
|
in the current directory:
|
71
77
|
|
72
|
-
```
|
78
|
+
```
|
73
79
|
$ rubocop
|
74
80
|
```
|
75
81
|
|
76
82
|
Alternatively you can pass `rubocop` a list of files and directories to check:
|
77
83
|
|
78
|
-
```
|
84
|
+
```
|
79
85
|
$ rubocop app spec lib/something.rb
|
80
86
|
```
|
81
87
|
|
@@ -92,7 +98,7 @@ end
|
|
92
98
|
Running RuboCop on it (assuming it's in a file named `test.rb`) would produce the following report:
|
93
99
|
|
94
100
|
```
|
95
|
-
|
101
|
+
Offenses:
|
96
102
|
|
97
103
|
test.rb:1:5: C: Use snake_case for methods and variables.
|
98
104
|
def badName
|
@@ -104,12 +110,12 @@ test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2
|
|
104
110
|
end
|
105
111
|
^^^
|
106
112
|
|
107
|
-
1 file inspected, 3
|
113
|
+
1 file inspected, 3 offenses detected
|
108
114
|
```
|
109
115
|
|
110
116
|
For more details check the available command-line options:
|
111
117
|
|
112
|
-
```
|
118
|
+
```
|
113
119
|
$ rubocop -h
|
114
120
|
```
|
115
121
|
|
@@ -118,14 +124,14 @@ Command flag | Description
|
|
118
124
|
`-v/--version` | Displays the current version and exits
|
119
125
|
`-V/--verbose-version` | Displays the current version plus the version of Parser and Ruby
|
120
126
|
`-d/--debug` | Displays some extra debug output
|
121
|
-
`-D/--display-cop-names` | Displays cop names in
|
127
|
+
`-D/--display-cop-names` | Displays cop names in offense messages.
|
122
128
|
`-c/--config` | Run with specified config file
|
123
129
|
`-f/--format` | Choose a formatter
|
124
130
|
`-o/--out` | Write output to a file instead of STDOUT
|
125
131
|
`-r/--require` | Require Ruby file
|
126
132
|
`-R/--rails` | Run extra Rails cops
|
127
133
|
`-l/--lint` | Run only lint cops
|
128
|
-
`-a/--auto-correct` | Auto-correct certain
|
134
|
+
`-a/--auto-correct` | Auto-correct certain offenses *Note:* Experimental - use with caution
|
129
135
|
`--only` | Run only the specified cop
|
130
136
|
`--auto-gen-config` | Generate a configuration file acting as a TODO list
|
131
137
|
`--show-cops` | Shows available cops and their configuration
|
@@ -289,12 +295,12 @@ CyclomaticComplexity:
|
|
289
295
|
|
290
296
|
### Automatically Generated Configuration
|
291
297
|
|
292
|
-
If you have a code base with an overwhelming amount of
|
298
|
+
If you have a code base with an overwhelming amount of offenses, it can be a
|
293
299
|
good idea to use `rubocop --auto-gen-config` and add an `inherit_from:
|
294
300
|
rubocop-todo.yml` in your `.rubocop.yml`. The generated file `rubocop-todo.yml`
|
295
|
-
contains configuration to disable all cops that currently detect an
|
301
|
+
contains configuration to disable all cops that currently detect an offense in
|
296
302
|
the code. Then you can start removing the entries in the generated file one by
|
297
|
-
one as you work through all the
|
303
|
+
one as you work through all the offenses in the code.
|
298
304
|
|
299
305
|
## Disabling Cops within Source Code
|
300
306
|
|
@@ -324,72 +330,147 @@ for x in (0..19) # rubocop:disable AvoidFor
|
|
324
330
|
|
325
331
|
## Formatters
|
326
332
|
|
327
|
-
|
333
|
+
You can change the output format of RuboCop by specifying formatters with the `-f/--format` option.
|
334
|
+
RuboCop ships with several built-in formatters, and also you can create your custom formatter.
|
335
|
+
|
336
|
+
Additionaly the output can be redirected to a file instead of `$stdout` with the `-o/--out` option.
|
337
|
+
|
338
|
+
Some of the built-in formatters produce **machine-parsable** output
|
339
|
+
and they are considered public APIs.
|
340
|
+
The rest of the formatters are for humans, so parsing their outputs is discouraged.
|
341
|
+
|
342
|
+
You can enable multiple formatters at the same time by specifying `-f/--format` multiple times.
|
343
|
+
The `-o/--out` option applies to the previously specified `-f/--format`,
|
344
|
+
or the default `progress` format if no `-f/--format` is specified before the `-o/--out` option.
|
345
|
+
|
346
|
+
```bash
|
347
|
+
# Simple format to $stdout.
|
348
|
+
$ rubocop --format simple
|
349
|
+
|
350
|
+
# Progress (default) format to the file result.txt.
|
351
|
+
$ rubocop --out result.txt
|
352
|
+
|
353
|
+
# Both progress and offense count formats to $stdout.
|
354
|
+
# The offense count formatter outputs only the final summary,
|
355
|
+
# so you'll mostly see the outputs from the progress formatter,
|
356
|
+
# and at the end the offense count summary will be outputted.
|
357
|
+
$ rubocop --format progress --format offenses
|
358
|
+
|
359
|
+
# Progress format to $stdout, and JSON format to the file rubocop.json.
|
360
|
+
$ rubocop --format progress --format json --out rubocop.json
|
361
|
+
# ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
|
362
|
+
# | |_______________|
|
363
|
+
# $stdout
|
364
|
+
|
365
|
+
# Progress format to result.txt, and simple format to $stdout.
|
366
|
+
$ rubocop --output result.txt --format simple
|
367
|
+
# ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
|
368
|
+
# | |
|
369
|
+
# default format $stdout
|
370
|
+
```
|
371
|
+
|
372
|
+
### Progress Formatter (default)
|
373
|
+
|
374
|
+
The default `progress` formatter outputs a character for each inspected file,
|
375
|
+
and at the end it displays all detected offenses in the `clang` format.
|
376
|
+
A `.` represents a clean file, and each of the capital letters means
|
377
|
+
the severest offense (convention, warning, error or fatal) found in a file.
|
378
|
+
|
379
|
+
```
|
380
|
+
$ rubocop
|
381
|
+
Inspecting 26 files
|
382
|
+
..W.C....C..CWCW.C...WC.CC
|
383
|
+
|
384
|
+
Offenses:
|
385
|
+
|
386
|
+
lib/foo.rb:6:5: C: Missing top-level class documentation comment.
|
387
|
+
class Foo
|
388
|
+
^^^^^
|
328
389
|
|
329
|
-
|
390
|
+
...
|
330
391
|
|
392
|
+
26 files inspected, 46 offenses detected
|
331
393
|
```
|
332
|
-
rubocop test.rb
|
333
394
|
|
334
|
-
|
335
|
-
W
|
395
|
+
### Clang Style Formatter
|
336
396
|
|
337
|
-
|
397
|
+
The `clang` formatter displays the offenses in a manner similar to `clang`:
|
338
398
|
|
399
|
+
```
|
400
|
+
$ rubocop test.rb
|
339
401
|
test.rb:1:1: C: Use snake_case for methods and variables.
|
340
402
|
def badName
|
341
|
-
|
403
|
+
^^^^^^^
|
342
404
|
test.rb:2:3: C: Favor modifier if/unless usage when you have a single-line body. Another good alternative is the usage of control flow &&/||.
|
343
405
|
if something
|
344
|
-
|
406
|
+
^^
|
345
407
|
test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2
|
346
408
|
end
|
347
409
|
^^^
|
348
410
|
|
349
|
-
1 file inspected, 3
|
411
|
+
1 file inspected, 3 offenses detected
|
350
412
|
```
|
351
413
|
|
352
|
-
###
|
414
|
+
### Fuubar Style Formatter
|
353
415
|
|
354
|
-
The `
|
416
|
+
The `fuubar` style formatter displays a progress bar
|
417
|
+
and shows details of offenses in the `clang` format as soon as they are detected.
|
418
|
+
This is inspired by the [Fuubar](https://github.com/jeffkreeftmeijer/fuubar) formatter for RSpec.
|
355
419
|
|
356
420
|
```
|
357
|
-
rubocop --format
|
421
|
+
$ rubocop --format fuubar
|
422
|
+
lib/foo.rb.rb:1:1: C: Use snake_case for methods and variables.
|
423
|
+
def badName
|
424
|
+
^^^^^^^
|
425
|
+
lib/bar.rb:13:14: W: File.exists? is deprecated in favor of File.exist?.
|
426
|
+
File.exists?(path)
|
427
|
+
^^^^^^^
|
428
|
+
22/53 files |======== 43 ========> | ETA: 00:00:02
|
429
|
+
```
|
430
|
+
|
431
|
+
### Emacs Style Formatter
|
432
|
+
|
433
|
+
**Machine-parsable**
|
358
434
|
|
435
|
+
The `emacs` formatter displays the offenses in a format suitable for consumption by `Emacs` (and possibly other tools).
|
436
|
+
|
437
|
+
```
|
438
|
+
$ rubocop --format emacs test.rb
|
359
439
|
/Users/bozhidar/projects/test.rb:1:1: C: Use snake_case for methods and variables.
|
360
440
|
/Users/bozhidar/projects/test.rb:2:3: C: Favor modifier if/unless usage when you have a single-line body. Another good alternative is the usage of control flow &&/||.
|
361
441
|
/Users/bozhidar/projects/test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2
|
362
|
-
|
363
|
-
1 file inspected, 3 offences detected
|
364
442
|
```
|
365
443
|
|
366
|
-
### Simple
|
444
|
+
### Simple Formatter
|
367
445
|
|
368
446
|
The name of the formatter says it all :-)
|
369
447
|
|
370
448
|
```
|
371
|
-
rubocop --format simple test.rb
|
372
|
-
|
449
|
+
$ rubocop --format simple test.rb
|
373
450
|
== test.rb ==
|
374
451
|
C: 1: 1: Use snake_case for methods and variables.
|
375
452
|
C: 2: 3: Favor modifier if/unless usage when you have a single-line body. Another good alternative is the usage of control flow &&/||.
|
376
453
|
W: 4: 5: end at 4, 4 is not aligned with if at 2, 2
|
377
454
|
|
378
|
-
1 file inspected, 3
|
455
|
+
1 file inspected, 3 offenses detected
|
379
456
|
```
|
380
457
|
|
381
458
|
### File List Formatter
|
382
459
|
|
383
|
-
|
460
|
+
**Machine-parsable**
|
461
|
+
|
462
|
+
Sometimes you might want to just open all files with offenses in your
|
384
463
|
favorite editor. This formatter outputs just the names of the files
|
385
|
-
with
|
464
|
+
with offenses in them and makes it possible to do something like:
|
386
465
|
|
387
466
|
```
|
388
|
-
rubocop --format files | xargs vim
|
467
|
+
$ rubocop --format files | xargs vim
|
389
468
|
```
|
390
469
|
|
391
470
|
### JSON Formatter
|
392
471
|
|
472
|
+
**Machine-parsable**
|
473
|
+
|
393
474
|
You can get RuboCop's inspection result in JSON format by passing `--format json` option in command line.
|
394
475
|
The JSON structure is like the following example:
|
395
476
|
|
@@ -404,17 +485,18 @@ The JSON structure is like the following example:
|
|
404
485
|
},
|
405
486
|
"files": [{
|
406
487
|
"path": "lib/foo.rb",
|
407
|
-
"
|
488
|
+
"offenses": []
|
408
489
|
}, {
|
409
490
|
"path": "lib/bar.rb",
|
410
|
-
"
|
491
|
+
"offenses": [{
|
411
492
|
"severity": "convention",
|
412
493
|
"message": "Line is too long. [81/79]",
|
413
494
|
"cop_name": "LineLength",
|
414
495
|
"corrected": true,
|
415
496
|
"location": {
|
416
497
|
"line": 546,
|
417
|
-
"column": 80
|
498
|
+
"column": 80,
|
499
|
+
"length": 4
|
418
500
|
}
|
419
501
|
}, {
|
420
502
|
"severity": "warning",
|
@@ -423,42 +505,45 @@ The JSON structure is like the following example:
|
|
423
505
|
"corrected": false,
|
424
506
|
"location": {
|
425
507
|
"line": 15,
|
426
|
-
"column": 9
|
508
|
+
"column": 9,
|
509
|
+
"length": 10
|
427
510
|
}
|
428
511
|
}
|
429
512
|
]
|
430
513
|
}
|
431
514
|
],
|
432
515
|
"summary": {
|
433
|
-
"
|
516
|
+
"offense_count": 2,
|
434
517
|
"target_file_count": 2,
|
435
518
|
"inspected_file_count": 2
|
436
519
|
}
|
437
520
|
}
|
438
521
|
```
|
439
522
|
|
440
|
-
###
|
523
|
+
### Offense Count Formatter
|
441
524
|
|
442
525
|
Sometimes when first applying RuboCop to a codebase, it's nice to be able to
|
443
526
|
see where most of your style cleanup is going to be spent.
|
444
527
|
|
445
|
-
With this in mind, you can use the
|
446
|
-
cops and the number of
|
528
|
+
With this in mind, you can use the offense count formatter to outline the offended
|
529
|
+
cops and the number of offenses found for each by running:
|
447
530
|
|
448
531
|
```
|
449
|
-
rubocop --format
|
532
|
+
$ rubocop --format offenses
|
450
533
|
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
534
|
+
87 Documentation
|
535
|
+
12 DotPosition
|
536
|
+
8 AvoidGlobalVars
|
537
|
+
7 EmptyLines
|
538
|
+
6 AssignmentInCondition
|
539
|
+
4 Blocks
|
540
|
+
4 CommentAnnotation
|
541
|
+
3 BlockAlignment
|
542
|
+
1 IndentationWidth
|
543
|
+
1 AvoidPerlBackrefs
|
544
|
+
1 ColonMethodCall
|
545
|
+
--
|
546
|
+
134 Total
|
462
547
|
```
|
463
548
|
|
464
549
|
### Custom Formatters
|
@@ -474,7 +559,7 @@ or implement all formatter API methods by duck typing.
|
|
474
559
|
Please see the documents below for more formatter API details.
|
475
560
|
|
476
561
|
* [Rubocop::Formatter::BaseFormatter](http://rubydoc.info/gems/rubocop/Rubocop/Formatter/BaseFormatter)
|
477
|
-
* [Rubocop::Cop::
|
562
|
+
* [Rubocop::Cop::Offense](http://rubydoc.info/gems/rubocop/Rubocop/Cop/Offense)
|
478
563
|
* [Parser::Source::Range](http://rubydoc.info/github/whitequark/parser/Parser/Source/Range)
|
479
564
|
|
480
565
|
#### Using Custom Formatter in Command Line
|
@@ -484,7 +569,7 @@ You can tell RuboCop to use your custom formatter with a combination of
|
|
484
569
|
For example, when you have defined `MyCustomFormatter` in
|
485
570
|
`./path/to/my_custom_formatter.rb`, you would type this command:
|
486
571
|
|
487
|
-
```
|
572
|
+
```
|
488
573
|
$ rubocop --require ./path/to/my_custom_formatter --format MyCustomFormatter
|
489
574
|
```
|
490
575
|
|
@@ -530,10 +615,27 @@ If you're a ST user you might find the
|
|
530
615
|
useful.
|
531
616
|
|
532
617
|
### Brackets
|
618
|
+
|
533
619
|
The [brackets-rubocop](https://github.com/smockle/brackets-rubocop)
|
534
620
|
extension displays RuboCop results in Brackets.
|
535
621
|
It can be installed via the extension manager in Brackets.
|
536
622
|
|
623
|
+
### TextMate2
|
624
|
+
|
625
|
+
The [textmate2-rubocop](https://github.com/mrdougal/textmate2-rubocop)
|
626
|
+
bundle displays formatted RuboCop results in a new window.
|
627
|
+
Installation instructions can be found [here](https://github.com/mrdougal/textmate2-rubocop#installation).
|
628
|
+
|
629
|
+
### Atom
|
630
|
+
|
631
|
+
The [atom-lint](https://github.com/yujinakayama/atom-lint) package
|
632
|
+
runs RuboCop and highlights the offenses in Atom.
|
633
|
+
|
634
|
+
### LightTable
|
635
|
+
|
636
|
+
The [lt-rubocop](https://github.com/seancaffery/lt-rubocop) plugin
|
637
|
+
provides LightTable integration.
|
638
|
+
|
537
639
|
### Other Editors
|
538
640
|
|
539
641
|
Here's one great opportunity to contribute to RuboCop - implement
|
@@ -611,5 +713,5 @@ RuboCop's changelog is available [here](CHANGELOG.md).
|
|
611
713
|
|
612
714
|
## Copyright
|
613
715
|
|
614
|
-
Copyright (c) 2012-
|
716
|
+
Copyright (c) 2012-2014 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
|
615
717
|
further details.
|