rubocop 1.82.0 → 1.84.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 +1 -1
- data/config/default.yml +44 -0
- data/lib/rubocop/cli/command/lsp.rb +1 -1
- data/lib/rubocop/cli.rb +2 -1
- data/lib/rubocop/comment_config.rb +1 -0
- data/lib/rubocop/cop/autocorrect_logic.rb +2 -0
- data/lib/rubocop/cop/bundler/gem_version.rb +28 -28
- data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -2
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +20 -2
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -2
- data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +8 -8
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +9 -9
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +4 -4
- data/lib/rubocop/cop/layout/case_indentation.rb +3 -1
- data/lib/rubocop/cop/layout/class_structure.rb +12 -5
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +32 -1
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +26 -0
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +25 -25
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +35 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +111 -7
- data/lib/rubocop/cop/layout/line_length.rb +6 -2
- data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +57 -57
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +2 -0
- data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +56 -56
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +5 -1
- data/lib/rubocop/cop/layout/space_after_comma.rb +2 -10
- data/lib/rubocop/cop/layout/space_after_semicolon.rb +1 -1
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +8 -8
- data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +4 -4
- data/lib/rubocop/cop/lint/duplicate_methods.rb +57 -5
- data/lib/rubocop/cop/lint/float_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/struct_new_override.rb +17 -1
- data/lib/rubocop/cop/lint/to_json.rb +12 -16
- data/lib/rubocop/cop/lint/useless_assignment.rb +44 -16
- data/lib/rubocop/cop/lint/useless_or.rb +1 -1
- data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +1 -1
- data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +2 -0
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +4 -4
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +5 -4
- data/lib/rubocop/cop/mixin/trailing_comma.rb +5 -1
- data/lib/rubocop/cop/naming/predicate_prefix.rb +11 -11
- data/lib/rubocop/cop/offense.rb +2 -1
- data/lib/rubocop/cop/security/json_load.rb +1 -1
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -2
- data/lib/rubocop/cop/style/documentation.rb +6 -6
- data/lib/rubocop/cop/style/documentation_method.rb +8 -8
- data/lib/rubocop/cop/style/empty_class_definition.rb +144 -0
- data/lib/rubocop/cop/style/guard_clause.rb +7 -4
- data/lib/rubocop/cop/style/hash_lookup_method.rb +94 -0
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +12 -12
- data/lib/rubocop/cop/style/lambda_call.rb +8 -8
- data/lib/rubocop/cop/style/module_member_existence_check.rb +56 -13
- data/lib/rubocop/cop/style/multiline_method_signature.rb +2 -0
- data/lib/rubocop/cop/style/negative_array_index.rb +218 -0
- data/lib/rubocop/cop/style/operator_method_call.rb +11 -2
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +12 -12
- data/lib/rubocop/cop/style/redundant_condition.rb +1 -1
- data/lib/rubocop/cop/style/reverse_find.rb +51 -0
- data/lib/rubocop/cop/team.rb +3 -3
- data/lib/rubocop/cop/variable_force/branch.rb +28 -4
- data/lib/rubocop/formatter/clang_style_formatter.rb +5 -2
- data/lib/rubocop/formatter/formatter_set.rb +1 -1
- data/lib/rubocop/formatter/tap_formatter.rb +5 -2
- data/lib/rubocop/remote_config.rb +5 -2
- data/lib/rubocop/result_cache.rb +38 -27
- data/lib/rubocop/rspec/shared_contexts.rb +4 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/runner.rb +4 -0
- data/lib/rubocop/target_ruby.rb +3 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +4 -0
- metadata +11 -7
data/lib/rubocop/result_cache.rb
CHANGED
|
@@ -22,7 +22,7 @@ module RuboCop
|
|
|
22
22
|
# Remove old files so that the cache doesn't grow too big. When the
|
|
23
23
|
# threshold MaxFilesInCache has been exceeded, the oldest 50% of all the
|
|
24
24
|
# files in the cache are removed. The reason for removing so much is that
|
|
25
|
-
#
|
|
25
|
+
# removing should be done relatively seldom, since there is a slight risk
|
|
26
26
|
# that some other RuboCop process was just about to read the file, when
|
|
27
27
|
# there's parallel execution and the cache is shared.
|
|
28
28
|
def self.cleanup(config_store, verbose, cache_root_override = nil)
|
|
@@ -31,10 +31,12 @@ module RuboCop
|
|
|
31
31
|
rubocop_cache_dir = cache_root(config_store, cache_root_override)
|
|
32
32
|
return unless File.exist?(rubocop_cache_dir)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
# We know the cache entries are 3 level deep, so globing
|
|
35
|
+
# for `*/*/*` only returns files.
|
|
36
|
+
files = Dir[File.join(rubocop_cache_dir, '*/*/*')]
|
|
35
37
|
return unless requires_file_removal?(files.length, config_store)
|
|
36
38
|
|
|
37
|
-
remove_oldest_files(files,
|
|
39
|
+
remove_oldest_files(files, rubocop_cache_dir, verbose)
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
class << self
|
|
@@ -49,26 +51,36 @@ module RuboCop
|
|
|
49
51
|
file_count > 1 && file_count > config_store.for_pwd.for_all_cops['MaxFilesInCache']
|
|
50
52
|
end
|
|
51
53
|
|
|
52
|
-
def remove_oldest_files(files,
|
|
54
|
+
def remove_oldest_files(files, rubocop_cache_dir, verbose)
|
|
53
55
|
# Add 1 to half the number of files, so that we remove the file if
|
|
54
56
|
# there's only 1 left.
|
|
55
57
|
remove_count = (files.length / 2) + 1
|
|
56
58
|
puts "Removing the #{remove_count} oldest files from #{rubocop_cache_dir}" if verbose
|
|
57
59
|
sorted = files.sort_by { |path| File.mtime(path) }
|
|
58
|
-
remove_files(sorted,
|
|
60
|
+
remove_files(sorted, remove_count)
|
|
59
61
|
rescue Errno::ENOENT
|
|
60
62
|
# This can happen if parallel RuboCop invocations try to remove the
|
|
61
63
|
# same files. No problem.
|
|
62
64
|
puts $ERROR_INFO if verbose
|
|
63
65
|
end
|
|
64
66
|
|
|
65
|
-
def remove_files(files,
|
|
67
|
+
def remove_files(files, remove_count)
|
|
66
68
|
# Batch file deletions, deleting over 130,000+ files will crash
|
|
67
69
|
# File.delete.
|
|
68
70
|
files[0, remove_count].each_slice(10_000).each do |files_slice|
|
|
69
71
|
File.delete(*files_slice)
|
|
70
72
|
end
|
|
71
|
-
|
|
73
|
+
|
|
74
|
+
dirs = files.map { |f| File.dirname(f) }.uniq
|
|
75
|
+
until dirs.empty?
|
|
76
|
+
dirs.select! do |dir|
|
|
77
|
+
Dir.rmdir(dir)
|
|
78
|
+
true
|
|
79
|
+
rescue SystemCallError # ENOTEMPTY etc
|
|
80
|
+
false
|
|
81
|
+
end
|
|
82
|
+
dirs = dirs.map { |f| File.dirname(f) }.uniq
|
|
83
|
+
end
|
|
72
84
|
end
|
|
73
85
|
end
|
|
74
86
|
|
|
@@ -90,7 +102,7 @@ module RuboCop
|
|
|
90
102
|
@allow_symlinks_in_cache_location =
|
|
91
103
|
ResultCache.allow_symlinks_in_cache_location?(config_store)
|
|
92
104
|
@path = File.join(rubocop_cache_dir,
|
|
93
|
-
|
|
105
|
+
self.class.source_checksum,
|
|
94
106
|
context_checksum(team, options),
|
|
95
107
|
file_checksum(file, config_store))
|
|
96
108
|
@cached_data = CachedData.new(file)
|
|
@@ -167,13 +179,11 @@ module RuboCop
|
|
|
167
179
|
end
|
|
168
180
|
|
|
169
181
|
class << self
|
|
170
|
-
attr_accessor :
|
|
171
|
-
end
|
|
182
|
+
attr_accessor :inhibit_cleanup
|
|
172
183
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
begin
|
|
184
|
+
# The checksum of the RuboCop program running the inspection.
|
|
185
|
+
def source_checksum
|
|
186
|
+
@source_checksum ||= begin
|
|
177
187
|
digest = Digest::SHA1.new
|
|
178
188
|
rubocop_extra_features
|
|
179
189
|
.select { |path| File.file?(path) }
|
|
@@ -184,21 +194,22 @@ module RuboCop
|
|
|
184
194
|
digest << RuboCop::Version::STRING << RuboCop::AST::Version::STRING
|
|
185
195
|
digest.hexdigest
|
|
186
196
|
end
|
|
187
|
-
|
|
197
|
+
end
|
|
188
198
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
+
private
|
|
200
|
+
|
|
201
|
+
def digest(path)
|
|
202
|
+
content = if path.end_with?(*DL_EXTENSIONS)
|
|
203
|
+
# Shared libraries often contain timestamps of when
|
|
204
|
+
# they were compiled and other non-stable data.
|
|
205
|
+
File.basename(path)
|
|
206
|
+
else
|
|
207
|
+
File.binread(path) # mtime not reliable
|
|
208
|
+
end
|
|
209
|
+
Zlib.crc32(content).to_s
|
|
210
|
+
end
|
|
199
211
|
|
|
200
|
-
|
|
201
|
-
@rubocop_extra_features ||= begin
|
|
212
|
+
def rubocop_extra_features
|
|
202
213
|
lib_root = File.join(File.dirname(__FILE__), '..')
|
|
203
214
|
exe_root = File.join(lib_root, '..', 'exe')
|
|
204
215
|
|
data/lib/rubocop/runner.rb
CHANGED
|
@@ -65,6 +65,10 @@ module RuboCop
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def run(paths)
|
|
68
|
+
# Compute the cache source checksum once to avoid potential
|
|
69
|
+
# inconsistencies between workers.
|
|
70
|
+
ResultCache.source_checksum
|
|
71
|
+
|
|
68
72
|
target_files = find_target_files(paths)
|
|
69
73
|
if @options[:list_target_files]
|
|
70
74
|
list_files(target_files)
|
data/lib/rubocop/target_ruby.rb
CHANGED
|
@@ -4,7 +4,9 @@ module RuboCop
|
|
|
4
4
|
# The kind of Ruby that code inspected by RuboCop is written in.
|
|
5
5
|
# @api private
|
|
6
6
|
class TargetRuby
|
|
7
|
-
KNOWN_RUBIES = [
|
|
7
|
+
KNOWN_RUBIES = [
|
|
8
|
+
2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 4.0, 4.1
|
|
9
|
+
].freeze
|
|
8
10
|
DEFAULT_VERSION = 2.7
|
|
9
11
|
|
|
10
12
|
OBSOLETE_RUBIES = {
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
|
@@ -541,6 +541,7 @@ require_relative 'rubocop/cop/style/each_for_simple_loop'
|
|
|
541
541
|
require_relative 'rubocop/cop/style/each_with_object'
|
|
542
542
|
require_relative 'rubocop/cop/style/empty_block_parameter'
|
|
543
543
|
require_relative 'rubocop/cop/style/empty_case_condition'
|
|
544
|
+
require_relative 'rubocop/cop/style/empty_class_definition'
|
|
544
545
|
require_relative 'rubocop/cop/style/empty_else'
|
|
545
546
|
require_relative 'rubocop/cop/style/empty_heredoc'
|
|
546
547
|
require_relative 'rubocop/cop/style/empty_lambda_parameter'
|
|
@@ -577,6 +578,7 @@ require_relative 'rubocop/cop/style/hash_each_methods'
|
|
|
577
578
|
require_relative 'rubocop/cop/style/hash_except'
|
|
578
579
|
require_relative 'rubocop/cop/style/hash_fetch_chain'
|
|
579
580
|
require_relative 'rubocop/cop/style/hash_like_case'
|
|
581
|
+
require_relative 'rubocop/cop/style/hash_lookup_method'
|
|
580
582
|
require_relative 'rubocop/cop/style/hash_slice'
|
|
581
583
|
require_relative 'rubocop/cop/style/hash_syntax'
|
|
582
584
|
require_relative 'rubocop/cop/style/hash_transform_keys'
|
|
@@ -633,6 +635,7 @@ require_relative 'rubocop/cop/style/redundant_regexp_constructor'
|
|
|
633
635
|
require_relative 'rubocop/cop/style/redundant_self_assignment'
|
|
634
636
|
require_relative 'rubocop/cop/style/redundant_self_assignment_branch'
|
|
635
637
|
require_relative 'rubocop/cop/style/require_order'
|
|
638
|
+
require_relative 'rubocop/cop/style/reverse_find'
|
|
636
639
|
require_relative 'rubocop/cop/style/safe_navigation_chain_length'
|
|
637
640
|
require_relative 'rubocop/cop/style/single_line_do_end_block'
|
|
638
641
|
require_relative 'rubocop/cop/style/sole_nested_conditional'
|
|
@@ -659,6 +662,7 @@ require_relative 'rubocop/cop/style/negated_if'
|
|
|
659
662
|
require_relative 'rubocop/cop/style/negated_if_else_condition'
|
|
660
663
|
require_relative 'rubocop/cop/style/negated_unless'
|
|
661
664
|
require_relative 'rubocop/cop/style/negated_while'
|
|
665
|
+
require_relative 'rubocop/cop/style/negative_array_index'
|
|
662
666
|
require_relative 'rubocop/cop/style/nested_file_dirname'
|
|
663
667
|
require_relative 'rubocop/cop/style/nested_modifier'
|
|
664
668
|
require_relative 'rubocop/cop/style/nested_parenthesized_calls'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.84.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bozhidar Batsov
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
- Yuji Nakayama
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: json
|
|
@@ -127,7 +127,7 @@ dependencies:
|
|
|
127
127
|
requirements:
|
|
128
128
|
- - ">="
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: 1.
|
|
130
|
+
version: 1.49.0
|
|
131
131
|
- - "<"
|
|
132
132
|
- !ruby/object:Gem::Version
|
|
133
133
|
version: '2.0'
|
|
@@ -137,7 +137,7 @@ dependencies:
|
|
|
137
137
|
requirements:
|
|
138
138
|
- - ">="
|
|
139
139
|
- !ruby/object:Gem::Version
|
|
140
|
-
version: 1.
|
|
140
|
+
version: 1.49.0
|
|
141
141
|
- - "<"
|
|
142
142
|
- !ruby/object:Gem::Version
|
|
143
143
|
version: '2.0'
|
|
@@ -761,6 +761,7 @@ files:
|
|
|
761
761
|
- lib/rubocop/cop/style/each_with_object.rb
|
|
762
762
|
- lib/rubocop/cop/style/empty_block_parameter.rb
|
|
763
763
|
- lib/rubocop/cop/style/empty_case_condition.rb
|
|
764
|
+
- lib/rubocop/cop/style/empty_class_definition.rb
|
|
764
765
|
- lib/rubocop/cop/style/empty_else.rb
|
|
765
766
|
- lib/rubocop/cop/style/empty_heredoc.rb
|
|
766
767
|
- lib/rubocop/cop/style/empty_lambda_parameter.rb
|
|
@@ -797,6 +798,7 @@ files:
|
|
|
797
798
|
- lib/rubocop/cop/style/hash_except.rb
|
|
798
799
|
- lib/rubocop/cop/style/hash_fetch_chain.rb
|
|
799
800
|
- lib/rubocop/cop/style/hash_like_case.rb
|
|
801
|
+
- lib/rubocop/cop/style/hash_lookup_method.rb
|
|
800
802
|
- lib/rubocop/cop/style/hash_slice.rb
|
|
801
803
|
- lib/rubocop/cop/style/hash_syntax.rb
|
|
802
804
|
- lib/rubocop/cop/style/hash_transform_keys.rb
|
|
@@ -854,6 +856,7 @@ files:
|
|
|
854
856
|
- lib/rubocop/cop/style/negated_if_else_condition.rb
|
|
855
857
|
- lib/rubocop/cop/style/negated_unless.rb
|
|
856
858
|
- lib/rubocop/cop/style/negated_while.rb
|
|
859
|
+
- lib/rubocop/cop/style/negative_array_index.rb
|
|
857
860
|
- lib/rubocop/cop/style/nested_file_dirname.rb
|
|
858
861
|
- lib/rubocop/cop/style/nested_modifier.rb
|
|
859
862
|
- lib/rubocop/cop/style/nested_parenthesized_calls.rb
|
|
@@ -928,6 +931,7 @@ files:
|
|
|
928
931
|
- lib/rubocop/cop/style/rescue_standard_error.rb
|
|
929
932
|
- lib/rubocop/cop/style/return_nil.rb
|
|
930
933
|
- lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb
|
|
934
|
+
- lib/rubocop/cop/style/reverse_find.rb
|
|
931
935
|
- lib/rubocop/cop/style/safe_navigation.rb
|
|
932
936
|
- lib/rubocop/cop/style/safe_navigation_chain_length.rb
|
|
933
937
|
- lib/rubocop/cop/style/sample.rb
|
|
@@ -1092,9 +1096,9 @@ licenses:
|
|
|
1092
1096
|
- MIT
|
|
1093
1097
|
metadata:
|
|
1094
1098
|
homepage_uri: https://rubocop.org/
|
|
1095
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
|
1099
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.84.0
|
|
1096
1100
|
source_code_uri: https://github.com/rubocop/rubocop/
|
|
1097
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
|
1101
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.84/
|
|
1098
1102
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
|
1099
1103
|
rubygems_mfa_required: 'true'
|
|
1100
1104
|
rdoc_options: []
|
|
@@ -1111,7 +1115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1111
1115
|
- !ruby/object:Gem::Version
|
|
1112
1116
|
version: '0'
|
|
1113
1117
|
requirements: []
|
|
1114
|
-
rubygems_version: 3.6.
|
|
1118
|
+
rubygems_version: 3.6.9
|
|
1115
1119
|
specification_version: 4
|
|
1116
1120
|
summary: Automatic Ruby code style checking tool.
|
|
1117
1121
|
test_files: []
|