rubocop 0.29.1 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +73 -1
- data/README.md +11 -2
- data/config/default.yml +194 -6
- data/config/disabled.yml +25 -1
- data/config/enabled.yml +74 -12
- data/lib/rubocop.rb +19 -2
- data/lib/rubocop/config.rb +23 -3
- data/lib/rubocop/config_loader.rb +9 -1
- data/lib/rubocop/cop/autocorrect_logic.rb +26 -0
- data/lib/rubocop/cop/cop.rb +33 -17
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +16 -4
- data/lib/rubocop/cop/lint/block_alignment.rb +5 -14
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +61 -0
- data/lib/rubocop/cop/lint/void.rb +11 -3
- data/lib/rubocop/cop/mixin/on_normal_if_unless.rb +17 -0
- data/lib/rubocop/cop/performance/detect.rb +72 -0
- data/lib/rubocop/cop/performance/flat_map.rb +64 -0
- data/lib/rubocop/cop/performance/reverse_each.rb +43 -0
- data/lib/rubocop/cop/performance/sample.rb +58 -0
- data/lib/rubocop/cop/performance/size.rb +64 -0
- data/lib/rubocop/cop/rails/date.rb +121 -0
- data/lib/rubocop/cop/rails/find_by.rb +52 -0
- data/lib/rubocop/cop/rails/find_each.rb +41 -0
- data/lib/rubocop/cop/rails/time_zone.rb +93 -0
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +45 -0
- data/lib/rubocop/cop/style/block_delimiters.rb +186 -0
- data/lib/rubocop/cop/style/closing_parenthesis_indentation.rb +76 -0
- data/lib/rubocop/cop/style/command_literal.rb +120 -0
- data/lib/rubocop/cop/style/copyright.rb +87 -0
- data/lib/rubocop/cop/style/documentation.rb +32 -0
- data/lib/rubocop/cop/style/empty_else.rb +85 -16
- data/lib/rubocop/cop/style/encoding.rb +14 -2
- data/lib/rubocop/cop/style/end_of_line.rb +5 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +86 -23
- data/lib/rubocop/cop/style/if_unless_modifier.rb +15 -0
- data/lib/rubocop/cop/style/indentation_consistency.rb +13 -6
- data/lib/rubocop/cop/style/indentation_width.rb +34 -10
- data/lib/rubocop/cop/style/lambda.rb +32 -17
- data/lib/rubocop/cop/style/line_end_concatenation.rb +4 -0
- data/lib/rubocop/cop/style/missing_else.rb +72 -0
- data/lib/rubocop/cop/style/regexp_literal.rb +89 -58
- data/lib/rubocop/cop/style/space_around_operators.rb +13 -2
- data/lib/rubocop/cop/style/space_before_block_braces.rb +3 -3
- data/lib/rubocop/cop/style/space_inside_block_braces.rb +9 -5
- data/lib/rubocop/cop/style/symbol_literal.rb +36 -0
- data/lib/rubocop/cop/style/trailing_blank_lines.rb +7 -0
- data/lib/rubocop/cop/style/trailing_comma.rb +21 -7
- data/lib/rubocop/cop/style/trivial_accessors.rb +17 -3
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +4 -6
- data/lib/rubocop/cop/style/while_until_modifier.rb +10 -0
- data/lib/rubocop/cop/util.rb +24 -19
- data/lib/rubocop/cop/variable_force.rb +14 -0
- data/lib/rubocop/cop/variable_force/reference.rb +10 -4
- data/lib/rubocop/formatter/html_formatter.rb +10 -4
- data/lib/rubocop/formatter/text_util.rb +5 -7
- data/lib/rubocop/options.rb +47 -45
- data/lib/rubocop/path_util.rb +12 -8
- data/lib/rubocop/processed_source.rb +12 -1
- data/lib/rubocop/rake_task.rb +2 -2
- data/lib/rubocop/version.rb +1 -1
- data/relnotes/v0.30.0.md +145 -0
- data/rubocop.gemspec +15 -3
- metadata +22 -545
- data/.gitignore +0 -54
- data/.rspec +0 -1
- data/.rubocop.yml +0 -11
- data/.rubocop_todo.yml +0 -28
- data/.travis.yml +0 -22
- data/Gemfile +0 -15
- data/Rakefile +0 -41
- data/lib/rubocop/cop/style/blocks.rb +0 -80
- data/lib/rubocop/cop/style/unneeded_percent_x.rb +0 -25
- data/logo/rubocop-final-logo.eps +0 -0
- data/spec/.rubocop.yml +0 -5
- data/spec/fixtures/html_formatter/expected.html +0 -495
- data/spec/fixtures/html_formatter/project/app/controllers/application_controller.rb +0 -5
- data/spec/fixtures/html_formatter/project/app/controllers/books_controller.rb +0 -74
- data/spec/fixtures/html_formatter/project/app/models/book.rb +0 -5
- data/spec/isolated_environment_spec.rb +0 -24
- data/spec/project_spec.rb +0 -119
- data/spec/rubocop/cli_spec.rb +0 -2740
- data/spec/rubocop/comment_config_spec.rb +0 -105
- data/spec/rubocop/config_loader_spec.rb +0 -377
- data/spec/rubocop/config_spec.rb +0 -235
- data/spec/rubocop/config_store_spec.rb +0 -53
- data/spec/rubocop/cop/commissioner_spec.rb +0 -85
- data/spec/rubocop/cop/cop_spec.rb +0 -135
- data/spec/rubocop/cop/corrector_spec.rb +0 -59
- data/spec/rubocop/cop/force_spec.rb +0 -29
- data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +0 -113
- data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +0 -35
- data/spec/rubocop/cop/lint/assignment_in_condition_spec.rb +0 -130
- data/spec/rubocop/cop/lint/block_alignment_spec.rb +0 -533
- data/spec/rubocop/cop/lint/condition_position_spec.rb +0 -51
- data/spec/rubocop/cop/lint/debugger_spec.rb +0 -73
- data/spec/rubocop/cop/lint/def_end_alignment_spec.rb +0 -108
- data/spec/rubocop/cop/lint/deprecated_class_methods_spec.rb +0 -38
- data/spec/rubocop/cop/lint/duplicate_methods_spec.rb +0 -189
- data/spec/rubocop/cop/lint/else_layout_spec.rb +0 -65
- data/spec/rubocop/cop/lint/empty_ensure_spec.rb +0 -27
- data/spec/rubocop/cop/lint/empty_interpolation_spec.rb +0 -18
- data/spec/rubocop/cop/lint/end_alignment_spec.rb +0 -91
- data/spec/rubocop/cop/lint/end_in_method_spec.rb +0 -29
- data/spec/rubocop/cop/lint/ensure_return_spec.rb +0 -39
- data/spec/rubocop/cop/lint/eval_spec.rb +0 -33
- data/spec/rubocop/cop/lint/handle_exceptions_spec.rb +0 -30
- data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +0 -33
- data/spec/rubocop/cop/lint/literal_in_condition_spec.rb +0 -172
- data/spec/rubocop/cop/lint/literal_in_interpolation_spec.rb +0 -31
- data/spec/rubocop/cop/lint/loop_spec.rb +0 -27
- data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +0 -57
- data/spec/rubocop/cop/lint/require_parentheses_spec.rb +0 -82
- data/spec/rubocop/cop/lint/rescue_exception_spec.rb +0 -123
- data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +0 -237
- data/spec/rubocop/cop/lint/space_before_first_arg_spec.rb +0 -66
- data/spec/rubocop/cop/lint/string_conversion_in_interpolation_spec.rb +0 -51
- data/spec/rubocop/cop/lint/syntax_spec.rb +0 -34
- data/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb +0 -179
- data/spec/rubocop/cop/lint/unreachable_code_spec.rb +0 -63
- data/spec/rubocop/cop/lint/unused_block_argument_spec.rb +0 -231
- data/spec/rubocop/cop/lint/unused_method_argument_spec.rb +0 -278
- data/spec/rubocop/cop/lint/useless_access_modifier_spec.rb +0 -192
- data/spec/rubocop/cop/lint/useless_assignment_spec.rb +0 -1778
- data/spec/rubocop/cop/lint/useless_comparison_spec.rb +0 -30
- data/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb +0 -48
- data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +0 -211
- data/spec/rubocop/cop/lint/void_spec.rb +0 -64
- data/spec/rubocop/cop/metrics/abc_size_spec.rb +0 -109
- data/spec/rubocop/cop/metrics/block_nesting_spec.rb +0 -156
- data/spec/rubocop/cop/metrics/class_length_spec.rb +0 -131
- data/spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb +0 -204
- data/spec/rubocop/cop/metrics/line_length_spec.rb +0 -136
- data/spec/rubocop/cop/metrics/method_length_spec.rb +0 -147
- data/spec/rubocop/cop/metrics/parameter_lists_spec.rb +0 -44
- data/spec/rubocop/cop/metrics/perceived_complexity_spec.rb +0 -222
- data/spec/rubocop/cop/offense_spec.rb +0 -133
- data/spec/rubocop/cop/rails/action_filter_spec.rb +0 -64
- data/spec/rubocop/cop/rails/default_scope_spec.rb +0 -37
- data/spec/rubocop/cop/rails/delegate_spec.rb +0 -177
- data/spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb +0 -13
- data/spec/rubocop/cop/rails/output_spec.rb +0 -37
- data/spec/rubocop/cop/rails/read_write_attribute_spec.rb +0 -130
- data/spec/rubocop/cop/rails/scope_args_spec.rb +0 -25
- data/spec/rubocop/cop/rails/validation_spec.rb +0 -28
- data/spec/rubocop/cop/severity_spec.rb +0 -113
- data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +0 -421
- data/spec/rubocop/cop/style/accessor_method_name_spec.rb +0 -81
- data/spec/rubocop/cop/style/alias_spec.rb +0 -59
- data/spec/rubocop/cop/style/align_array_spec.rb +0 -123
- data/spec/rubocop/cop/style/align_hash_spec.rb +0 -411
- data/spec/rubocop/cop/style/align_parameters_spec.rb +0 -431
- data/spec/rubocop/cop/style/and_or_spec.rb +0 -235
- data/spec/rubocop/cop/style/array_join_spec.rb +0 -29
- data/spec/rubocop/cop/style/ascii_comments_spec.rb +0 -21
- data/spec/rubocop/cop/style/ascii_identifiers_spec.rb +0 -36
- data/spec/rubocop/cop/style/attr_spec.rb +0 -29
- data/spec/rubocop/cop/style/bare_percent_literals_spec.rb +0 -132
- data/spec/rubocop/cop/style/begin_block_spec.rb +0 -13
- data/spec/rubocop/cop/style/block_comments_spec.rb +0 -45
- data/spec/rubocop/cop/style/block_end_newline_spec.rb +0 -61
- data/spec/rubocop/cop/style/blocks_spec.rb +0 -121
- data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +0 -288
- data/spec/rubocop/cop/style/case_equality_spec.rb +0 -13
- data/spec/rubocop/cop/style/case_indentation_spec.rb +0 -293
- data/spec/rubocop/cop/style/character_literal_spec.rb +0 -37
- data/spec/rubocop/cop/style/class_and_module_camel_case_spec.rb +0 -40
- data/spec/rubocop/cop/style/class_and_module_children_spec.rb +0 -133
- data/spec/rubocop/cop/style/class_check_spec.rb +0 -41
- data/spec/rubocop/cop/style/class_methods_spec.rb +0 -80
- data/spec/rubocop/cop/style/class_vars_spec.rb +0 -19
- data/spec/rubocop/cop/style/collection_methods_spec.rb +0 -48
- data/spec/rubocop/cop/style/colon_method_call_spec.rb +0 -65
- data/spec/rubocop/cop/style/comment_annotation_spec.rb +0 -86
- data/spec/rubocop/cop/style/comment_indentation_spec.rb +0 -179
- data/spec/rubocop/cop/style/constant_name_spec.rb +0 -65
- data/spec/rubocop/cop/style/def_with_parentheses_spec.rb +0 -43
- data/spec/rubocop/cop/style/deprecated_hash_methods_spec.rb +0 -45
- data/spec/rubocop/cop/style/documentation_spec.rb +0 -146
- data/spec/rubocop/cop/style/dot_position_spec.rb +0 -132
- data/spec/rubocop/cop/style/double_negation_spec.rb +0 -22
- data/spec/rubocop/cop/style/each_with_object_spec.rb +0 -73
- data/spec/rubocop/cop/style/else_alignment_spec.rb +0 -506
- data/spec/rubocop/cop/style/empty_else_spec.rb +0 -100
- data/spec/rubocop/cop/style/empty_line_between_defs_spec.rb +0 -135
- data/spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb +0 -178
- data/spec/rubocop/cop/style/empty_lines_around_block_body_spec.rb +0 -103
- data/spec/rubocop/cop/style/empty_lines_around_class_body_spec.rb +0 -135
- data/spec/rubocop/cop/style/empty_lines_around_method_body_spec.rb +0 -90
- data/spec/rubocop/cop/style/empty_lines_around_module_body_spec.rb +0 -79
- data/spec/rubocop/cop/style/empty_lines_spec.rb +0 -51
- data/spec/rubocop/cop/style/empty_literal_spec.rb +0 -117
- data/spec/rubocop/cop/style/encoding_spec.rb +0 -139
- data/spec/rubocop/cop/style/end_block_spec.rb +0 -13
- data/spec/rubocop/cop/style/end_of_line_spec.rb +0 -65
- data/spec/rubocop/cop/style/even_odd_spec.rb +0 -164
- data/spec/rubocop/cop/style/extra_spacing_spec.rb +0 -68
- data/spec/rubocop/cop/style/file_name_spec.rb +0 -84
- data/spec/rubocop/cop/style/first_parameter_indentation_spec.rb +0 -304
- data/spec/rubocop/cop/style/flip_flop_spec.rb +0 -23
- data/spec/rubocop/cop/style/for_spec.rb +0 -105
- data/spec/rubocop/cop/style/format_string_spec.rb +0 -184
- data/spec/rubocop/cop/style/global_vars_spec.rb +0 -34
- data/spec/rubocop/cop/style/guard_clause_spec.rb +0 -172
- data/spec/rubocop/cop/style/hash_syntax_spec.rb +0 -137
- data/spec/rubocop/cop/style/if_unless_modifier_spec.rb +0 -146
- data/spec/rubocop/cop/style/if_with_semicolon_spec.rb +0 -24
- data/spec/rubocop/cop/style/indent_array_spec.rb +0 -173
- data/spec/rubocop/cop/style/indent_hash_spec.rb +0 -367
- data/spec/rubocop/cop/style/indentation_consistency_spec.rb +0 -509
- data/spec/rubocop/cop/style/indentation_width_spec.rb +0 -885
- data/spec/rubocop/cop/style/infinite_loop_spec.rb +0 -48
- data/spec/rubocop/cop/style/inline_comment_spec.rb +0 -13
- data/spec/rubocop/cop/style/lambda_call_spec.rb +0 -65
- data/spec/rubocop/cop/style/lambda_spec.rb +0 -76
- data/spec/rubocop/cop/style/leading_comment_space_spec.rb +0 -64
- data/spec/rubocop/cop/style/line_end_concatenation_spec.rb +0 -184
- data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +0 -59
- data/spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb +0 -60
- data/spec/rubocop/cop/style/method_def_parentheses_spec.rb +0 -108
- data/spec/rubocop/cop/style/method_name_spec.rb +0 -125
- data/spec/rubocop/cop/style/module_function_spec.rb +0 -24
- data/spec/rubocop/cop/style/multiline_block_chain_spec.rb +0 -78
- data/spec/rubocop/cop/style/multiline_block_layout_spec.rb +0 -199
- data/spec/rubocop/cop/style/multiline_if_then_spec.rb +0 -134
- data/spec/rubocop/cop/style/multiline_operation_indentation_spec.rb +0 -464
- data/spec/rubocop/cop/style/multiline_ternary_operator_spec.rb +0 -18
- data/spec/rubocop/cop/style/negated_if_spec.rb +0 -102
- data/spec/rubocop/cop/style/negated_while_spec.rb +0 -64
- data/spec/rubocop/cop/style/nested_ternary_operator_spec.rb +0 -21
- data/spec/rubocop/cop/style/next_spec.rb +0 -301
- data/spec/rubocop/cop/style/nil_comparison_spec.rb +0 -29
- data/spec/rubocop/cop/style/non_nil_check_spec.rb +0 -132
- data/spec/rubocop/cop/style/not_spec.rb +0 -28
- data/spec/rubocop/cop/style/numeric_literals_spec.rb +0 -80
- data/spec/rubocop/cop/style/one_line_conditional_spec.rb +0 -13
- data/spec/rubocop/cop/style/op_method_spec.rb +0 -85
- data/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +0 -161
- data/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb +0 -316
- data/spec/rubocop/cop/style/percent_q_literals_spec.rb +0 -122
- data/spec/rubocop/cop/style/perl_backrefs_spec.rb +0 -22
- data/spec/rubocop/cop/style/predicate_name_spec.rb +0 -57
- data/spec/rubocop/cop/style/proc_spec.rb +0 -27
- data/spec/rubocop/cop/style/raise_args_spec.rb +0 -87
- data/spec/rubocop/cop/style/redundant_begin_spec.rb +0 -121
- data/spec/rubocop/cop/style/redundant_exception_spec.rb +0 -59
- data/spec/rubocop/cop/style/redundant_return_spec.rb +0 -171
- data/spec/rubocop/cop/style/redundant_self_spec.rb +0 -186
- data/spec/rubocop/cop/style/regexp_literal_spec.rb +0 -188
- data/spec/rubocop/cop/style/rescue_modifier_spec.rb +0 -116
- data/spec/rubocop/cop/style/self_assignment_spec.rb +0 -49
- data/spec/rubocop/cop/style/semicolon_spec.rb +0 -114
- data/spec/rubocop/cop/style/signal_exception_spec.rb +0 -289
- data/spec/rubocop/cop/style/single_line_block_params_spec.rb +0 -82
- data/spec/rubocop/cop/style/single_line_methods_spec.rb +0 -94
- data/spec/rubocop/cop/style/single_space_before_first_arg_spec.rb +0 -63
- data/spec/rubocop/cop/style/space_after_colon_spec.rb +0 -55
- data/spec/rubocop/cop/style/space_after_comma_spec.rb +0 -30
- data/spec/rubocop/cop/style/space_after_control_keyword_spec.rb +0 -84
- data/spec/rubocop/cop/style/space_after_method_name_spec.rb +0 -70
- data/spec/rubocop/cop/style/space_after_not_spec.rb +0 -22
- data/spec/rubocop/cop/style/space_after_semicolon_spec.rb +0 -23
- data/spec/rubocop/cop/style/space_around_block_parameters_spec.rb +0 -155
- data/spec/rubocop/cop/style/space_around_equals_in_parameter_default_spec.rb +0 -95
- data/spec/rubocop/cop/style/space_around_operators_spec.rb +0 -330
- data/spec/rubocop/cop/style/space_before_block_braces_spec.rb +0 -73
- data/spec/rubocop/cop/style/space_before_comma_spec.rb +0 -42
- data/spec/rubocop/cop/style/space_before_comment_spec.rb +0 -34
- data/spec/rubocop/cop/style/space_before_modifier_keyword_spec.rb +0 -70
- data/spec/rubocop/cop/style/space_before_semicolon_spec.rb +0 -28
- data/spec/rubocop/cop/style/space_inside_block_braces_spec.rb +0 -317
- data/spec/rubocop/cop/style/space_inside_brackets_spec.rb +0 -83
- data/spec/rubocop/cop/style/space_inside_hash_literal_braces_spec.rb +0 -147
- data/spec/rubocop/cop/style/space_inside_parens_spec.rb +0 -44
- data/spec/rubocop/cop/style/space_inside_range_literal_spec.rb +0 -64
- data/spec/rubocop/cop/style/special_global_vars_spec.rb +0 -62
- data/spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb +0 -99
- data/spec/rubocop/cop/style/string_literals_spec.rb +0 -228
- data/spec/rubocop/cop/style/struct_inheritance_spec.rb +0 -44
- data/spec/rubocop/cop/style/symbol_array_spec.rb +0 -37
- data/spec/rubocop/cop/style/symbol_proc_spec.rb +0 -100
- data/spec/rubocop/cop/style/tab_spec.rb +0 -47
- data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +0 -83
- data/spec/rubocop/cop/style/trailing_comma_spec.rb +0 -390
- data/spec/rubocop/cop/style/trailing_whitespace_spec.rb +0 -31
- data/spec/rubocop/cop/style/trivial_accessors_spec.rb +0 -558
- data/spec/rubocop/cop/style/unless_else_spec.rb +0 -23
- data/spec/rubocop/cop/style/unneeded_capital_w_spec.rb +0 -90
- data/spec/rubocop/cop/style/unneeded_percent_q_spec.rb +0 -127
- data/spec/rubocop/cop/style/unneeded_percent_x_spec.rb +0 -34
- data/spec/rubocop/cop/style/variable_interpolation_spec.rb +0 -76
- data/spec/rubocop/cop/style/variable_name_spec.rb +0 -107
- data/spec/rubocop/cop/style/when_then_spec.rb +0 -42
- data/spec/rubocop/cop/style/while_until_do_spec.rb +0 -55
- data/spec/rubocop/cop/style/while_until_modifier_spec.rb +0 -93
- data/spec/rubocop/cop/style/word_array_spec.rb +0 -117
- data/spec/rubocop/cop/team_spec.rb +0 -190
- data/spec/rubocop/cop/util_spec.rb +0 -102
- data/spec/rubocop/cop/variable_force/assignment_spec.rb +0 -200
- data/spec/rubocop/cop/variable_force/locatable_spec.rb +0 -699
- data/spec/rubocop/cop/variable_force/reference_spec.rb +0 -19
- data/spec/rubocop/cop/variable_force/scope_spec.rb +0 -319
- data/spec/rubocop/cop/variable_force/variable_spec.rb +0 -59
- data/spec/rubocop/cop/variable_force/variable_table_spec.rb +0 -276
- data/spec/rubocop/cop/variable_force_spec.rb +0 -26
- data/spec/rubocop/formatter/base_formatter_spec.rb +0 -191
- data/spec/rubocop/formatter/clang_style_formatter_spec.rb +0 -114
- data/spec/rubocop/formatter/colorizable_spec.rb +0 -107
- data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +0 -50
- data/spec/rubocop/formatter/disabled_lines_formatter_spec.rb +0 -67
- data/spec/rubocop/formatter/emacs_style_formatter_spec.rb +0 -63
- data/spec/rubocop/formatter/file_list_formatter_spec.rb +0 -33
- data/spec/rubocop/formatter/formatter_set_spec.rb +0 -141
- data/spec/rubocop/formatter/fuubar_style_formatter_spec.rb +0 -129
- data/spec/rubocop/formatter/html_formatter_spec.rb +0 -48
- data/spec/rubocop/formatter/json_formatter_spec.rb +0 -152
- data/spec/rubocop/formatter/offense_count_formatter_spec.rb +0 -75
- data/spec/rubocop/formatter/progress_formatter_spec.rb +0 -182
- data/spec/rubocop/formatter/simple_text_formatter_spec.rb +0 -135
- data/spec/rubocop/formatter/text_util_spec.rb +0 -55
- data/spec/rubocop/options_spec.rb +0 -181
- data/spec/rubocop/path_util_spec.rb +0 -77
- data/spec/rubocop/processed_source_spec.rb +0 -184
- data/spec/rubocop/rake_task_spec.rb +0 -122
- data/spec/rubocop/runner_spec.rb +0 -99
- data/spec/rubocop/string_util_spec.rb +0 -46
- data/spec/rubocop/target_finder_spec.rb +0 -245
- data/spec/rubocop/token_spec.rb +0 -29
- data/spec/spec_helper.rb +0 -39
- data/spec/support/cop_helper.rb +0 -75
- data/spec/support/cops/class_must_be_a_module_cop.rb +0 -19
- data/spec/support/cops/module_must_be_a_class_cop.rb +0 -19
- data/spec/support/coverage.rb +0 -15
- data/spec/support/custom_matchers.rb +0 -58
- data/spec/support/file_helper.rb +0 -23
- data/spec/support/jruby_workaround.rb +0 -15
- data/spec/support/mri_syntax_checker.rb +0 -73
- data/spec/support/shared_contexts.rb +0 -53
- data/spec/support/shared_examples.rb +0 -55
- data/spec/support/statement_modifier_helper.rb +0 -41
data/config/enabled.yml
CHANGED
@@ -78,7 +78,7 @@ Style/BlockEndNewline:
|
|
78
78
|
Description: 'Put end statement of multiline block on its own line.'
|
79
79
|
Enabled: true
|
80
80
|
|
81
|
-
Style/
|
81
|
+
Style/BlockDelimiters:
|
82
82
|
Description: >-
|
83
83
|
Avoid using {...} for multi-line blocks (multiline chaining is
|
84
84
|
always ugly).
|
@@ -128,11 +128,20 @@ Style/ClassVars:
|
|
128
128
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
|
129
129
|
Enabled: true
|
130
130
|
|
131
|
+
Style/ClosingParenthesisIndentation:
|
132
|
+
Description: 'Checks the indentation of hanging closing parentheses.'
|
133
|
+
Enabled: true
|
134
|
+
|
131
135
|
Style/ColonMethodCall:
|
132
136
|
Description: 'Do not use :: for method call.'
|
133
137
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons'
|
134
138
|
Enabled: true
|
135
139
|
|
140
|
+
Style/CommandLiteral:
|
141
|
+
Description: 'Use `` or %x around command literals.'
|
142
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-x'
|
143
|
+
Enabled: true
|
144
|
+
|
136
145
|
Style/CommentAnnotation:
|
137
146
|
Description: >-
|
138
147
|
Checks formatting of special comments
|
@@ -494,11 +503,7 @@ Style/RedundantSelf:
|
|
494
503
|
Enabled: true
|
495
504
|
|
496
505
|
Style/RegexpLiteral:
|
497
|
-
Description:
|
498
|
-
Use %r for regular expressions matching more than
|
499
|
-
`MaxSlashes` '/' characters.
|
500
|
-
Use %r only for regular expressions matching more than
|
501
|
-
`MaxSlashes` '/' character.
|
506
|
+
Description: 'Use / or %r around regular expressions.'
|
502
507
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
|
503
508
|
Enabled: true
|
504
509
|
|
@@ -611,7 +616,7 @@ Style/SpaceAroundEqualsInParameterDefault:
|
|
611
616
|
Enabled: true
|
612
617
|
|
613
618
|
Style/SpaceAroundOperators:
|
614
|
-
Description: 'Use
|
619
|
+
Description: 'Use a single space around operators.'
|
615
620
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators'
|
616
621
|
Enabled: true
|
617
622
|
|
@@ -660,6 +665,10 @@ Style/StructInheritance:
|
|
660
665
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-extend-struct-new'
|
661
666
|
Enabled: true
|
662
667
|
|
668
|
+
Style/SymbolLiteral:
|
669
|
+
Description: 'Use plain symbols instead of string symbols when possible.'
|
670
|
+
Enabled: true
|
671
|
+
|
663
672
|
Style/SymbolProc:
|
664
673
|
Description: 'Use symbols as procs instead of blocks when possible.'
|
665
674
|
Enabled: true
|
@@ -705,11 +714,6 @@ Style/UnneededPercentQ:
|
|
705
714
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q'
|
706
715
|
Enabled: true
|
707
716
|
|
708
|
-
Style/UnneededPercentX:
|
709
|
-
Description: 'Checks for %x when `` would do.'
|
710
|
-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-x'
|
711
|
-
Enabled: true
|
712
|
-
|
713
717
|
Style/VariableInterpolation:
|
714
718
|
Description: >-
|
715
719
|
Don't interpolate global, instance and class variables
|
@@ -891,6 +895,10 @@ Lint/Loop:
|
|
891
895
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
|
892
896
|
Enabled: true
|
893
897
|
|
898
|
+
Lint/NonLocalExitFromIterator:
|
899
|
+
Description: 'Do not use return in iterator to cause non-local exit.'
|
900
|
+
Enabled: true
|
901
|
+
|
894
902
|
Lint/ParenthesesAsGroupedExpression:
|
895
903
|
Description: >-
|
896
904
|
Checks for method calls with a space before the opening
|
@@ -969,12 +977,54 @@ Lint/Void:
|
|
969
977
|
Description: 'Possible use of operator/literal/variable in void context.'
|
970
978
|
Enabled: true
|
971
979
|
|
980
|
+
##################### Performance #############################
|
981
|
+
|
982
|
+
Performance/Detect:
|
983
|
+
Description: >-
|
984
|
+
Use `detect` instead of `select.first`, `find_all.first`,
|
985
|
+
`select.last`, and `find_all.last`.
|
986
|
+
Enabled: true
|
987
|
+
|
988
|
+
Performance/FlatMap:
|
989
|
+
Description: >-
|
990
|
+
Use `Enumerable#flat_map`
|
991
|
+
instead of `Enumerable#map...Array#flatten(1)`
|
992
|
+
or `Enumberable#collect..Array#flatten(1)`
|
993
|
+
Enabled: true
|
994
|
+
EnabledForFlattenWithoutParams: false
|
995
|
+
# If enabled, this cop will warn about usages of
|
996
|
+
# `flatten` being called without any parameters.
|
997
|
+
# This can be dangerous since `flat_map` will only flatten 1 level, and
|
998
|
+
# `flatten` without any parameters can flatten multiple levels.
|
999
|
+
|
1000
|
+
Performance/ReverseEach:
|
1001
|
+
Description: 'Use `reverse_each` instead of `reverse.each`.'
|
1002
|
+
Enabled: true
|
1003
|
+
|
1004
|
+
Performance/Sample:
|
1005
|
+
Description: >-
|
1006
|
+
Use `sample` instead of `shuffle.first`,
|
1007
|
+
`shuffle.last`, and `shuffle[Fixnum]`.
|
1008
|
+
Enabled: true
|
1009
|
+
|
1010
|
+
Performance/Size:
|
1011
|
+
Description: >-
|
1012
|
+
Use `size` instead of `count` for counting
|
1013
|
+
the number of elements in `Array` and `Hash`.
|
1014
|
+
Enabled: true
|
1015
|
+
|
972
1016
|
##################### Rails ##################################
|
973
1017
|
|
974
1018
|
Rails/ActionFilter:
|
975
1019
|
Description: 'Enforces consistent use of action filter methods.'
|
976
1020
|
Enabled: true
|
977
1021
|
|
1022
|
+
Rails/Date:
|
1023
|
+
Description: >-
|
1024
|
+
Checks the correct usage of date aware methods,
|
1025
|
+
such as Date.today, Date.current etc.
|
1026
|
+
Enabled: true
|
1027
|
+
|
978
1028
|
Rails/DefaultScope:
|
979
1029
|
Description: 'Checks if the argument passed to default_scope is a block.'
|
980
1030
|
Enabled: true
|
@@ -983,6 +1033,14 @@ Rails/Delegate:
|
|
983
1033
|
Description: 'Prefer delegate method for delegations.'
|
984
1034
|
Enabled: true
|
985
1035
|
|
1036
|
+
Rails/FindBy:
|
1037
|
+
Description: 'Prefer find_by over where.first.'
|
1038
|
+
Enabled: true
|
1039
|
+
|
1040
|
+
Rails/FindEach:
|
1041
|
+
Description: 'Prefer all.find_each over all.find.'
|
1042
|
+
Enabled: true
|
1043
|
+
|
986
1044
|
Rails/HasAndBelongsToMany:
|
987
1045
|
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
988
1046
|
Enabled: true
|
@@ -1001,6 +1059,10 @@ Rails/ScopeArgs:
|
|
1001
1059
|
Description: 'Checks the arguments of ActiveRecord scopes.'
|
1002
1060
|
Enabled: true
|
1003
1061
|
|
1062
|
+
Rails/TimeZone:
|
1063
|
+
Description: 'Checks the correct usage of time zone aware methods.'
|
1064
|
+
Enabled: true
|
1065
|
+
|
1004
1066
|
Rails/Validation:
|
1005
1067
|
Description: 'Use validates :attribute, hash of validations.'
|
1006
1068
|
Enabled: true
|
data/lib/rubocop.rb
CHANGED
@@ -21,6 +21,7 @@ require 'rubocop/string_util'
|
|
21
21
|
require 'rubocop/cop/util'
|
22
22
|
require 'rubocop/cop/offense'
|
23
23
|
require 'rubocop/cop/ignored_node'
|
24
|
+
require 'rubocop/cop/autocorrect_logic'
|
24
25
|
require 'rubocop/cop/cop'
|
25
26
|
require 'rubocop/cop/commissioner'
|
26
27
|
require 'rubocop/cop/corrector'
|
@@ -86,6 +87,7 @@ require 'rubocop/cop/lint/invalid_character_literal'
|
|
86
87
|
require 'rubocop/cop/lint/literal_in_condition'
|
87
88
|
require 'rubocop/cop/lint/literal_in_interpolation'
|
88
89
|
require 'rubocop/cop/lint/loop'
|
90
|
+
require 'rubocop/cop/lint/non_local_exit_from_iterator'
|
89
91
|
require 'rubocop/cop/lint/parentheses_as_grouped_expression'
|
90
92
|
require 'rubocop/cop/lint/require_parentheses'
|
91
93
|
require 'rubocop/cop/lint/rescue_exception'
|
@@ -113,6 +115,12 @@ require 'rubocop/cop/metrics/method_length'
|
|
113
115
|
require 'rubocop/cop/metrics/parameter_lists'
|
114
116
|
require 'rubocop/cop/metrics/perceived_complexity'
|
115
117
|
|
118
|
+
require 'rubocop/cop/performance/detect'
|
119
|
+
require 'rubocop/cop/performance/flat_map'
|
120
|
+
require 'rubocop/cop/performance/reverse_each'
|
121
|
+
require 'rubocop/cop/performance/sample'
|
122
|
+
require 'rubocop/cop/performance/size'
|
123
|
+
|
116
124
|
require 'rubocop/cop/style/access_modifier_indentation'
|
117
125
|
require 'rubocop/cop/style/accessor_method_name'
|
118
126
|
require 'rubocop/cop/style/alias'
|
@@ -124,11 +132,12 @@ require 'rubocop/cop/style/array_join'
|
|
124
132
|
require 'rubocop/cop/style/ascii_comments'
|
125
133
|
require 'rubocop/cop/style/ascii_identifiers'
|
126
134
|
require 'rubocop/cop/style/attr'
|
135
|
+
require 'rubocop/cop/style/auto_resource_cleanup'
|
127
136
|
require 'rubocop/cop/style/bare_percent_literals'
|
128
137
|
require 'rubocop/cop/style/begin_block'
|
129
138
|
require 'rubocop/cop/style/block_comments'
|
130
139
|
require 'rubocop/cop/style/block_end_newline'
|
131
|
-
require 'rubocop/cop/style/
|
140
|
+
require 'rubocop/cop/style/block_delimiters'
|
132
141
|
require 'rubocop/cop/style/braces_around_hash_parameters'
|
133
142
|
require 'rubocop/cop/style/case_equality'
|
134
143
|
require 'rubocop/cop/style/case_indentation'
|
@@ -138,10 +147,13 @@ require 'rubocop/cop/style/class_and_module_children'
|
|
138
147
|
require 'rubocop/cop/style/class_check'
|
139
148
|
require 'rubocop/cop/style/class_methods'
|
140
149
|
require 'rubocop/cop/style/class_vars'
|
150
|
+
require 'rubocop/cop/style/closing_parenthesis_indentation'
|
141
151
|
require 'rubocop/cop/style/collection_methods'
|
142
152
|
require 'rubocop/cop/style/colon_method_call'
|
153
|
+
require 'rubocop/cop/style/command_literal'
|
143
154
|
require 'rubocop/cop/style/comment_annotation'
|
144
155
|
require 'rubocop/cop/style/comment_indentation'
|
156
|
+
require 'rubocop/cop/style/copyright'
|
145
157
|
require 'rubocop/cop/style/constant_name'
|
146
158
|
require 'rubocop/cop/style/def_with_parentheses'
|
147
159
|
require 'rubocop/cop/style/deprecated_hash_methods'
|
@@ -151,6 +163,7 @@ require 'rubocop/cop/style/double_negation'
|
|
151
163
|
require 'rubocop/cop/style/each_with_object'
|
152
164
|
require 'rubocop/cop/style/else_alignment'
|
153
165
|
require 'rubocop/cop/style/empty_else'
|
166
|
+
require 'rubocop/cop/style/missing_else'
|
154
167
|
require 'rubocop/cop/style/empty_line_between_defs'
|
155
168
|
require 'rubocop/cop/style/empty_lines'
|
156
169
|
require 'rubocop/cop/style/empty_lines_around_access_modifier'
|
@@ -247,6 +260,7 @@ require 'rubocop/cop/style/string_literals'
|
|
247
260
|
require 'rubocop/cop/style/string_literals_in_interpolation'
|
248
261
|
require 'rubocop/cop/style/struct_inheritance'
|
249
262
|
require 'rubocop/cop/style/symbol_array'
|
263
|
+
require 'rubocop/cop/style/symbol_literal'
|
250
264
|
require 'rubocop/cop/style/symbol_proc'
|
251
265
|
require 'rubocop/cop/style/tab'
|
252
266
|
require 'rubocop/cop/style/trailing_blank_lines'
|
@@ -256,7 +270,6 @@ require 'rubocop/cop/style/trivial_accessors'
|
|
256
270
|
require 'rubocop/cop/style/unless_else'
|
257
271
|
require 'rubocop/cop/style/unneeded_capital_w'
|
258
272
|
require 'rubocop/cop/style/unneeded_percent_q'
|
259
|
-
require 'rubocop/cop/style/unneeded_percent_x'
|
260
273
|
require 'rubocop/cop/style/variable_interpolation'
|
261
274
|
require 'rubocop/cop/style/variable_name'
|
262
275
|
require 'rubocop/cop/style/when_then'
|
@@ -265,12 +278,16 @@ require 'rubocop/cop/style/while_until_modifier'
|
|
265
278
|
require 'rubocop/cop/style/word_array'
|
266
279
|
|
267
280
|
require 'rubocop/cop/rails/action_filter'
|
281
|
+
require 'rubocop/cop/rails/date'
|
268
282
|
require 'rubocop/cop/rails/default_scope'
|
269
283
|
require 'rubocop/cop/rails/delegate'
|
284
|
+
require 'rubocop/cop/rails/find_by'
|
285
|
+
require 'rubocop/cop/rails/find_each'
|
270
286
|
require 'rubocop/cop/rails/has_and_belongs_to_many'
|
271
287
|
require 'rubocop/cop/rails/output'
|
272
288
|
require 'rubocop/cop/rails/read_write_attribute'
|
273
289
|
require 'rubocop/cop/rails/scope_args'
|
290
|
+
require 'rubocop/cop/rails/time_zone'
|
274
291
|
require 'rubocop/cop/rails/validation'
|
275
292
|
|
276
293
|
require 'rubocop/formatter/base_formatter'
|
data/lib/rubocop/config.rb
CHANGED
@@ -95,8 +95,9 @@ module RuboCop
|
|
95
95
|
# TODO: This should be a private method
|
96
96
|
def validate
|
97
97
|
# Don't validate RuboCop's own files. Avoids infinite recursion.
|
98
|
-
|
99
|
-
|
98
|
+
base_config_path = File.expand_path(File.join(ConfigLoader::RUBOCOP_HOME,
|
99
|
+
'config'))
|
100
|
+
return if File.expand_path(loaded_path).start_with?(base_config_path)
|
100
101
|
|
101
102
|
valid_cop_names, invalid_cop_names = @hash.keys.partition do |key|
|
102
103
|
ConfigLoader.default_configuration.key?(key)
|
@@ -111,14 +112,33 @@ module RuboCop
|
|
111
112
|
end
|
112
113
|
|
113
114
|
def file_to_include?(file)
|
114
|
-
absolute_file_path = File.expand_path(file)
|
115
115
|
relative_file_path = path_relative_to_config(file)
|
116
|
+
|
117
|
+
# Optimization to quickly decide if the given file is hidden (on the top
|
118
|
+
# level) and can not be matched by any pattern.
|
119
|
+
is_hidden = relative_file_path.start_with?('.') &&
|
120
|
+
!relative_file_path.start_with?('..')
|
121
|
+
return false if is_hidden && !possibly_include_hidden?
|
122
|
+
|
123
|
+
absolute_file_path = File.expand_path(file)
|
124
|
+
|
116
125
|
patterns_to_include.any? do |pattern|
|
117
126
|
match_path?(pattern, relative_file_path, loaded_path) ||
|
118
127
|
match_path?(pattern, absolute_file_path, loaded_path)
|
119
128
|
end
|
120
129
|
end
|
121
130
|
|
131
|
+
# Returns true if there's a chance that an Include pattern matches hidden
|
132
|
+
# files, false if that's definitely not possible.
|
133
|
+
def possibly_include_hidden?
|
134
|
+
if @possibly_include_hidden.nil?
|
135
|
+
@possibly_include_hidden = patterns_to_include.any? do |s|
|
136
|
+
s.is_a?(Regexp) || s.start_with?('.') || s.include?('/.')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
@possibly_include_hidden
|
140
|
+
end
|
141
|
+
|
122
142
|
def file_to_exclude?(file)
|
123
143
|
file = File.expand_path(file)
|
124
144
|
patterns_to_exclude.any? do |pattern|
|
@@ -114,7 +114,7 @@ module RuboCop
|
|
114
114
|
# is not possible to reproduce now, but we want to avoid it in case
|
115
115
|
# it's still there. So we only load the YAML code if we find some real
|
116
116
|
# code in there.
|
117
|
-
hash = yaml_code =~ /^[A-Z]/i ?
|
117
|
+
hash = yaml_code =~ /^[A-Z]/i ? yaml_safe_load(yaml_code) : {}
|
118
118
|
puts "configuration from #{absolute_path}" if debug?
|
119
119
|
|
120
120
|
unless hash.is_a?(Hash)
|
@@ -124,6 +124,14 @@ module RuboCop
|
|
124
124
|
hash
|
125
125
|
end
|
126
126
|
|
127
|
+
def yaml_safe_load(yaml_code)
|
128
|
+
if YAML.respond_to?(:safe_load) # Ruby 2.1+
|
129
|
+
YAML.safe_load(yaml_code, [Regexp])
|
130
|
+
else
|
131
|
+
YAML.load(yaml_code)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
127
135
|
def resolve_inheritance(path, hash)
|
128
136
|
base_configs(path, hash['inherit_from']).reverse_each do |base_config|
|
129
137
|
base_config.each do |k, v|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
# This module encapsulates the logic for autocorrect behaviour for a cop
|
6
|
+
module AutocorrectLogic
|
7
|
+
def autocorrect?
|
8
|
+
autocorrect_requested? && support_autocorrect? && autocorrect_enabled?
|
9
|
+
end
|
10
|
+
|
11
|
+
def autocorrect_requested?
|
12
|
+
@options.fetch(:auto_correct, false)
|
13
|
+
end
|
14
|
+
|
15
|
+
def support_autocorrect?
|
16
|
+
respond_to?(:autocorrect, true)
|
17
|
+
end
|
18
|
+
|
19
|
+
def autocorrect_enabled?
|
20
|
+
# allow turning off autocorrect on a cop by cop basis
|
21
|
+
return true unless cop_config
|
22
|
+
cop_config['AutoCorrect'] != 'False'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/rubocop/cop/cop.rb
CHANGED
@@ -47,6 +47,7 @@ module RuboCop
|
|
47
47
|
extend AST::Sexp
|
48
48
|
include Util
|
49
49
|
include IgnoredNode
|
50
|
+
include AutocorrectLogic
|
50
51
|
|
51
52
|
attr_reader :config, :offenses, :corrections
|
52
53
|
attr_accessor :processed_source # TODO: Bad design.
|
@@ -105,7 +106,7 @@ module RuboCop
|
|
105
106
|
|
106
107
|
def initialize(config = nil, options = nil)
|
107
108
|
@config = config || Config.new
|
108
|
-
@options = options || {
|
109
|
+
@options = options || { debug: false }
|
109
110
|
|
110
111
|
@offenses = []
|
111
112
|
@corrections = []
|
@@ -119,10 +120,6 @@ module RuboCop
|
|
119
120
|
@config.for_cop(self)
|
120
121
|
end
|
121
122
|
|
122
|
-
def autocorrect?
|
123
|
-
@options[:auto_correct] && support_autocorrect?
|
124
|
-
end
|
125
|
-
|
126
123
|
def debug?
|
127
124
|
@options[:debug]
|
128
125
|
end
|
@@ -132,12 +129,14 @@ module RuboCop
|
|
132
129
|
config['AllCops'] && config['AllCops']['DisplayCopNames']
|
133
130
|
end
|
134
131
|
|
135
|
-
def
|
136
|
-
|
132
|
+
def display_style_guide?
|
133
|
+
style_guide_url &&
|
134
|
+
(@options[:display_style_guide] ||
|
135
|
+
config['AllCops'] && config['AllCops']['DisplayStyleGuide'])
|
137
136
|
end
|
138
137
|
|
139
|
-
def
|
140
|
-
|
138
|
+
def message(_node = nil)
|
139
|
+
self.class::MSG
|
141
140
|
end
|
142
141
|
|
143
142
|
def add_offense(node, loc, message = nil, severity = nil)
|
@@ -151,18 +150,24 @@ module RuboCop
|
|
151
150
|
severity = custom_severity || severity || default_severity
|
152
151
|
|
153
152
|
message ||= message(node)
|
154
|
-
message =
|
155
|
-
|
156
|
-
corrected =
|
157
|
-
|
158
|
-
autocorrect?
|
159
|
-
rescue CorrectionNotPossible
|
160
|
-
false
|
161
|
-
end
|
153
|
+
message = annotate_message(message)
|
154
|
+
|
155
|
+
corrected = correct(node)
|
156
|
+
|
162
157
|
@offenses << Offense.new(severity, location, message, name, corrected)
|
163
158
|
yield if block_given?
|
164
159
|
end
|
165
160
|
|
161
|
+
def correct(node)
|
162
|
+
return nil unless support_autocorrect?
|
163
|
+
return false unless autocorrect?
|
164
|
+
|
165
|
+
autocorrect(node)
|
166
|
+
true
|
167
|
+
rescue CorrectionNotPossible
|
168
|
+
false
|
169
|
+
end
|
170
|
+
|
166
171
|
def config_to_allow_offenses
|
167
172
|
Formatter::DisabledConfigFormatter.config_to_allow_offenses[cop_name]
|
168
173
|
end
|
@@ -183,8 +188,19 @@ module RuboCop
|
|
183
188
|
!file_name_matches_any?(file, 'Exclude', false)
|
184
189
|
end
|
185
190
|
|
191
|
+
def style_guide_url
|
192
|
+
url = cop_config && cop_config['StyleGuide']
|
193
|
+
(url.nil? || url.empty?) ? nil : url
|
194
|
+
end
|
195
|
+
|
186
196
|
private
|
187
197
|
|
198
|
+
def annotate_message(message)
|
199
|
+
message = "#{name}: #{message}" if display_cop_names?
|
200
|
+
message = "#{message} (#{style_guide_url})" if display_style_guide?
|
201
|
+
message
|
202
|
+
end
|
203
|
+
|
188
204
|
def file_name_matches_any?(file, parameter, default_result)
|
189
205
|
patterns = cop_config && cop_config[parameter]
|
190
206
|
return default_result unless patterns
|