rubocop 0.81.0 → 0.85.1
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.
- checksums.yaml +4 -4
- data/README.md +13 -17
- data/config/default.yml +141 -35
- data/lib/rubocop.rb +17 -61
- data/lib/rubocop/ast_aliases.rb +8 -0
- data/lib/rubocop/cli.rb +13 -7
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +2 -2
- data/lib/rubocop/cli/command/show_cops.rb +2 -6
- data/lib/rubocop/comment_config.rb +1 -1
- data/lib/rubocop/config.rb +14 -2
- data/lib/rubocop/config_loader.rb +37 -33
- data/lib/rubocop/config_loader_resolver.rb +45 -6
- data/lib/rubocop/config_obsoletion.rb +1 -0
- data/lib/rubocop/config_store.rb +12 -2
- data/lib/rubocop/config_validator.rb +18 -1
- data/lib/rubocop/cop/autocorrect_logic.rb +1 -2
- data/lib/rubocop/cop/badge.rb +5 -5
- data/lib/rubocop/cop/bundler/gem_comment.rb +70 -1
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
- data/lib/rubocop/cop/commissioner.rb +0 -21
- data/lib/rubocop/cop/cop.rb +36 -21
- data/lib/rubocop/cop/corrector.rb +48 -24
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +4 -8
- data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -2
- data/lib/rubocop/cop/correctors/empty_line_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +4 -4
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/space_corrector.rb +1 -3
- data/lib/rubocop/cop/correctors/string_literal_corrector.rb +2 -2
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -3
- data/lib/rubocop/cop/generator.rb +4 -3
- data/lib/rubocop/cop/ignored_node.rb +1 -3
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -1
- data/lib/rubocop/cop/layout/case_indentation.rb +3 -3
- data/lib/rubocop/cop/layout/class_structure.rb +19 -16
- data/lib/rubocop/cop/layout/condition_position.rb +12 -2
- data/lib/rubocop/cop/layout/dot_position.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2 -6
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +126 -0
- data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +1 -3
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +14 -10
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +1 -3
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/hash_alignment.rb +6 -6
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +5 -9
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +21 -104
- data/lib/rubocop/cop/layout/{tab.rb → indentation_style.rb} +48 -6
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -3
- data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +23 -20
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +1 -3
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +13 -4
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +3 -3
- data/lib/rubocop/cop/layout/space_around_keyword.rb +2 -2
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +131 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +19 -2
- data/lib/rubocop/cop/layout/space_before_comment.rb +1 -3
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +1 -3
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +1 -3
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +2 -2
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +41 -0
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +14 -0
- data/lib/rubocop/cop/lint/boolean_symbol.rb +2 -2
- data/lib/rubocop/cop/lint/debugger.rb +1 -1
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +137 -0
- data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -5
- data/lib/rubocop/cop/lint/empty_when.rb +29 -6
- data/lib/rubocop/cop/lint/ensure_return.rb +19 -2
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -3
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +33 -2
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
- data/lib/rubocop/cop/lint/inherit_exception.rb +1 -1
- data/lib/rubocop/cop/lint/interpolation_check.rb +1 -1
- data/lib/rubocop/cop/lint/literal_as_condition.rb +10 -13
- 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/mixed_regexp_capture_types.rb +69 -0
- data/lib/rubocop/cop/lint/multiple_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/nested_percent_literal.rb +1 -1
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +2 -2
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +7 -7
- data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +33 -11
- data/lib/rubocop/cop/lint/percent_string_array.rb +2 -4
- data/lib/rubocop/cop/lint/raise_exception.rb +42 -6
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +1 -6
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +3 -3
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/suppressed_exception.rb +11 -4
- data/lib/rubocop/cop/lint/syntax.rb +1 -3
- data/lib/rubocop/cop/lint/unified_integer.rb +0 -2
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/uri_regexp.rb +4 -4
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +13 -3
- data/lib/rubocop/cop/lint/useless_assignment.rb +3 -2
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +6 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/migration/department_name.rb +7 -7
- data/lib/rubocop/cop/mixin/alignment.rb +1 -3
- data/lib/rubocop/cop/mixin/array_min_size.rb +1 -3
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +3 -9
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -3
- data/lib/rubocop/cop/mixin/configurable_formatting.rb +2 -4
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +10 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +9 -2
- data/lib/rubocop/cop/mixin/ignored_pattern.rb +1 -1
- data/lib/rubocop/cop/mixin/line_length_help.rb +3 -2
- data/lib/rubocop/cop/mixin/parser_diagnostic.rb +1 -1
- data/lib/rubocop/cop/mixin/regexp_literal_help.rb +16 -0
- data/lib/rubocop/cop/mixin/statement_modifier.rb +7 -22
- data/lib/rubocop/cop/mixin/target_ruby_version.rb +5 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +2 -4
- data/lib/rubocop/cop/mixin/uncommunicative_name.rb +1 -1
- data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +11 -1
- data/lib/rubocop/cop/naming/constant_name.rb +2 -1
- data/lib/rubocop/cop/naming/file_name.rb +27 -14
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
- data/lib/rubocop/cop/naming/method_name.rb +1 -5
- data/lib/rubocop/cop/naming/predicate_name.rb +1 -1
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
- data/lib/rubocop/cop/registry.rb +74 -14
- data/lib/rubocop/cop/severity.rb +1 -3
- data/lib/rubocop/cop/style/alias.rb +4 -4
- data/lib/rubocop/cop/style/and_or.rb +7 -8
- data/lib/rubocop/cop/style/array_join.rb +2 -2
- data/lib/rubocop/cop/style/attr.rb +1 -3
- data/lib/rubocop/cop/style/bare_percent_literals.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +2 -8
- data/lib/rubocop/cop/style/case_equality.rb +24 -1
- data/lib/rubocop/cop/style/character_literal.rb +2 -2
- data/lib/rubocop/cop/style/conditional_assignment.rb +9 -11
- data/lib/rubocop/cop/style/copyright.rb +3 -3
- data/lib/rubocop/cop/style/dir.rb +1 -1
- data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +49 -0
- data/lib/rubocop/cop/style/double_cop_disable_directive.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +41 -4
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +3 -3
- data/lib/rubocop/cop/style/empty_literal.rb +1 -3
- data/lib/rubocop/cop/style/empty_method.rb +2 -6
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -3
- data/lib/rubocop/cop/style/exponential_notation.rb +119 -0
- data/lib/rubocop/cop/style/format_string.rb +2 -2
- data/lib/rubocop/cop/style/format_string_token.rb +2 -3
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -6
- data/lib/rubocop/cop/style/guard_clause.rb +25 -2
- data/lib/rubocop/cop/style/hash_each_methods.rb +4 -4
- data/lib/rubocop/cop/style/hash_syntax.rb +19 -12
- data/lib/rubocop/cop/style/hash_transform_values.rb +0 -3
- data/lib/rubocop/cop/style/if_unless_modifier.rb +23 -3
- data/lib/rubocop/cop/style/if_with_semicolon.rb +16 -0
- data/lib/rubocop/cop/style/inline_comment.rb +1 -1
- data/lib/rubocop/cop/style/lambda.rb +2 -2
- data/lib/rubocop/cop/style/lambda_call.rb +1 -21
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +1 -3
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -3
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/module_function.rb +2 -2
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +1 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +16 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +2 -4
- data/lib/rubocop/cop/style/negated_if.rb +3 -3
- data/lib/rubocop/cop/style/negated_unless.rb +3 -3
- data/lib/rubocop/cop/style/next.rb +2 -2
- data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +5 -5
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
- data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +3 -7
- data/lib/rubocop/cop/style/optional_arguments.rb +1 -1
- data/lib/rubocop/cop/style/or_assignment.rb +1 -1
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/perl_backrefs.rb +2 -2
- data/lib/rubocop/cop/style/proc.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +1 -1
- data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
- data/lib/rubocop/cop/style/redundant_condition.rb +3 -4
- data/lib/rubocop/cop/style/redundant_conditional.rb +5 -4
- data/lib/rubocop/cop/style/redundant_exception.rb +3 -3
- data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
- data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -6
- data/lib/rubocop/cop/style/redundant_percent_q.rb +3 -3
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +89 -0
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +130 -0
- data/lib/rubocop/cop/style/redundant_return.rb +5 -7
- data/lib/rubocop/cop/style/redundant_self.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +3 -7
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/slicing_with_range.rb +39 -0
- data/lib/rubocop/cop/style/special_global_vars.rb +3 -7
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -4
- data/lib/rubocop/cop/style/string_hash_keys.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +2 -2
- data/lib/rubocop/cop/style/symbol_literal.rb +2 -2
- data/lib/rubocop/cop/style/ternary_parentheses.rb +2 -5
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -3
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +3 -3
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +16 -13
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +3 -3
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +1 -3
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/unless_else.rb +1 -1
- data/lib/rubocop/cop/style/unpack_first.rb +0 -4
- 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_modifier.rb +1 -1
- data/lib/rubocop/cop/style/word_array.rb +1 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +1 -1
- data/lib/rubocop/cop/team.rb +69 -25
- data/lib/rubocop/cop/util.rb +25 -1
- data/lib/rubocop/cop/utils/format_string.rb +18 -0
- data/lib/rubocop/cop/variable_force.rb +3 -9
- data/lib/rubocop/cop/variable_force/assignment.rb +1 -0
- data/lib/rubocop/cop/variable_force/branch.rb +1 -3
- data/lib/rubocop/cop/variable_force/scope.rb +1 -0
- data/lib/rubocop/cop/variable_force/variable.rb +3 -6
- data/lib/rubocop/ext/processed_source.rb +18 -0
- data/lib/rubocop/formatter/base_formatter.rb +0 -4
- data/lib/rubocop/formatter/disabled_config_formatter.rb +4 -12
- data/lib/rubocop/formatter/formatter_set.rb +1 -4
- data/lib/rubocop/formatter/junit_formatter.rb +14 -4
- data/lib/rubocop/formatter/pacman_formatter.rb +1 -1
- data/lib/rubocop/magic_comment.rb +1 -1
- data/lib/rubocop/name_similarity.rb +12 -9
- data/lib/rubocop/options.rb +33 -12
- data/lib/rubocop/remote_config.rb +1 -3
- data/lib/rubocop/result_cache.rb +5 -7
- data/lib/rubocop/rspec/cop_helper.rb +3 -26
- data/lib/rubocop/rspec/expect_offense.rb +49 -16
- data/lib/rubocop/rspec/shared_contexts.rb +54 -20
- data/lib/rubocop/runner.rb +21 -14
- data/lib/rubocop/target_finder.rb +7 -7
- data/lib/rubocop/target_ruby.rb +5 -2
- data/lib/rubocop/version.rb +5 -3
- metadata +47 -77
- data/lib/rubocop/ast/builder.rb +0 -85
- data/lib/rubocop/ast/node.rb +0 -637
- data/lib/rubocop/ast/node/alias_node.rb +0 -24
- data/lib/rubocop/ast/node/and_node.rb +0 -29
- data/lib/rubocop/ast/node/args_node.rb +0 -29
- data/lib/rubocop/ast/node/array_node.rb +0 -57
- data/lib/rubocop/ast/node/block_node.rb +0 -121
- data/lib/rubocop/ast/node/break_node.rb +0 -17
- data/lib/rubocop/ast/node/case_match_node.rb +0 -56
- data/lib/rubocop/ast/node/case_node.rb +0 -56
- data/lib/rubocop/ast/node/class_node.rb +0 -31
- data/lib/rubocop/ast/node/def_node.rb +0 -82
- data/lib/rubocop/ast/node/defined_node.rb +0 -17
- data/lib/rubocop/ast/node/ensure_node.rb +0 -17
- data/lib/rubocop/ast/node/float_node.rb +0 -12
- data/lib/rubocop/ast/node/for_node.rb +0 -53
- data/lib/rubocop/ast/node/forward_args_node.rb +0 -18
- data/lib/rubocop/ast/node/hash_node.rb +0 -109
- data/lib/rubocop/ast/node/if_node.rb +0 -175
- data/lib/rubocop/ast/node/int_node.rb +0 -12
- data/lib/rubocop/ast/node/keyword_splat_node.rb +0 -45
- data/lib/rubocop/ast/node/mixin/basic_literal_node.rb +0 -16
- data/lib/rubocop/ast/node/mixin/binary_operator_node.rb +0 -43
- data/lib/rubocop/ast/node/mixin/collection_node.rb +0 -15
- data/lib/rubocop/ast/node/mixin/conditional_node.rb +0 -45
- data/lib/rubocop/ast/node/mixin/hash_element_node.rb +0 -125
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +0 -261
- data/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb +0 -114
- data/lib/rubocop/ast/node/mixin/modifier_node.rb +0 -17
- data/lib/rubocop/ast/node/mixin/numeric_node.rb +0 -21
- data/lib/rubocop/ast/node/mixin/parameterized_node.rb +0 -61
- data/lib/rubocop/ast/node/mixin/predicate_operator_node.rb +0 -35
- data/lib/rubocop/ast/node/module_node.rb +0 -24
- data/lib/rubocop/ast/node/or_node.rb +0 -29
- data/lib/rubocop/ast/node/pair_node.rb +0 -63
- data/lib/rubocop/ast/node/range_node.rb +0 -18
- data/lib/rubocop/ast/node/regexp_node.rb +0 -33
- data/lib/rubocop/ast/node/resbody_node.rb +0 -24
- data/lib/rubocop/ast/node/retry_node.rb +0 -17
- data/lib/rubocop/ast/node/return_node.rb +0 -24
- data/lib/rubocop/ast/node/self_class_node.rb +0 -24
- data/lib/rubocop/ast/node/send_node.rb +0 -13
- data/lib/rubocop/ast/node/str_node.rb +0 -16
- data/lib/rubocop/ast/node/super_node.rb +0 -21
- data/lib/rubocop/ast/node/symbol_node.rb +0 -12
- data/lib/rubocop/ast/node/until_node.rb +0 -35
- data/lib/rubocop/ast/node/when_node.rb +0 -53
- data/lib/rubocop/ast/node/while_node.rb +0 -35
- data/lib/rubocop/ast/node/yield_node.rb +0 -21
- data/lib/rubocop/ast/sexp.rb +0 -16
- data/lib/rubocop/ast/traversal.rb +0 -202
- data/lib/rubocop/formatter/disabled_lines_formatter.rb +0 -57
- data/lib/rubocop/node_pattern.rb +0 -887
- data/lib/rubocop/processed_source.rb +0 -216
- data/lib/rubocop/string_util.rb +0 -14
- data/lib/rubocop/token.rb +0 -114
| @@ -56,9 +56,7 @@ module RuboCop | |
| 56 56 | 
             
                def generate_request(uri)
         | 
| 57 57 | 
             
                  request = Net::HTTP::Get.new(uri.request_uri)
         | 
| 58 58 |  | 
| 59 | 
            -
                  if cache_path_exists?
         | 
| 60 | 
            -
                    request['If-Modified-Since'] = File.stat(cache_path).mtime.rfc2822
         | 
| 61 | 
            -
                  end
         | 
| 59 | 
            +
                  request['If-Modified-Since'] = File.stat(cache_path).mtime.rfc2822 if cache_path_exists?
         | 
| 62 60 |  | 
| 63 61 | 
             
                  yield request
         | 
| 64 62 | 
             
                end
         | 
    
        data/lib/rubocop/result_cache.rb
    CHANGED
    
    | @@ -33,16 +33,14 @@ module RuboCop | |
| 33 33 |  | 
| 34 34 | 
             
                  def requires_file_removal?(file_count, config_store)
         | 
| 35 35 | 
             
                    file_count > 1 &&
         | 
| 36 | 
            -
                      file_count > config_store. | 
| 36 | 
            +
                      file_count > config_store.for_dir('.').for_all_cops['MaxFilesInCache']
         | 
| 37 37 | 
             
                  end
         | 
| 38 38 |  | 
| 39 39 | 
             
                  def remove_oldest_files(files, dirs, cache_root, verbose)
         | 
| 40 40 | 
             
                    # Add 1 to half the number of files, so that we remove the file if
         | 
| 41 41 | 
             
                    # there's only 1 left.
         | 
| 42 42 | 
             
                    remove_count = 1 + files.length / 2
         | 
| 43 | 
            -
                    if verbose
         | 
| 44 | 
            -
                      puts "Removing the #{remove_count} oldest files from #{cache_root}"
         | 
| 45 | 
            -
                    end
         | 
| 43 | 
            +
                    puts "Removing the #{remove_count} oldest files from #{cache_root}" if verbose
         | 
| 46 44 | 
             
                    sorted = files.sort_by { |path| File.mtime(path) }
         | 
| 47 45 | 
             
                    remove_files(sorted, dirs, remove_count)
         | 
| 48 46 | 
             
                  rescue Errno::ENOENT
         | 
| @@ -62,7 +60,7 @@ module RuboCop | |
| 62 60 | 
             
                end
         | 
| 63 61 |  | 
| 64 62 | 
             
                def self.cache_root(config_store)
         | 
| 65 | 
            -
                  root = config_store. | 
| 63 | 
            +
                  root = config_store.for_dir('.').for_all_cops['CacheRootDirectory']
         | 
| 66 64 | 
             
                  root ||= if ENV.key?('XDG_CACHE_HOME')
         | 
| 67 65 | 
             
                             # Include user ID in the path to make sure the user has write
         | 
| 68 66 | 
             
                             # access.
         | 
| @@ -74,7 +72,7 @@ module RuboCop | |
| 74 72 | 
             
                end
         | 
| 75 73 |  | 
| 76 74 | 
             
                def self.allow_symlinks_in_cache_location?(config_store)
         | 
| 77 | 
            -
                  config_store. | 
| 75 | 
            +
                  config_store.for_dir('.').for_all_cops['AllowSymlinksInCacheRootDirectory']
         | 
| 78 76 | 
             
                end
         | 
| 79 77 |  | 
| 80 78 | 
             
                def initialize(file, team, options, config_store, cache_root = nil)
         | 
| @@ -145,7 +143,7 @@ module RuboCop | |
| 145 143 | 
             
                  digester = Digest::SHA1.new
         | 
| 146 144 | 
             
                  mode = File.stat(file).mode
         | 
| 147 145 | 
             
                  digester.update(
         | 
| 148 | 
            -
                    "#{file}#{mode}#{config_store. | 
| 146 | 
            +
                    "#{file}#{mode}#{config_store.for_file(file).signature}"
         | 
| 149 147 | 
             
                  )
         | 
| 150 148 | 
             
                  digester.file(file)
         | 
| 151 149 | 
             
                  digester.hexdigest
         | 
| @@ -6,7 +6,7 @@ require 'tempfile' | |
| 6 6 | 
             
            module CopHelper
         | 
| 7 7 | 
             
              extend RSpec::SharedContext
         | 
| 8 8 |  | 
| 9 | 
            -
              let(:ruby_version) { 2. | 
| 9 | 
            +
              let(:ruby_version) { 2.4 }
         | 
| 10 10 | 
             
              let(:rails_version) { false }
         | 
| 11 11 |  | 
| 12 12 | 
             
              def inspect_source_file(source)
         | 
| @@ -48,32 +48,9 @@ module CopHelper | |
| 48 48 | 
             
                corrector.rewrite
         | 
| 49 49 | 
             
              end
         | 
| 50 50 |  | 
| 51 | 
            -
              def autocorrect_source_with_loop(source, file = nil)
         | 
| 52 | 
            -
                cnt = 0
         | 
| 53 | 
            -
                loop do
         | 
| 54 | 
            -
                  cop.instance_variable_set(:@corrections, [])
         | 
| 55 | 
            -
                  new_source = autocorrect_source(source, file)
         | 
| 56 | 
            -
                  return new_source if new_source == source
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                  source = new_source
         | 
| 59 | 
            -
                  cnt += 1
         | 
| 60 | 
            -
                  if cnt > RuboCop::Runner::MAX_ITERATIONS
         | 
| 61 | 
            -
                    raise RuboCop::Runner::InfiniteCorrectionLoop.new(file, [])
         | 
| 62 | 
            -
                  end
         | 
| 63 | 
            -
                end
         | 
| 64 | 
            -
              end
         | 
| 65 | 
            -
             | 
| 66 51 | 
             
              def _investigate(cop, processed_source)
         | 
| 67 | 
            -
                 | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
                  instances << klass.new([cop])
         | 
| 71 | 
            -
                end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                commissioner =
         | 
| 74 | 
            -
                  RuboCop::Cop::Commissioner.new([cop], forces, raise_error: true)
         | 
| 75 | 
            -
                commissioner.investigate(processed_source)
         | 
| 76 | 
            -
                commissioner
         | 
| 52 | 
            +
                team = RuboCop::Cop::Team.new([cop], nil, raise_error: true)
         | 
| 53 | 
            +
                team.inspect_file(processed_source)
         | 
| 77 54 | 
             
              end
         | 
| 78 55 | 
             
            end
         | 
| 79 56 |  | 
| @@ -71,9 +71,27 @@ module RuboCop | |
| 71 71 | 
             
                #   RUBY
         | 
| 72 72 | 
             
                #
         | 
| 73 73 | 
             
                #   expect_no_corrections
         | 
| 74 | 
            +
                #
         | 
| 75 | 
            +
                # If your code has variables of different lengths, you can use `%{foo}`
         | 
| 76 | 
            +
                # and `^{foo}` to format your template:
         | 
| 77 | 
            +
                #
         | 
| 78 | 
            +
                #   %w[raise fail].each do |keyword|
         | 
| 79 | 
            +
                #     expect_offense(<<~RUBY, keyword: keyword)
         | 
| 80 | 
            +
                #       %{keyword}(RuntimeError, msg)
         | 
| 81 | 
            +
                #       ^{keyword}^^^^^^^^^^^^^^^^^^^ Redundant `RuntimeError` argument can be removed.
         | 
| 82 | 
            +
                #     RUBY
         | 
| 74 83 | 
             
                module ExpectOffense
         | 
| 84 | 
            +
                  def format_offense(source, **replacements)
         | 
| 85 | 
            +
                    replacements.each do |keyword, value|
         | 
| 86 | 
            +
                      source = source.gsub("%{#{keyword}}", value)
         | 
| 87 | 
            +
                                     .gsub("^{#{keyword}}", '^' * value.size)
         | 
| 88 | 
            +
                    end
         | 
| 89 | 
            +
                    source
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
             | 
| 75 92 | 
             
                  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
         | 
| 76 | 
            -
                  def expect_offense(source, file = nil)
         | 
| 93 | 
            +
                  def expect_offense(source, file = nil, **replacements)
         | 
| 94 | 
            +
                    source = format_offense(source, **replacements)
         | 
| 77 95 | 
             
                    RuboCop::Formatter::DisabledConfigFormatter
         | 
| 78 96 | 
             
                      .config_to_allow_offenses = {}
         | 
| 79 97 | 
             
                    RuboCop::Formatter::DisabledConfigFormatter.detected_styles = {}
         | 
| @@ -88,9 +106,7 @@ module RuboCop | |
| 88 106 | 
             
                    @processed_source = parse_source(expected_annotations.plain_source,
         | 
| 89 107 | 
             
                                                     file)
         | 
| 90 108 |  | 
| 91 | 
            -
                    unless @processed_source.valid_syntax?
         | 
| 92 | 
            -
                      raise 'Error parsing example code'
         | 
| 93 | 
            -
                    end
         | 
| 109 | 
            +
                    raise 'Error parsing example code' unless @processed_source.valid_syntax?
         | 
| 94 110 |  | 
| 95 111 | 
             
                    _investigate(cop, @processed_source)
         | 
| 96 112 | 
             
                    actual_annotations =
         | 
| @@ -98,24 +114,41 @@ module RuboCop | |
| 98 114 |  | 
| 99 115 | 
             
                    expect(actual_annotations.to_s).to eq(expected_annotations.to_s)
         | 
| 100 116 | 
             
                  end
         | 
| 101 | 
            -
                  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
         | 
| 102 117 |  | 
| 103 | 
            -
                  def expect_correction(correction)
         | 
| 104 | 
            -
                    unless @processed_source
         | 
| 105 | 
            -
                      raise '`expect_correction` must follow `expect_offense`'
         | 
| 106 | 
            -
                    end
         | 
| 118 | 
            +
                  def expect_correction(correction, loop: true)
         | 
| 119 | 
            +
                    raise '`expect_correction` must follow `expect_offense`' unless @processed_source
         | 
| 107 120 |  | 
| 108 | 
            -
                     | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 121 | 
            +
                    iteration = 0
         | 
| 122 | 
            +
                    new_source = loop do
         | 
| 123 | 
            +
                      iteration += 1
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                      corrector =
         | 
| 126 | 
            +
                        RuboCop::Cop::Corrector.new(@processed_source.buffer, cop.corrections)
         | 
| 127 | 
            +
                      corrected_source = corrector.rewrite
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                      break corrected_source unless loop
         | 
| 130 | 
            +
                      break corrected_source if cop.corrections.empty?
         | 
| 131 | 
            +
                      break corrected_source if corrected_source == @processed_source.buffer.source
         | 
| 132 | 
            +
             | 
| 133 | 
            +
                      if iteration > RuboCop::Runner::MAX_ITERATIONS
         | 
| 134 | 
            +
                        raise RuboCop::Runner::InfiniteCorrectionLoop.new(@processed_source.path, [])
         | 
| 135 | 
            +
                      end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
                      # Prepare for next loop
         | 
| 138 | 
            +
                      cop.instance_variable_set(:@corrections, [])
         | 
| 139 | 
            +
                      # Cache invalidation. This is bad!
         | 
| 140 | 
            +
                      cop.instance_variable_set(:@token_table, nil)
         | 
| 141 | 
            +
                      @processed_source = parse_source(corrected_source,
         | 
| 142 | 
            +
                                                       @processed_source.path)
         | 
| 143 | 
            +
                      _investigate(cop, @processed_source)
         | 
| 144 | 
            +
                    end
         | 
| 111 145 |  | 
| 112 146 | 
             
                    expect(new_source).to eq(correction)
         | 
| 113 147 | 
             
                  end
         | 
| 148 | 
            +
                  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
         | 
| 114 149 |  | 
| 115 150 | 
             
                  def expect_no_corrections
         | 
| 116 | 
            -
                    unless @processed_source
         | 
| 117 | 
            -
                      raise '`expect_no_corrections` must follow `expect_offense`'
         | 
| 118 | 
            -
                    end
         | 
| 151 | 
            +
                    raise '`expect_no_corrections` must follow `expect_offense`' unless @processed_source
         | 
| 119 152 |  | 
| 120 153 | 
             
                    return if cop.corrections.empty?
         | 
| 121 154 |  | 
| @@ -153,7 +186,7 @@ module RuboCop | |
| 153 186 | 
             
                      annotations = []
         | 
| 154 187 |  | 
| 155 188 | 
             
                      annotated_source.each_line do |source_line|
         | 
| 156 | 
            -
                        if source_line | 
| 189 | 
            +
                        if ANNOTATION_PATTERN.match?(source_line)
         | 
| 157 190 | 
             
                          annotations << [source.size, source_line]
         | 
| 158 191 | 
             
                        else
         | 
| 159 192 | 
             
                          source << source_line
         | 
| @@ -38,28 +38,66 @@ RSpec.shared_context 'isolated environment', :isolated_environment do | |
| 38 38 | 
             
              end
         | 
| 39 39 | 
             
            end
         | 
| 40 40 |  | 
| 41 | 
            -
            #  | 
| 42 | 
            -
            RSpec.shared_context 'config', :config do
         | 
| 43 | 
            -
               | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
                  raise '`config` must be used in `describe SomeCopClass do .. end`'
         | 
| 47 | 
            -
                end
         | 
| 41 | 
            +
            # This context assumes nothing and defines `cop`, among others.
         | 
| 42 | 
            +
            RSpec.shared_context 'config', :config do # rubocop:disable Metrics/BlockLength
         | 
| 43 | 
            +
              ### Meant to be overridden at will
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              let(:source) { 'code = {some: :ruby}' }
         | 
| 48 46 |  | 
| 49 | 
            -
             | 
| 50 | 
            -
                 | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
                   | 
| 54 | 
            -
                                   .default_configuration[cop_name]
         | 
| 55 | 
            -
                                   .merge('Enabled' => true) # in case it is 'pending'
         | 
| 56 | 
            -
                                   .merge(cop_config)
         | 
| 47 | 
            +
              let(:cop_class) do
         | 
| 48 | 
            +
                if described_class.is_a?(Class) && described_class < RuboCop::Cop::Cop
         | 
| 49 | 
            +
                  described_class
         | 
| 50 | 
            +
                else
         | 
| 51 | 
            +
                  RuboCop::Cop::Cop
         | 
| 57 52 | 
             
                end
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              let(:cop_config) { {} }
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              let(:other_cops) { {} }
         | 
| 58 | 
            +
             | 
| 59 | 
            +
              let(:cop_options) { {} }
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              ### Utilities
         | 
| 62 | 
            +
             | 
| 63 | 
            +
              def source_range(range, buffer: source_buffer)
         | 
| 64 | 
            +
                Parser::Source::Range.new(buffer, range.begin,
         | 
| 65 | 
            +
                                          range.exclude_end? ? range.end : range.end + 1)
         | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              ### Useful intermediary steps (less likely to be overridden)
         | 
| 58 69 |  | 
| 59 | 
            -
             | 
| 70 | 
            +
              let(:processed_source) { parse_source(source, 'test') }
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              let(:source_buffer) { processed_source.buffer }
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              let(:all_cops_config) do
         | 
| 75 | 
            +
                rails = { 'TargetRubyVersion' => ruby_version }
         | 
| 76 | 
            +
                rails['TargetRailsVersion'] = rails_version if rails_version
         | 
| 77 | 
            +
                rails
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
              let(:cur_cop_config) do
         | 
| 81 | 
            +
                RuboCop::ConfigLoader
         | 
| 82 | 
            +
                  .default_configuration.for_cop(cop_class)
         | 
| 83 | 
            +
                  .merge({
         | 
| 84 | 
            +
                           'Enabled' => true, # in case it is 'pending'
         | 
| 85 | 
            +
                           'AutoCorrect' => true # in case defaults set it to false
         | 
| 86 | 
            +
                         })
         | 
| 87 | 
            +
                  .merge(cop_config)
         | 
| 88 | 
            +
              end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
              let(:config) do
         | 
| 91 | 
            +
                hash = { 'AllCops' => all_cops_config,
         | 
| 92 | 
            +
                         cop_class.cop_name => cur_cop_config }.merge!(other_cops)
         | 
| 60 93 |  | 
| 61 94 | 
             
                RuboCop::Config.new(hash, "#{Dir.pwd}/.rubocop.yml")
         | 
| 62 95 | 
             
              end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
              let(:cop) do
         | 
| 98 | 
            +
                cop_class.new(config, cop_options)
         | 
| 99 | 
            +
                         .tap { |cop| cop.processed_source = processed_source }
         | 
| 100 | 
            +
              end
         | 
| 63 101 | 
             
            end
         | 
| 64 102 |  | 
| 65 103 | 
             
            RSpec.shared_context 'mock console output' do
         | 
| @@ -74,10 +112,6 @@ RSpec.shared_context 'mock console output' do | |
| 74 112 | 
             
              end
         | 
| 75 113 | 
             
            end
         | 
| 76 114 |  | 
| 77 | 
            -
            RSpec.shared_context 'ruby 2.3', :ruby23 do
         | 
| 78 | 
            -
              let(:ruby_version) { 2.3 }
         | 
| 79 | 
            -
            end
         | 
| 80 | 
            -
             | 
| 81 115 | 
             
            RSpec.shared_context 'ruby 2.4', :ruby24 do
         | 
| 82 116 | 
             
              let(:ruby_version) { 2.4 }
         | 
| 83 117 | 
             
            end
         | 
    
        data/lib/rubocop/runner.rb
    CHANGED
    
    | @@ -61,7 +61,12 @@ module RuboCop | |
| 61 61 |  | 
| 62 62 | 
             
                def find_target_files(paths)
         | 
| 63 63 | 
             
                  target_finder = TargetFinder.new(@config_store, @options)
         | 
| 64 | 
            -
                   | 
| 64 | 
            +
                  mode = if @options[:only_recognized_file_types]
         | 
| 65 | 
            +
                           :only_recognized_file_types
         | 
| 66 | 
            +
                         else
         | 
| 67 | 
            +
                           :all_file_types
         | 
| 68 | 
            +
                         end
         | 
| 69 | 
            +
                  target_files = target_finder.find(paths, mode)
         | 
| 65 70 | 
             
                  target_files.each(&:freeze).freeze
         | 
| 66 71 | 
             
                end
         | 
| 67 72 |  | 
| @@ -75,9 +80,7 @@ module RuboCop | |
| 75 80 | 
             
                  # OPTIMIZE: Calling `ResultCache.cleanup` takes time. This optimization
         | 
| 76 81 | 
             
                  # mainly targets editors that integrates RuboCop. When RuboCop is run
         | 
| 77 82 | 
             
                  # by an editor, it should be inspecting only one file.
         | 
| 78 | 
            -
                  if files.size > 1 && cached_run?
         | 
| 79 | 
            -
                    ResultCache.cleanup(@config_store, @options[:debug])
         | 
| 80 | 
            -
                  end
         | 
| 83 | 
            +
                  ResultCache.cleanup(@config_store, @options[:debug]) if files.size > 1 && cached_run?
         | 
| 81 84 | 
             
                  formatter_set.finished(inspected_files.freeze)
         | 
| 82 85 | 
             
                  formatter_set.close_output_files
         | 
| 83 86 | 
             
                end
         | 
| @@ -126,7 +129,7 @@ module RuboCop | |
| 126 129 | 
             
                end
         | 
| 127 130 |  | 
| 128 131 | 
             
                def file_offense_cache(file)
         | 
| 129 | 
            -
                  config = @config_store. | 
| 132 | 
            +
                  config = @config_store.for_file(file)
         | 
| 130 133 | 
             
                  cache = cached_result(file, standby_team(config)) if cached_run?
         | 
| 131 134 |  | 
| 132 135 | 
             
                  if cache&.valid?
         | 
| @@ -165,7 +168,7 @@ module RuboCop | |
| 165 168 | 
             
                end
         | 
| 166 169 |  | 
| 167 170 | 
             
                def redundant_cop_disable_directive(file)
         | 
| 168 | 
            -
                  config = @config_store. | 
| 171 | 
            +
                  config = @config_store.for_file(file)
         | 
| 169 172 | 
             
                  if config.for_cop(Cop::Lint::RedundantCopDisableDirective)
         | 
| 170 173 | 
             
                           .fetch('Enabled')
         | 
| 171 174 | 
             
                    cop = Cop::Lint::RedundantCopDisableDirective.new(config, @options)
         | 
| @@ -180,7 +183,7 @@ module RuboCop | |
| 180 183 | 
             
                def autocorrect_redundant_disables(file, source, cop, offenses)
         | 
| 181 184 | 
             
                  cop.processed_source = source
         | 
| 182 185 |  | 
| 183 | 
            -
                  team = Cop::Team. | 
| 186 | 
            +
                  team = Cop::Team.mobilize(RuboCop::Cop::Registry.new, nil, @options)
         | 
| 184 187 | 
             
                  team.autocorrect(source.buffer, [cop])
         | 
| 185 188 |  | 
| 186 189 | 
             
                  return [] unless team.updated_source_file?
         | 
| @@ -211,7 +214,7 @@ module RuboCop | |
| 211 214 | 
             
                  @cached_run ||=
         | 
| 212 215 | 
             
                    (@options[:cache] == 'true' ||
         | 
| 213 216 | 
             
                     @options[:cache] != 'false' &&
         | 
| 214 | 
            -
                     @config_store. | 
| 217 | 
            +
                     @config_store.for_dir(Dir.pwd).for_all_cops['UseCache']) &&
         | 
| 215 218 | 
             
                    # When running --auto-gen-config, there's some processing done in the
         | 
| 216 219 | 
             
                    # cops related to calculating the Max parameters for Metrics cops. We
         | 
| 217 220 | 
             
                    # need to do that processing and cannot use caching.
         | 
| @@ -291,8 +294,8 @@ module RuboCop | |
| 291 294 | 
             
                end
         | 
| 292 295 |  | 
| 293 296 | 
             
                def inspect_file(processed_source)
         | 
| 294 | 
            -
                  config = @config_store. | 
| 295 | 
            -
                  team = Cop::Team. | 
| 297 | 
            +
                  config = @config_store.for_file(processed_source.path)
         | 
| 298 | 
            +
                  team = Cop::Team.mobilize(mobilized_cop_classes(config), config, @options)
         | 
| 296 299 | 
             
                  offenses = team.inspect_file(processed_source)
         | 
| 297 300 | 
             
                  @errors.concat(team.errors)
         | 
| 298 301 | 
             
                  @warnings.concat(team.warnings)
         | 
| @@ -314,7 +317,7 @@ module RuboCop | |
| 314 317 |  | 
| 315 318 | 
             
                    cop_classes.reject! { |c| c.match?(@options[:except]) }
         | 
| 316 319 |  | 
| 317 | 
            -
                    Cop::Registry.new(cop_classes)
         | 
| 320 | 
            +
                    Cop::Registry.new(cop_classes, @options)
         | 
| 318 321 | 
             
                  end
         | 
| 319 322 | 
             
                end
         | 
| 320 323 |  | 
| @@ -357,12 +360,16 @@ module RuboCop | |
| 357 360 | 
             
                end
         | 
| 358 361 |  | 
| 359 362 | 
             
                def get_processed_source(file)
         | 
| 360 | 
            -
                  ruby_version = @config_store. | 
| 363 | 
            +
                  ruby_version = @config_store.for_file(file).target_ruby_version
         | 
| 361 364 |  | 
| 362 365 | 
             
                  if @options[:stdin]
         | 
| 363 366 | 
             
                    ProcessedSource.new(@options[:stdin], ruby_version, file)
         | 
| 364 367 | 
             
                  else
         | 
| 365 | 
            -
                     | 
| 368 | 
            +
                    begin
         | 
| 369 | 
            +
                      ProcessedSource.from_file(file, ruby_version)
         | 
| 370 | 
            +
                    rescue Errno::ENOENT
         | 
| 371 | 
            +
                      raise RuboCop::Error, "No such file or directory: #{file}"
         | 
| 372 | 
            +
                    end
         | 
| 366 373 | 
             
                  end
         | 
| 367 374 | 
             
                end
         | 
| 368 375 |  | 
| @@ -373,7 +380,7 @@ module RuboCop | |
| 373 380 | 
             
                def standby_team(config)
         | 
| 374 381 | 
             
                  @team_by_config ||= {}
         | 
| 375 382 | 
             
                  @team_by_config[config.object_id] ||=
         | 
| 376 | 
            -
                    Cop::Team. | 
| 383 | 
            +
                    Cop::Team.mobilize(mobilized_cop_classes(config), config, @options)
         | 
| 377 384 | 
             
                end
         | 
| 378 385 | 
             
              end
         | 
| 379 386 | 
             
            end
         | 
| @@ -27,7 +27,7 @@ module RuboCop | |
| 27 27 | 
             
                # (if any). If args is empty, recursively find all Ruby source
         | 
| 28 28 | 
             
                # files under the current directory
         | 
| 29 29 | 
             
                # @return [Array] array of file paths
         | 
| 30 | 
            -
                def find(args)
         | 
| 30 | 
            +
                def find(args, mode)
         | 
| 31 31 | 
             
                  return target_files_in_dir if args.empty?
         | 
| 32 32 |  | 
| 33 33 | 
             
                  files = []
         | 
| @@ -36,7 +36,7 @@ module RuboCop | |
| 36 36 | 
             
                    files += if File.directory?(arg)
         | 
| 37 37 | 
             
                               target_files_in_dir(arg.chomp(File::SEPARATOR))
         | 
| 38 38 | 
             
                             else
         | 
| 39 | 
            -
                               process_explicit_path(arg)
         | 
| 39 | 
            +
                               process_explicit_path(arg, mode)
         | 
| 40 40 | 
             
                             end
         | 
| 41 41 | 
             
                  end
         | 
| 42 42 |  | 
| @@ -54,9 +54,7 @@ module RuboCop | |
| 54 54 | 
             
                # @return [Array] Array of filenames
         | 
| 55 55 | 
             
                def target_files_in_dir(base_dir = Dir.pwd)
         | 
| 56 56 | 
             
                  # Support Windows: Backslashes from command-line -> forward slashes
         | 
| 57 | 
            -
                  if File::ALT_SEPARATOR
         | 
| 58 | 
            -
                    base_dir = base_dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
         | 
| 59 | 
            -
                  end
         | 
| 57 | 
            +
                  base_dir = base_dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
         | 
| 60 58 | 
             
                  all_files = find_files(base_dir, File::FNM_DOTMATCH)
         | 
| 61 59 | 
             
                  hidden_files = Set.new(all_files - find_files(base_dir, 0))
         | 
| 62 60 | 
             
                  base_dir_config = @config_store.for(base_dir)
         | 
| @@ -169,10 +167,12 @@ module RuboCop | |
| 169 167 | 
             
                  ruby_file?(file) || configured_include?(file)
         | 
| 170 168 | 
             
                end
         | 
| 171 169 |  | 
| 172 | 
            -
                def process_explicit_path(path)
         | 
| 170 | 
            +
                def process_explicit_path(path, mode)
         | 
| 173 171 | 
             
                  files = path.include?('*') ? Dir[path] : [path]
         | 
| 174 172 |  | 
| 175 | 
            -
                   | 
| 173 | 
            +
                  if mode == :only_recognized_file_types || force_exclusion?
         | 
| 174 | 
            +
                    files.select! { |file| included_file?(file) }
         | 
| 175 | 
            +
                  end
         | 
| 176 176 |  | 
| 177 177 | 
             
                  return files unless force_exclusion?
         | 
| 178 178 |  | 
    
        data/lib/rubocop/target_ruby.rb
    CHANGED
    
    | @@ -3,11 +3,11 @@ | |
| 3 3 | 
             
            module RuboCop
         | 
| 4 4 | 
             
              # The kind of Ruby that code inspected by RuboCop is written in.
         | 
| 5 5 | 
             
              class TargetRuby
         | 
| 6 | 
            -
                KNOWN_RUBIES = [2. | 
| 6 | 
            +
                KNOWN_RUBIES = [2.4, 2.5, 2.6, 2.7].freeze
         | 
| 7 7 | 
             
                DEFAULT_VERSION = KNOWN_RUBIES.first
         | 
| 8 8 |  | 
| 9 9 | 
             
                OBSOLETE_RUBIES = {
         | 
| 10 | 
            -
                  1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69'
         | 
| 10 | 
            +
                  1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69', 2.3 => '0.81'
         | 
| 11 11 | 
             
                }.freeze
         | 
| 12 12 | 
             
                private_constant :KNOWN_RUBIES, :OBSOLETE_RUBIES
         | 
| 13 13 |  | 
| @@ -52,7 +52,10 @@ module RuboCop | |
| 52 52 | 
             
                    file = ruby_version_file
         | 
| 53 53 | 
             
                    return unless file && File.file?(file)
         | 
| 54 54 |  | 
| 55 | 
            +
                    # rubocop:disable Lint/MixedRegexpCaptureTypes
         | 
| 56 | 
            +
                    # `(ruby-)` is not a capture type.
         | 
| 55 57 | 
             
                    File.read(file).match(/\A(ruby-)?(?<version>\d+\.\d+)/) do |md|
         | 
| 58 | 
            +
                      # rubocop:enable Lint/MixedRegexpCaptureTypes
         | 
| 56 59 | 
             
                      md[:version].to_f
         | 
| 57 60 | 
             
                    end
         | 
| 58 61 | 
             
                  end
         |