rubocop 1.40.0 → 1.42.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.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/config/default.yml +44 -1
- data/lib/rubocop/cli.rb +1 -1
- data/lib/rubocop/config.rb +34 -11
- data/lib/rubocop/config_loader.rb +9 -0
- data/lib/rubocop/config_loader_resolver.rb +5 -1
- data/lib/rubocop/config_validator.rb +1 -1
- data/lib/rubocop/cop/badge.rb +9 -4
- data/lib/rubocop/cop/base.rb +83 -66
- data/lib/rubocop/cop/commissioner.rb +8 -3
- data/lib/rubocop/cop/cop.rb +29 -29
- data/lib/rubocop/cop/corrector.rb +23 -11
- data/lib/rubocop/cop/gemspec/dependency_version.rb +16 -18
- data/lib/rubocop/cop/internal_affairs/cop_description.rb +3 -1
- data/lib/rubocop/cop/layout/class_structure.rb +32 -11
- data/lib/rubocop/cop/layout/comment_indentation.rb +3 -1
- data/lib/rubocop/cop/layout/empty_lines.rb +2 -0
- data/lib/rubocop/cop/layout/extra_spacing.rb +10 -6
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +38 -2
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +49 -2
- data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +61 -2
- data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +52 -2
- data/lib/rubocop/cop/layout/indentation_style.rb +7 -2
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +5 -0
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +11 -5
- data/lib/rubocop/cop/layout/line_length.rb +2 -0
- data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +51 -2
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +49 -2
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +53 -2
- data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +58 -2
- data/lib/rubocop/cop/layout/redundant_line_break.rb +2 -2
- data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_empty_lines.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +11 -4
- data/lib/rubocop/cop/lint/constant_resolution.rb +4 -0
- data/lib/rubocop/cop/lint/debugger.rb +3 -1
- data/lib/rubocop/cop/lint/duplicate_branch.rb +0 -2
- data/lib/rubocop/cop/lint/duplicate_methods.rb +19 -8
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +10 -5
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +19 -0
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +3 -1
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/regexp_as_condition.rb +6 -0
- data/lib/rubocop/cop/lint/require_parentheses.rb +3 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +8 -19
- data/lib/rubocop/cop/lint/unused_method_argument.rb +2 -1
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +5 -3
- data/lib/rubocop/cop/metrics/class_length.rb +1 -1
- data/lib/rubocop/cop/metrics/module_length.rb +1 -1
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +4 -4
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +2 -2
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/allowed_identifiers.rb +2 -2
- data/lib/rubocop/cop/mixin/annotation_comment.rb +13 -6
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +21 -9
- data/lib/rubocop/cop/mixin/first_element_line_break.rb +11 -7
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +5 -1
- data/lib/rubocop/cop/mixin/line_length_help.rb +8 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +5 -3
- data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +5 -3
- data/lib/rubocop/cop/mixin/percent_array.rb +3 -5
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/require_library.rb +2 -0
- data/lib/rubocop/cop/mixin/rescue_node.rb +3 -3
- data/lib/rubocop/cop/mixin/statement_modifier.rb +1 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +1 -1
- data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +2 -0
- data/lib/rubocop/cop/naming/inclusive_language.rb +4 -1
- data/lib/rubocop/cop/registry.rb +28 -25
- data/lib/rubocop/cop/security/compound_hash.rb +2 -1
- data/lib/rubocop/cop/style/alias.rb +9 -1
- data/lib/rubocop/cop/style/block_comments.rb +1 -1
- data/lib/rubocop/cop/style/concat_array_literals.rb +86 -0
- data/lib/rubocop/cop/style/documentation.rb +11 -5
- data/lib/rubocop/cop/style/guard_clause.rb +17 -9
- data/lib/rubocop/cop/style/hash_syntax.rb +10 -7
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +15 -0
- data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -3
- data/lib/rubocop/cop/style/inverse_methods.rb +2 -0
- data/lib/rubocop/cop/style/line_end_concatenation.rb +4 -1
- data/lib/rubocop/cop/style/map_to_set.rb +61 -0
- data/lib/rubocop/cop/style/method_def_parentheses.rb +11 -4
- data/lib/rubocop/cop/style/min_max_comparison.rb +73 -0
- data/lib/rubocop/cop/style/redundant_constant_base.rb +13 -0
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +39 -0
- data/lib/rubocop/cop/style/redundant_string_escape.rb +6 -3
- data/lib/rubocop/cop/style/require_order.rb +63 -9
- data/lib/rubocop/cop/style/select_by_regexp.rb +6 -2
- data/lib/rubocop/cop/style/semicolon.rb +2 -1
- data/lib/rubocop/cop/style/signal_exception.rb +8 -6
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -4
- data/lib/rubocop/cop/style/word_array.rb +41 -0
- data/lib/rubocop/cop/style/yoda_expression.rb +74 -0
- data/lib/rubocop/cop/style/zero_length_predicate.rb +31 -14
- data/lib/rubocop/cop/team.rb +29 -29
- data/lib/rubocop/cop/util.rb +31 -4
- data/lib/rubocop/cop/variable_force.rb +0 -3
- data/lib/rubocop/cops_documentation_generator.rb +33 -11
- data/lib/rubocop/directive_comment.rb +1 -1
- data/lib/rubocop/file_patterns.rb +43 -0
- data/lib/rubocop/formatter.rb +2 -0
- data/lib/rubocop/options.rb +1 -1
- data/lib/rubocop/path_util.rb +26 -15
- data/lib/rubocop/result_cache.rb +1 -1
- data/lib/rubocop/runner.rb +10 -3
- data/lib/rubocop/target_finder.rb +1 -1
- data/lib/rubocop/target_ruby.rb +0 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +6 -1
- metadata +15 -10
- data/lib/rubocop/optimized_patterns.rb +0 -38
@@ -33,7 +33,7 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
33
33
|
cops.with_department(department).sort!
|
34
34
|
end
|
35
35
|
|
36
|
-
def cops_body(cop, description, examples_objects, safety_objects, pars) # rubocop:disable Metrics/AbcSize
|
36
|
+
def cops_body(cop, description, examples_objects, safety_objects, see_objects, pars) # rubocop:disable Metrics/AbcSize, Metrics/ParameterLists
|
37
37
|
check_examples_to_have_the_default_enforced_style!(examples_objects, cop)
|
38
38
|
|
39
39
|
content = h2(cop.cop_name)
|
@@ -42,8 +42,8 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
42
42
|
content << "#{description}\n"
|
43
43
|
content << safety_object(safety_objects) if safety_objects.any? { |s| !s.text.blank? }
|
44
44
|
content << examples(examples_objects) if examples_objects.any?
|
45
|
-
content << configurations(pars)
|
46
|
-
content << references(cop)
|
45
|
+
content << configurations(cop.department, pars)
|
46
|
+
content << references(cop, see_objects)
|
47
47
|
content
|
48
48
|
end
|
49
49
|
|
@@ -136,7 +136,7 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
136
136
|
content
|
137
137
|
end
|
138
138
|
|
139
|
-
def configurations(pars)
|
139
|
+
def configurations(department, pars)
|
140
140
|
return '' if pars.empty?
|
141
141
|
|
142
142
|
header = ['Name', 'Default value', 'Configurable values']
|
@@ -147,12 +147,20 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
147
147
|
content = configs.map do |name|
|
148
148
|
configurable = configurable_values(pars, name)
|
149
149
|
default = format_table_value(pars[name])
|
150
|
-
|
150
|
+
|
151
|
+
[configuration_name(department, name), default, configurable]
|
151
152
|
end
|
152
153
|
|
153
154
|
h3('Configurable attributes') + to_table(header, content)
|
154
155
|
end
|
155
156
|
|
157
|
+
def configuration_name(department, name)
|
158
|
+
return name unless name == 'AllowMultilineFinalElement'
|
159
|
+
|
160
|
+
filename = "#{department_to_basename(department)}.adoc"
|
161
|
+
"xref:#{filename}#allowmultilinefinalelement[AllowMultilineFinalElement]"
|
162
|
+
end
|
163
|
+
|
156
164
|
# rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
|
157
165
|
def configurable_values(pars, name)
|
158
166
|
case name
|
@@ -216,21 +224,34 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
216
224
|
end
|
217
225
|
end
|
218
226
|
|
219
|
-
def references(cop)
|
227
|
+
def references(cop, see_objects) # rubocop:disable Metrics/AbcSize
|
220
228
|
cop_config = config.for_cop(cop)
|
221
229
|
urls = RuboCop::Cop::MessageAnnotator.new(config, cop.name, cop_config, {}).urls
|
222
|
-
return '' if urls.empty?
|
230
|
+
return '' if urls.empty? && see_objects.empty?
|
223
231
|
|
224
232
|
content = h3('References')
|
225
233
|
content << urls.map { |url| "* #{url}" }.join("\n")
|
226
|
-
content << "\n"
|
234
|
+
content << "\n" unless urls.empty?
|
235
|
+
content << see_objects.map { |see| "* #{see.name}" }.join("\n")
|
236
|
+
content << "\n" unless see_objects.empty?
|
227
237
|
content
|
228
238
|
end
|
229
239
|
|
240
|
+
def footer_for_department(department)
|
241
|
+
return '' unless department == :Layout
|
242
|
+
|
243
|
+
filename = "#{department_to_basename(department)}_footer.adoc"
|
244
|
+
file = "#{Dir.pwd}/docs/modules/ROOT/partials/#{filename}"
|
245
|
+
return '' unless File.exist?(file)
|
246
|
+
|
247
|
+
"\ninclude::../partials/#{filename}[]\n"
|
248
|
+
end
|
249
|
+
|
230
250
|
def print_cops_of_department(department)
|
231
251
|
selected_cops = cops_of_department(department)
|
232
252
|
content = +"= #{department}\n"
|
233
253
|
selected_cops.each { |cop| content << print_cop_with_doc(cop) }
|
254
|
+
content << footer_for_department(department)
|
234
255
|
file_name = "#{Dir.pwd}/docs/modules/ROOT/pages/#{department_to_basename(department)}.adoc"
|
235
256
|
File.open(file_name, 'w') do |file|
|
236
257
|
puts "* generated #{file_name}"
|
@@ -238,7 +259,7 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
238
259
|
end
|
239
260
|
end
|
240
261
|
|
241
|
-
def print_cop_with_doc(cop)
|
262
|
+
def print_cop_with_doc(cop) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
242
263
|
cop_config = config.for_cop(cop)
|
243
264
|
non_display_keys = %w[
|
244
265
|
Description Enabled StyleGuide Reference Safe SafeAutoCorrect VersionAdded
|
@@ -246,13 +267,14 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
246
267
|
]
|
247
268
|
pars = cop_config.reject { |k| non_display_keys.include? k }
|
248
269
|
description = 'No documentation'
|
249
|
-
examples_object = safety_object = []
|
270
|
+
examples_object = safety_object = see_object = []
|
250
271
|
cop_code(cop) do |code_object|
|
251
272
|
description = code_object.docstring unless code_object.docstring.blank?
|
252
273
|
examples_object = code_object.tags('example')
|
253
274
|
safety_object = code_object.tags('safety')
|
275
|
+
see_object = code_object.tags('see')
|
254
276
|
end
|
255
|
-
cops_body(cop, description, examples_object, safety_object, pars)
|
277
|
+
cops_body(cop, description, examples_object, safety_object, see_object, pars)
|
256
278
|
end
|
257
279
|
|
258
280
|
def cop_code(cop)
|
@@ -35,7 +35,7 @@ module RuboCop
|
|
35
35
|
|
36
36
|
# Checks if this directive relates to single line
|
37
37
|
def single_line?
|
38
|
-
!
|
38
|
+
!comment.text.start_with?(DIRECTIVE_COMMENT_REGEXP)
|
39
39
|
end
|
40
40
|
|
41
41
|
# Checks if this directive contains all the given cop names
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
# A wrapper around patterns array to perform optimized search.
|
5
|
+
#
|
6
|
+
# For projects with a large set of rubocop todo files, most items in `Exclude`/`Include`
|
7
|
+
# are exact file names. It is wasteful to linearly check the list of patterns over and over
|
8
|
+
# to check if the file is relevant to the cop.
|
9
|
+
#
|
10
|
+
# This class partitions an array of patterns into a set of exact match strings and the rest
|
11
|
+
# of the patterns. This way we can firstly do a cheap check in the set and then proceed via
|
12
|
+
# the costly patterns check, if needed.
|
13
|
+
# @api private
|
14
|
+
class FilePatterns
|
15
|
+
@cache = {}.compare_by_identity
|
16
|
+
|
17
|
+
def self.from(patterns)
|
18
|
+
@cache[patterns] ||= new(patterns)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(patterns)
|
22
|
+
@strings = Set.new
|
23
|
+
@patterns = []
|
24
|
+
partition_patterns(patterns)
|
25
|
+
end
|
26
|
+
|
27
|
+
def match?(path)
|
28
|
+
@strings.include?(path) || @patterns.any? { |pattern| PathUtil.match_path?(pattern, path) }
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def partition_patterns(patterns)
|
34
|
+
patterns.each do |pattern|
|
35
|
+
if pattern.is_a?(String) && !pattern.match?(/[*{\[?]/)
|
36
|
+
@strings << pattern
|
37
|
+
else
|
38
|
+
@patterns << pattern
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/rubocop/formatter.rb
CHANGED
data/lib/rubocop/options.rb
CHANGED
@@ -465,7 +465,7 @@ module RuboCop
|
|
465
465
|
|
466
466
|
# This module contains help texts for command line options.
|
467
467
|
# @api private
|
468
|
-
module OptionsHelp
|
468
|
+
module OptionsHelp
|
469
469
|
MAX_EXCL = RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS.to_s
|
470
470
|
FORMATTER_OPTION_LIST = RuboCop::Formatter::FormatterSet::BUILTIN_FORMATTERS_FOR_KEYS.keys
|
471
471
|
|
data/lib/rubocop/path_util.rb
CHANGED
@@ -3,23 +3,29 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# Common methods and behaviors for dealing with paths.
|
5
5
|
module PathUtil
|
6
|
+
class << self
|
7
|
+
attr_accessor :relative_paths_cache
|
8
|
+
end
|
9
|
+
self.relative_paths_cache = Hash.new { |hash, key| hash[key] = {} }
|
10
|
+
|
6
11
|
module_function
|
7
12
|
|
8
13
|
def relative_path(path, base_dir = Dir.pwd)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
PathUtil.relative_paths_cache[base_dir][path] ||=
|
15
|
+
# Optimization for the common case where path begins with the base
|
16
|
+
# dir. Just cut off the first part.
|
17
|
+
if path.start_with?(base_dir)
|
18
|
+
base_dir_length = base_dir.length
|
19
|
+
result_length = path.length - base_dir_length - 1
|
20
|
+
path[base_dir_length + 1, result_length]
|
21
|
+
else
|
22
|
+
path_name = Pathname.new(File.expand_path(path))
|
23
|
+
begin
|
24
|
+
path_name.relative_path_from(Pathname.new(base_dir)).to_s
|
25
|
+
rescue ArgumentError
|
26
|
+
path
|
27
|
+
end
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
def smart_path(path)
|
@@ -40,7 +46,7 @@ module RuboCop
|
|
40
46
|
matches =
|
41
47
|
if pattern == path
|
42
48
|
true
|
43
|
-
elsif
|
49
|
+
elsif glob?(pattern)
|
44
50
|
File.fnmatch?(pattern, path, File::FNM_PATHNAME | File::FNM_EXTGLOB)
|
45
51
|
end
|
46
52
|
|
@@ -62,6 +68,11 @@ module RuboCop
|
|
62
68
|
%r{\A([A-Z]:)?/}i.match?(path)
|
63
69
|
end
|
64
70
|
|
71
|
+
# Returns true for a glob
|
72
|
+
def glob?(path)
|
73
|
+
path.match?(/[*{\[?]/)
|
74
|
+
end
|
75
|
+
|
65
76
|
def hidden_file_in_not_hidden_dir?(pattern, path)
|
66
77
|
hidden_file?(path) &&
|
67
78
|
File.fnmatch?(
|
data/lib/rubocop/result_cache.rb
CHANGED
@@ -53,7 +53,7 @@ module RuboCop
|
|
53
53
|
def remove_oldest_files(files, dirs, cache_root, verbose)
|
54
54
|
# Add 1 to half the number of files, so that we remove the file if
|
55
55
|
# there's only 1 left.
|
56
|
-
remove_count =
|
56
|
+
remove_count = (files.length / 2) + 1
|
57
57
|
puts "Removing the #{remove_count} oldest files from #{cache_root}" if verbose
|
58
58
|
sorted = files.sort_by { |path| File.mtime(path) }
|
59
59
|
remove_files(sorted, dirs, remove_count)
|
data/lib/rubocop/runner.rb
CHANGED
@@ -27,6 +27,11 @@ module RuboCop
|
|
27
27
|
# @api private
|
28
28
|
MAX_ITERATIONS = 200
|
29
29
|
|
30
|
+
# @api private
|
31
|
+
REDUNDANT_COP_DISABLE_DIRECTIVE_RULES = %w[
|
32
|
+
Lint/RedundantCopDisableDirective RedundantCopDisableDirective Lint
|
33
|
+
].freeze
|
34
|
+
|
30
35
|
attr_reader :errors, :warnings
|
31
36
|
attr_writer :aborting
|
32
37
|
|
@@ -194,7 +199,9 @@ module RuboCop
|
|
194
199
|
end
|
195
200
|
|
196
201
|
def check_for_redundant_disables?(source)
|
197
|
-
|
202
|
+
return false if source.disabled_line_ranges.empty? || except_redundant_cop_disable_directive?
|
203
|
+
|
204
|
+
!@options[:only]
|
198
205
|
end
|
199
206
|
|
200
207
|
def redundant_cop_disable_directive(file)
|
@@ -205,8 +212,8 @@ module RuboCop
|
|
205
212
|
yield cop if cop.relevant_file?(file)
|
206
213
|
end
|
207
214
|
|
208
|
-
def
|
209
|
-
@options[:except]
|
215
|
+
def except_redundant_cop_disable_directive?
|
216
|
+
@options[:except] && (@options[:except] & REDUNDANT_COP_DISABLE_DIRECTIVE_RULES).any?
|
210
217
|
end
|
211
218
|
|
212
219
|
def file_started(file)
|
@@ -88,7 +88,7 @@ module RuboCop
|
|
88
88
|
patterns.map! { |dir| File.join(dir, '*') }
|
89
89
|
# We need this special case to avoid creating the pattern
|
90
90
|
# /**/* which searches the entire file system.
|
91
|
-
patterns = [File.join(
|
91
|
+
patterns = [File.join(base_dir, '**/*')] if patterns.empty?
|
92
92
|
|
93
93
|
Dir.glob(patterns, flags).select { |path| FileTest.file?(path) }
|
94
94
|
end
|
data/lib/rubocop/target_ruby.rb
CHANGED
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -23,8 +23,8 @@ require_relative 'rubocop/ext/processed_source'
|
|
23
23
|
|
24
24
|
require_relative 'rubocop/error'
|
25
25
|
require_relative 'rubocop/file_finder'
|
26
|
+
require_relative 'rubocop/file_patterns'
|
26
27
|
require_relative 'rubocop/name_similarity'
|
27
|
-
require_relative 'rubocop/optimized_patterns'
|
28
28
|
require_relative 'rubocop/path_util'
|
29
29
|
require_relative 'rubocop/platform'
|
30
30
|
require_relative 'rubocop/string_interpreter'
|
@@ -470,6 +470,7 @@ require_relative 'rubocop/cop/style/combinable_loops'
|
|
470
470
|
require_relative 'rubocop/cop/style/command_literal'
|
471
471
|
require_relative 'rubocop/cop/style/comment_annotation'
|
472
472
|
require_relative 'rubocop/cop/style/commented_keyword'
|
473
|
+
require_relative 'rubocop/cop/style/concat_array_literals'
|
473
474
|
require_relative 'rubocop/cop/style/conditional_assignment'
|
474
475
|
require_relative 'rubocop/cop/style/constant_visibility'
|
475
476
|
require_relative 'rubocop/cop/style/copyright'
|
@@ -537,14 +538,17 @@ require_relative 'rubocop/cop/style/lambda_call'
|
|
537
538
|
require_relative 'rubocop/cop/style/line_end_concatenation'
|
538
539
|
require_relative 'rubocop/cop/style/magic_comment_format'
|
539
540
|
require_relative 'rubocop/cop/style/map_to_hash'
|
541
|
+
require_relative 'rubocop/cop/style/map_to_set'
|
540
542
|
require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
|
541
543
|
require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
|
544
|
+
require_relative 'rubocop/cop/style/min_max_comparison'
|
542
545
|
require_relative 'rubocop/cop/style/multiline_in_pattern_then'
|
543
546
|
require_relative 'rubocop/cop/style/numbered_parameters'
|
544
547
|
require_relative 'rubocop/cop/style/open_struct_use'
|
545
548
|
require_relative 'rubocop/cop/style/operator_method_call'
|
546
549
|
require_relative 'rubocop/cop/style/redundant_assignment'
|
547
550
|
require_relative 'rubocop/cop/style/redundant_constant_base'
|
551
|
+
require_relative 'rubocop/cop/style/redundant_double_splat_hash_braces'
|
548
552
|
require_relative 'rubocop/cop/style/redundant_each'
|
549
553
|
require_relative 'rubocop/cop/style/redundant_fetch_block'
|
550
554
|
require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
|
@@ -673,6 +677,7 @@ require_relative 'rubocop/cop/style/while_until_do'
|
|
673
677
|
require_relative 'rubocop/cop/style/while_until_modifier'
|
674
678
|
require_relative 'rubocop/cop/style/word_array'
|
675
679
|
require_relative 'rubocop/cop/style/yoda_condition'
|
680
|
+
require_relative 'rubocop/cop/style/yoda_expression'
|
676
681
|
require_relative 'rubocop/cop/style/zero_length_predicate'
|
677
682
|
|
678
683
|
require_relative 'rubocop/cop/security/compound_hash'
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.42.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
8
8
|
- Jonas Arvidsson
|
9
9
|
- Yuji Nakayama
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - ">="
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 1.
|
123
|
+
version: 1.24.1
|
124
124
|
- - "<"
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '2.0'
|
@@ -130,7 +130,7 @@ dependencies:
|
|
130
130
|
requirements:
|
131
131
|
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 1.
|
133
|
+
version: 1.24.1
|
134
134
|
- - "<"
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '2.0'
|
@@ -691,6 +691,7 @@ files:
|
|
691
691
|
- lib/rubocop/cop/style/command_literal.rb
|
692
692
|
- lib/rubocop/cop/style/comment_annotation.rb
|
693
693
|
- lib/rubocop/cop/style/commented_keyword.rb
|
694
|
+
- lib/rubocop/cop/style/concat_array_literals.rb
|
694
695
|
- lib/rubocop/cop/style/conditional_assignment.rb
|
695
696
|
- lib/rubocop/cop/style/constant_visibility.rb
|
696
697
|
- lib/rubocop/cop/style/copyright.rb
|
@@ -759,6 +760,7 @@ files:
|
|
759
760
|
- lib/rubocop/cop/style/magic_comment_format.rb
|
760
761
|
- lib/rubocop/cop/style/map_compact_with_conditional_block.rb
|
761
762
|
- lib/rubocop/cop/style/map_to_hash.rb
|
763
|
+
- lib/rubocop/cop/style/map_to_set.rb
|
762
764
|
- lib/rubocop/cop/style/method_call_with_args_parentheses.rb
|
763
765
|
- lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb
|
764
766
|
- lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb
|
@@ -766,6 +768,7 @@ files:
|
|
766
768
|
- lib/rubocop/cop/style/method_called_on_do_end_block.rb
|
767
769
|
- lib/rubocop/cop/style/method_def_parentheses.rb
|
768
770
|
- lib/rubocop/cop/style/min_max.rb
|
771
|
+
- lib/rubocop/cop/style/min_max_comparison.rb
|
769
772
|
- lib/rubocop/cop/style/missing_else.rb
|
770
773
|
- lib/rubocop/cop/style/missing_respond_to_missing.rb
|
771
774
|
- lib/rubocop/cop/style/mixin_grouping.rb
|
@@ -824,6 +827,7 @@ files:
|
|
824
827
|
- lib/rubocop/cop/style/redundant_condition.rb
|
825
828
|
- lib/rubocop/cop/style/redundant_conditional.rb
|
826
829
|
- lib/rubocop/cop/style/redundant_constant_base.rb
|
830
|
+
- lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb
|
827
831
|
- lib/rubocop/cop/style/redundant_each.rb
|
828
832
|
- lib/rubocop/cop/style/redundant_exception.rb
|
829
833
|
- lib/rubocop/cop/style/redundant_fetch_block.rb
|
@@ -896,6 +900,7 @@ files:
|
|
896
900
|
- lib/rubocop/cop/style/while_until_modifier.rb
|
897
901
|
- lib/rubocop/cop/style/word_array.rb
|
898
902
|
- lib/rubocop/cop/style/yoda_condition.rb
|
903
|
+
- lib/rubocop/cop/style/yoda_expression.rb
|
899
904
|
- lib/rubocop/cop/style/zero_length_predicate.rb
|
900
905
|
- lib/rubocop/cop/team.rb
|
901
906
|
- lib/rubocop/cop/util.rb
|
@@ -918,6 +923,7 @@ files:
|
|
918
923
|
- lib/rubocop/ext/regexp_parser.rb
|
919
924
|
- lib/rubocop/feature_loader.rb
|
920
925
|
- lib/rubocop/file_finder.rb
|
926
|
+
- lib/rubocop/file_patterns.rb
|
921
927
|
- lib/rubocop/formatter.rb
|
922
928
|
- lib/rubocop/formatter/auto_gen_config_formatter.rb
|
923
929
|
- lib/rubocop/formatter/base_formatter.rb
|
@@ -944,7 +950,6 @@ files:
|
|
944
950
|
- lib/rubocop/lockfile.rb
|
945
951
|
- lib/rubocop/magic_comment.rb
|
946
952
|
- lib/rubocop/name_similarity.rb
|
947
|
-
- lib/rubocop/optimized_patterns.rb
|
948
953
|
- lib/rubocop/options.rb
|
949
954
|
- lib/rubocop/path_util.rb
|
950
955
|
- lib/rubocop/platform.rb
|
@@ -990,10 +995,10 @@ metadata:
|
|
990
995
|
homepage_uri: https://rubocop.org/
|
991
996
|
changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
|
992
997
|
source_code_uri: https://github.com/rubocop/rubocop/
|
993
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
998
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.42/
|
994
999
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
995
1000
|
rubygems_mfa_required: 'true'
|
996
|
-
post_install_message:
|
1001
|
+
post_install_message:
|
997
1002
|
rdoc_options: []
|
998
1003
|
require_paths:
|
999
1004
|
- lib
|
@@ -1008,8 +1013,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1008
1013
|
- !ruby/object:Gem::Version
|
1009
1014
|
version: '0'
|
1010
1015
|
requirements: []
|
1011
|
-
rubygems_version: 3.
|
1012
|
-
signing_key:
|
1016
|
+
rubygems_version: 3.3.7
|
1017
|
+
signing_key:
|
1013
1018
|
specification_version: 4
|
1014
1019
|
summary: Automatic Ruby code style checking tool.
|
1015
1020
|
test_files: []
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
# @api private
|
5
|
-
module OptimizedPatterns
|
6
|
-
# A wrapper around patterns array to perform optimized search.
|
7
|
-
# @api private
|
8
|
-
class PatternsSet
|
9
|
-
def initialize(patterns)
|
10
|
-
@strings = Set.new
|
11
|
-
@patterns = []
|
12
|
-
partition_patterns(patterns)
|
13
|
-
end
|
14
|
-
|
15
|
-
def match?(path)
|
16
|
-
@strings.include?(path) || @patterns.any? { |pattern| PathUtil.match_path?(pattern, path) }
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def partition_patterns(patterns)
|
22
|
-
patterns.each do |pattern|
|
23
|
-
if pattern.is_a?(String) && !pattern.match?(/[*{\[?]/)
|
24
|
-
@strings << pattern
|
25
|
-
else
|
26
|
-
@patterns << pattern
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
@cache = {}.compare_by_identity
|
33
|
-
|
34
|
-
def self.from(patterns)
|
35
|
-
@cache[patterns] ||= PatternsSet.new(patterns)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|