rubocop 1.31.1 → 1.33.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/README.md +2 -2
- data/config/default.yml +68 -16
- data/config/obsoletion.yml +23 -1
- data/lib/rubocop/cache_config.rb +29 -0
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +2 -2
- data/lib/rubocop/cli/command/init_dotfile.rb +1 -1
- data/lib/rubocop/cli.rb +1 -0
- data/lib/rubocop/config.rb +1 -1
- data/lib/rubocop/config_finder.rb +68 -0
- data/lib/rubocop/config_loader.rb +5 -45
- data/lib/rubocop/config_loader_resolver.rb +1 -1
- data/lib/rubocop/config_obsoletion/changed_parameter.rb +5 -0
- data/lib/rubocop/config_obsoletion/parameter_rule.rb +4 -0
- data/lib/rubocop/config_obsoletion.rb +7 -2
- data/lib/rubocop/cop/base.rb +1 -1
- data/lib/rubocop/cop/generator.rb +4 -0
- data/lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb +60 -0
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/block_end_newline.rb +32 -5
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +6 -1
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +4 -3
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +3 -3
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +57 -13
- data/lib/rubocop/cop/layout/line_length.rb +2 -0
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +4 -1
- data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +45 -0
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +26 -6
- data/lib/rubocop/cop/lint/debugger.rb +11 -1
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +10 -4
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +60 -1
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +60 -25
- data/lib/rubocop/cop/lint/number_conversion.rb +28 -6
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +7 -0
- data/lib/rubocop/cop/lint/require_range_parentheses.rb +57 -0
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +35 -1
- data/lib/rubocop/cop/metrics/abc_size.rb +3 -1
- data/lib/rubocop/cop/metrics/block_length.rb +6 -6
- data/lib/rubocop/cop/metrics/method_length.rb +8 -7
- data/lib/rubocop/cop/mixin/allowed_methods.rb +15 -1
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +9 -1
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +4 -0
- data/lib/rubocop/cop/mixin/comments_help.rb +5 -1
- data/lib/rubocop/cop/mixin/def_node.rb +2 -7
- data/lib/rubocop/cop/mixin/method_complexity.rb +4 -9
- data/lib/rubocop/cop/mixin/multiline_element_indentation.rb +6 -13
- data/lib/rubocop/cop/mixin/percent_array.rb +60 -1
- data/lib/rubocop/cop/naming/predicate_name.rb +30 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +26 -7
- data/lib/rubocop/cop/style/class_and_module_children.rb +4 -4
- data/lib/rubocop/cop/style/class_equality_comparison.rb +50 -3
- data/lib/rubocop/cop/style/empty_else.rb +37 -0
- data/lib/rubocop/cop/style/empty_heredoc.rb +73 -0
- data/lib/rubocop/cop/style/fetch_env_var.rb +10 -177
- data/lib/rubocop/cop/style/format_string_token.rb +25 -6
- data/lib/rubocop/cop/style/hash_except.rb +0 -4
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +2 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +5 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -7
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +19 -2
- data/lib/rubocop/cop/style/module_function.rb +2 -2
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +9 -0
- data/lib/rubocop/cop/style/numeric_predicate.rb +43 -9
- data/lib/rubocop/cop/style/redundant_condition.rb +19 -4
- data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -1
- data/lib/rubocop/cop/style/redundant_sort.rb +21 -6
- data/lib/rubocop/cop/style/semicolon.rb +27 -3
- data/lib/rubocop/cop/style/symbol_array.rb +2 -3
- data/lib/rubocop/cop/style/symbol_proc.rb +35 -7
- data/lib/rubocop/cop/style/trivial_accessors.rb +3 -0
- data/lib/rubocop/cop/style/word_array.rb +2 -3
- data/lib/rubocop/options.rb +3 -6
- data/lib/rubocop/rake_task.rb +5 -1
- data/lib/rubocop/result_cache.rb +22 -20
- data/lib/rubocop/rspec/shared_contexts.rb +14 -14
- data/lib/rubocop/rspec/support.rb +14 -0
- data/lib/rubocop/runner.rb +4 -0
- data/lib/rubocop/server/cache.rb +33 -1
- data/lib/rubocop/server/cli.rb +19 -2
- data/lib/rubocop/server/client_command/base.rb +1 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +4 -2
- metadata +12 -7
- data/lib/rubocop/cop/mixin/ignored_methods.rb +0 -52
data/lib/rubocop/options.rb
CHANGED
@@ -421,12 +421,9 @@ module RuboCop
|
|
421
421
|
end
|
422
422
|
|
423
423
|
def invalid_arguments_for_parallel
|
424
|
-
[('--auto-gen-config'
|
425
|
-
('-F/--fail-fast'
|
426
|
-
('
|
427
|
-
('-a/--autocorrect' if @options.key?(:safe_autocorrect)),
|
428
|
-
('-A/--autocorrect-all' if @options.key?(:autocorrect_all)),
|
429
|
-
('--cache false' if @options > { cache: 'false' })].compact
|
424
|
+
[('--auto-gen-config' if @options.key?(:auto_gen_config)),
|
425
|
+
('-F/--fail-fast' if @options.key?(:fail_fast)),
|
426
|
+
('--cache false' if @options > { cache: 'false' })].compact
|
430
427
|
end
|
431
428
|
|
432
429
|
def only_includes_redundant_disable?
|
data/lib/rubocop/rake_task.rb
CHANGED
@@ -73,11 +73,15 @@ module RuboCop
|
|
73
73
|
namespace(name) do
|
74
74
|
# rubocop:todo Naming/InclusiveLanguage
|
75
75
|
task(:auto_correct, *args) do
|
76
|
+
require 'rainbow'
|
76
77
|
warn Rainbow(
|
77
78
|
'rubocop:auto_correct task is deprecated; ' \
|
78
79
|
'use rubocop:autocorrect task or rubocop:autocorrect_all task instead.'
|
79
80
|
).yellow
|
80
|
-
|
81
|
+
RakeFileUtils.verbose(verbose) do
|
82
|
+
yield(*[self, task_args].slice(0, task_block.arity)) if task_block
|
83
|
+
perform('--autocorrect')
|
84
|
+
end
|
81
85
|
end
|
82
86
|
# rubocop:enable Naming/InclusiveLanguage
|
83
87
|
|
data/lib/rubocop/result_cache.rb
CHANGED
@@ -4,6 +4,7 @@ require 'digest/sha1'
|
|
4
4
|
require 'find'
|
5
5
|
require 'etc'
|
6
6
|
require 'zlib'
|
7
|
+
require_relative 'cache_config'
|
7
8
|
|
8
9
|
module RuboCop
|
9
10
|
# Provides functionality for caching RuboCop runs.
|
@@ -13,6 +14,12 @@ module RuboCop
|
|
13
14
|
fix_layout autocorrect safe_autocorrect autocorrect_all
|
14
15
|
cache fail_fast stdin parallel].freeze
|
15
16
|
|
17
|
+
DL_EXTENSIONS = ::RbConfig::CONFIG
|
18
|
+
.values_at('DLEXT', 'DLEXT2')
|
19
|
+
.reject { |ext| !ext || ext.empty? }
|
20
|
+
.map { |ext| ".#{ext}" }
|
21
|
+
.freeze
|
22
|
+
|
16
23
|
# Remove old files so that the cache doesn't grow too big. When the
|
17
24
|
# threshold MaxFilesInCache has been exceeded, the oldest 50% of all the
|
18
25
|
# files in the cache are removed. The reason for removing so much is that
|
@@ -67,24 +74,9 @@ module RuboCop
|
|
67
74
|
end
|
68
75
|
|
69
76
|
def self.cache_root(config_store)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
# Include user ID in the path to make sure the user has write
|
74
|
-
# access.
|
75
|
-
File.join(ENV.fetch('XDG_CACHE_HOME'), Process.uid.to_s)
|
76
|
-
else
|
77
|
-
# On FreeBSD, the /home path is a symbolic link to /usr/home
|
78
|
-
# and the $HOME environment variable returns the /home path.
|
79
|
-
#
|
80
|
-
# As $HOME is a built-in environment variable, FreeBSD users
|
81
|
-
# always get a warning message.
|
82
|
-
#
|
83
|
-
# To avoid raising warn log messages on FreeBSD, we retrieve
|
84
|
-
# the real path of the home folder.
|
85
|
-
File.join(File.realpath(Dir.home), '.cache')
|
86
|
-
end
|
87
|
-
File.join(root, 'rubocop_cache')
|
77
|
+
CacheConfig.root_dir do
|
78
|
+
config_store.for_pwd.for_all_cops['CacheRootDirectory']
|
79
|
+
end
|
88
80
|
end
|
89
81
|
|
90
82
|
def self.allow_symlinks_in_cache_location?(config_store)
|
@@ -188,14 +180,24 @@ module RuboCop
|
|
188
180
|
.select { |path| File.file?(path) }
|
189
181
|
.sort!
|
190
182
|
.each do |path|
|
191
|
-
|
192
|
-
digest << Zlib.crc32(content).to_s # mtime not reliable
|
183
|
+
digest << digest(path)
|
193
184
|
end
|
194
185
|
digest << RuboCop::Version::STRING << RuboCop::AST::Version::STRING
|
195
186
|
digest.hexdigest
|
196
187
|
end
|
197
188
|
end
|
198
189
|
|
190
|
+
def digest(path)
|
191
|
+
content = if path.end_with?(*DL_EXTENSIONS)
|
192
|
+
# Shared libraries often contain timestamps of when
|
193
|
+
# they were compiled and other non-stable data.
|
194
|
+
File.basename(path)
|
195
|
+
else
|
196
|
+
File.binread(path) # mtime not reliable
|
197
|
+
end
|
198
|
+
Zlib.crc32(content).to_s
|
199
|
+
end
|
200
|
+
|
199
201
|
def rubocop_extra_features
|
200
202
|
lib_root = File.join(File.dirname(__FILE__), '..')
|
201
203
|
exe_root = File.join(lib_root, '..', 'exe')
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'tmpdir'
|
4
4
|
|
5
|
-
RSpec.shared_context 'isolated environment'
|
5
|
+
RSpec.shared_context 'isolated environment' do
|
6
6
|
around do |example|
|
7
7
|
Dir.mktmpdir do |tmpdir|
|
8
8
|
original_home = Dir.home
|
@@ -38,7 +38,7 @@ RSpec.shared_context 'isolated environment', :isolated_environment do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
RSpec.shared_context 'maintain registry'
|
41
|
+
RSpec.shared_context 'maintain registry' do
|
42
42
|
around(:each) { |example| RuboCop::Cop::Registry.with_temporary_global { example.run } }
|
43
43
|
|
44
44
|
def stub_cop_class(name, inherit: RuboCop::Cop::Base, &block)
|
@@ -49,7 +49,7 @@ RSpec.shared_context 'maintain registry', :restore_registry do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# This context assumes nothing and defines `cop`, among others.
|
52
|
-
RSpec.shared_context 'config'
|
52
|
+
RSpec.shared_context 'config' do # rubocop:disable Metrics/BlockLength
|
53
53
|
### Meant to be overridden at will
|
54
54
|
|
55
55
|
let(:cop_class) do
|
@@ -116,46 +116,46 @@ RSpec.shared_context 'mock console output' do
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
RSpec.shared_context 'ruby 2.0'
|
119
|
+
RSpec.shared_context 'ruby 2.0' do
|
120
120
|
let(:ruby_version) { 2.0 }
|
121
121
|
end
|
122
122
|
|
123
|
-
RSpec.shared_context 'ruby 2.1'
|
123
|
+
RSpec.shared_context 'ruby 2.1' do
|
124
124
|
let(:ruby_version) { 2.1 }
|
125
125
|
end
|
126
126
|
|
127
|
-
RSpec.shared_context 'ruby 2.2'
|
127
|
+
RSpec.shared_context 'ruby 2.2' do
|
128
128
|
let(:ruby_version) { 2.2 }
|
129
129
|
end
|
130
130
|
|
131
|
-
RSpec.shared_context 'ruby 2.3'
|
131
|
+
RSpec.shared_context 'ruby 2.3' do
|
132
132
|
let(:ruby_version) { 2.3 }
|
133
133
|
end
|
134
134
|
|
135
|
-
RSpec.shared_context 'ruby 2.4'
|
135
|
+
RSpec.shared_context 'ruby 2.4' do
|
136
136
|
let(:ruby_version) { 2.4 }
|
137
137
|
end
|
138
138
|
|
139
|
-
RSpec.shared_context 'ruby 2.5'
|
139
|
+
RSpec.shared_context 'ruby 2.5' do
|
140
140
|
let(:ruby_version) { 2.5 }
|
141
141
|
end
|
142
142
|
|
143
|
-
RSpec.shared_context 'ruby 2.6'
|
143
|
+
RSpec.shared_context 'ruby 2.6' do
|
144
144
|
let(:ruby_version) { 2.6 }
|
145
145
|
end
|
146
146
|
|
147
|
-
RSpec.shared_context 'ruby 2.7'
|
147
|
+
RSpec.shared_context 'ruby 2.7' do
|
148
148
|
let(:ruby_version) { 2.7 }
|
149
149
|
end
|
150
150
|
|
151
|
-
RSpec.shared_context 'ruby 3.0'
|
151
|
+
RSpec.shared_context 'ruby 3.0' do
|
152
152
|
let(:ruby_version) { 3.0 }
|
153
153
|
end
|
154
154
|
|
155
|
-
RSpec.shared_context 'ruby 3.1'
|
155
|
+
RSpec.shared_context 'ruby 3.1' do
|
156
156
|
let(:ruby_version) { 3.1 }
|
157
157
|
end
|
158
158
|
|
159
|
-
RSpec.shared_context 'ruby 3.2'
|
159
|
+
RSpec.shared_context 'ruby 3.2' do
|
160
160
|
let(:ruby_version) { 3.2 }
|
161
161
|
end
|
@@ -11,4 +11,18 @@ require_relative 'parallel_formatter'
|
|
11
11
|
RSpec.configure do |config|
|
12
12
|
config.include CopHelper
|
13
13
|
config.include HostEnvironmentSimulatorHelper
|
14
|
+
config.include_context 'config', :config
|
15
|
+
config.include_context 'isolated environment', :isolated_environment
|
16
|
+
config.include_context 'maintain registry', :restore_registry
|
17
|
+
config.include_context 'ruby 2.0', :ruby20
|
18
|
+
config.include_context 'ruby 2.1', :ruby21
|
19
|
+
config.include_context 'ruby 2.2', :ruby22
|
20
|
+
config.include_context 'ruby 2.3', :ruby23
|
21
|
+
config.include_context 'ruby 2.4', :ruby24
|
22
|
+
config.include_context 'ruby 2.5', :ruby25
|
23
|
+
config.include_context 'ruby 2.6', :ruby26
|
24
|
+
config.include_context 'ruby 2.7', :ruby27
|
25
|
+
config.include_context 'ruby 3.0', :ruby30
|
26
|
+
config.include_context 'ruby 3.1', :ruby31
|
27
|
+
config.include_context 'ruby 3.2', :ruby32
|
14
28
|
end
|
data/lib/rubocop/runner.rb
CHANGED
@@ -63,8 +63,12 @@ module RuboCop
|
|
63
63
|
# Warms up the RuboCop cache by forking a suitable number of RuboCop
|
64
64
|
# instances that each inspects its allotted group of files.
|
65
65
|
def warm_cache(target_files)
|
66
|
+
saved_options = @options.dup
|
66
67
|
puts 'Running parallel inspection' if @options[:debug]
|
68
|
+
%i[autocorrect safe_autocorrect].each { |opt| @options[opt] = false }
|
67
69
|
Parallel.each(target_files) { |target_file| file_offenses(target_file) }
|
70
|
+
ensure
|
71
|
+
@options = saved_options
|
68
72
|
end
|
69
73
|
|
70
74
|
def find_target_files(paths)
|
data/lib/rubocop/server/cache.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'pathname'
|
4
|
+
require_relative '../cache_config'
|
5
|
+
require_relative '../config_finder'
|
4
6
|
|
5
7
|
#
|
6
8
|
# This code is based on https://github.com/fohte/rubocop-daemon.
|
@@ -19,6 +21,8 @@ module RuboCop
|
|
19
21
|
GEMFILE_NAMES = %w[Gemfile gems.rb].freeze
|
20
22
|
|
21
23
|
class << self
|
24
|
+
attr_accessor :cache_root_path
|
25
|
+
|
22
26
|
# Searches for Gemfile or gems.rb in the current dir or any parent dirs
|
23
27
|
def project_dir
|
24
28
|
current_dir = Dir.pwd
|
@@ -38,12 +42,40 @@ module RuboCop
|
|
38
42
|
end
|
39
43
|
|
40
44
|
def dir
|
41
|
-
cache_path = File.expand_path('~/.cache/rubocop_cache/server')
|
42
45
|
Pathname.new(File.join(cache_path, project_dir_cache_key)).tap do |d|
|
43
46
|
d.mkpath unless d.exist?
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
50
|
+
def cache_path
|
51
|
+
cache_root_dir = if cache_root_path
|
52
|
+
File.join(cache_root_path, 'rubocop_cache')
|
53
|
+
else
|
54
|
+
cache_root_dir_from_config
|
55
|
+
end
|
56
|
+
|
57
|
+
File.expand_path(File.join(cache_root_dir, 'server'))
|
58
|
+
end
|
59
|
+
|
60
|
+
def cache_root_dir_from_config
|
61
|
+
CacheConfig.root_dir do
|
62
|
+
# `RuboCop::ConfigStore` has heavy dependencies, this is a lightweight implementation
|
63
|
+
# so that only the necessary `CacheRootDirectory` can be obtained.
|
64
|
+
require 'yaml'
|
65
|
+
|
66
|
+
config_path = ConfigFinder.find_config_path(Dir.pwd)
|
67
|
+
|
68
|
+
# Ruby 3.1+
|
69
|
+
config_yaml = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('4.0.0')
|
70
|
+
YAML.safe_load_file(config_path, permitted_classes: [Regexp, Symbol])
|
71
|
+
else
|
72
|
+
YAML.load_file(config_path)
|
73
|
+
end
|
74
|
+
|
75
|
+
config_yaml.dig('AllCops', 'CacheRootDirectory')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
47
79
|
def port_path
|
48
80
|
dir.join('port')
|
49
81
|
end
|
data/lib/rubocop/server/cli.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'optparse'
|
4
3
|
require 'rainbow'
|
5
4
|
|
6
5
|
#
|
@@ -30,6 +29,7 @@ module RuboCop
|
|
30
29
|
@exit = false
|
31
30
|
end
|
32
31
|
|
32
|
+
# rubocop:disable Metrics/MethodLength
|
33
33
|
def run(argv = ARGV)
|
34
34
|
unless Server.support_server?
|
35
35
|
return error('RuboCop server is not supported by this Ruby.') if use_server_option?(argv)
|
@@ -37,6 +37,7 @@ module RuboCop
|
|
37
37
|
return STATUS_SUCCESS
|
38
38
|
end
|
39
39
|
|
40
|
+
Cache.cache_root_path = fetch_cache_root_path_from(argv)
|
40
41
|
deleted_server_arguments = delete_server_argument_from(argv)
|
41
42
|
|
42
43
|
if deleted_server_arguments.size >= 2
|
@@ -45,7 +46,7 @@ module RuboCop
|
|
45
46
|
|
46
47
|
server_command = deleted_server_arguments.first
|
47
48
|
|
48
|
-
if EXCLUSIVE_OPTIONS.include?(server_command) && argv.count
|
49
|
+
if EXCLUSIVE_OPTIONS.include?(server_command) && argv.count > allowed_option_count
|
49
50
|
return error("#{server_command} cannot be combined with other options.")
|
50
51
|
end
|
51
52
|
|
@@ -53,6 +54,7 @@ module RuboCop
|
|
53
54
|
|
54
55
|
STATUS_SUCCESS
|
55
56
|
end
|
57
|
+
# rubocop:enable Metrics/MethodLength
|
56
58
|
|
57
59
|
def exit?
|
58
60
|
@exit
|
@@ -83,6 +85,17 @@ module RuboCop
|
|
83
85
|
end
|
84
86
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength:
|
85
87
|
|
88
|
+
def fetch_cache_root_path_from(arguments)
|
89
|
+
cache_root = arguments.detect { |argument| argument.start_with?('--cache-root') }
|
90
|
+
return unless cache_root
|
91
|
+
|
92
|
+
if cache_root.start_with?('--cache-root=')
|
93
|
+
cache_root.split('=')[1]
|
94
|
+
else
|
95
|
+
arguments[arguments.index(cache_root) + 1]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
86
99
|
def delete_server_argument_from(all_arguments)
|
87
100
|
SERVER_OPTIONS.each_with_object([]) do |server_option, server_arguments|
|
88
101
|
server_arguments << all_arguments.delete(server_option)
|
@@ -93,6 +106,10 @@ module RuboCop
|
|
93
106
|
(argv & SERVER_OPTIONS).any?
|
94
107
|
end
|
95
108
|
|
109
|
+
def allowed_option_count
|
110
|
+
Cache.cache_root_path ? 2 : 1
|
111
|
+
end
|
112
|
+
|
96
113
|
def error(message)
|
97
114
|
@exit = true
|
98
115
|
warn Rainbow(message).red
|
@@ -29,7 +29,7 @@ module RuboCop
|
|
29
29
|
socket.puts [Cache.token_path.read, Dir.pwd, command, *args].shelljoin
|
30
30
|
socket.write body
|
31
31
|
socket.close_write
|
32
|
-
$stdout.write socket.
|
32
|
+
$stdout.write socket.readpartial(4096) until socket.eof?
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -72,7 +72,6 @@ require_relative 'rubocop/cop/mixin/configurable_enforced_style'
|
|
72
72
|
require_relative 'rubocop/cop/mixin/configurable_formatting'
|
73
73
|
require_relative 'rubocop/cop/mixin/configurable_naming'
|
74
74
|
require_relative 'rubocop/cop/mixin/configurable_numbering'
|
75
|
-
require_relative 'rubocop/cop/mixin/def_node'
|
76
75
|
require_relative 'rubocop/cop/mixin/documentation_comment'
|
77
76
|
require_relative 'rubocop/cop/mixin/duplication'
|
78
77
|
require_relative 'rubocop/cop/mixin/range_help'
|
@@ -87,7 +86,6 @@ require_relative 'rubocop/cop/mixin/gem_declaration'
|
|
87
86
|
require_relative 'rubocop/cop/mixin/gemspec_help'
|
88
87
|
require_relative 'rubocop/cop/mixin/hash_alignment_styles'
|
89
88
|
require_relative 'rubocop/cop/mixin/hash_transform_method'
|
90
|
-
require_relative 'rubocop/cop/mixin/ignored_methods'
|
91
89
|
require_relative 'rubocop/cop/mixin/integer_node'
|
92
90
|
require_relative 'rubocop/cop/mixin/interpolation'
|
93
91
|
require_relative 'rubocop/cop/mixin/line_length_help'
|
@@ -130,6 +128,7 @@ require_relative 'rubocop/cop/mixin/uncommunicative_name'
|
|
130
128
|
require_relative 'rubocop/cop/mixin/unused_argument'
|
131
129
|
require_relative 'rubocop/cop/mixin/visibility_help'
|
132
130
|
require_relative 'rubocop/cop/mixin/comments_help' # relies on visibility_help
|
131
|
+
require_relative 'rubocop/cop/mixin/def_node' # relies on visibility_help
|
133
132
|
|
134
133
|
require_relative 'rubocop/cop/utils/format_string'
|
135
134
|
|
@@ -233,6 +232,7 @@ require_relative 'rubocop/cop/layout/multiline_method_argument_line_breaks'
|
|
233
232
|
require_relative 'rubocop/cop/layout/multiline_method_call_brace_layout'
|
234
233
|
require_relative 'rubocop/cop/layout/multiline_method_call_indentation'
|
235
234
|
require_relative 'rubocop/cop/layout/multiline_method_definition_brace_layout'
|
235
|
+
require_relative 'rubocop/cop/layout/multiline_method_parameter_line_breaks'
|
236
236
|
require_relative 'rubocop/cop/layout/multiline_operation_indentation'
|
237
237
|
require_relative 'rubocop/cop/layout/parameter_alignment'
|
238
238
|
require_relative 'rubocop/cop/layout/redundant_line_break'
|
@@ -356,6 +356,7 @@ require_relative 'rubocop/cop/lint/redundant_with_object'
|
|
356
356
|
require_relative 'rubocop/cop/lint/refinement_import_methods'
|
357
357
|
require_relative 'rubocop/cop/lint/regexp_as_condition'
|
358
358
|
require_relative 'rubocop/cop/lint/require_parentheses'
|
359
|
+
require_relative 'rubocop/cop/lint/require_range_parentheses'
|
359
360
|
require_relative 'rubocop/cop/lint/require_relative_self_path'
|
360
361
|
require_relative 'rubocop/cop/lint/rescue_exception'
|
361
362
|
require_relative 'rubocop/cop/lint/rescue_type'
|
@@ -479,6 +480,7 @@ require_relative 'rubocop/cop/style/each_with_object'
|
|
479
480
|
require_relative 'rubocop/cop/style/empty_block_parameter'
|
480
481
|
require_relative 'rubocop/cop/style/empty_case_condition'
|
481
482
|
require_relative 'rubocop/cop/style/empty_else'
|
483
|
+
require_relative 'rubocop/cop/style/empty_heredoc'
|
482
484
|
require_relative 'rubocop/cop/style/empty_lambda_parameter'
|
483
485
|
require_relative 'rubocop/cop/style/empty_literal'
|
484
486
|
require_relative 'rubocop/cop/style/empty_method'
|
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.33.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-08-04 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.19.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.19.1
|
134
134
|
- - "<"
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '2.0'
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- exe/rubocop
|
209
209
|
- lib/rubocop.rb
|
210
210
|
- lib/rubocop/ast_aliases.rb
|
211
|
+
- lib/rubocop/cache_config.rb
|
211
212
|
- lib/rubocop/cached_data.rb
|
212
213
|
- lib/rubocop/cli.rb
|
213
214
|
- lib/rubocop/cli/command.rb
|
@@ -222,6 +223,7 @@ files:
|
|
222
223
|
- lib/rubocop/cli/environment.rb
|
223
224
|
- lib/rubocop/comment_config.rb
|
224
225
|
- lib/rubocop/config.rb
|
226
|
+
- lib/rubocop/config_finder.rb
|
225
227
|
- lib/rubocop/config_loader.rb
|
226
228
|
- lib/rubocop/config_loader_resolver.rb
|
227
229
|
- lib/rubocop/config_obsoletion.rb
|
@@ -301,6 +303,7 @@ files:
|
|
301
303
|
- lib/rubocop/cop/internal_affairs/style_detected_api_use.rb
|
302
304
|
- lib/rubocop/cop/internal_affairs/undefined_config.rb
|
303
305
|
- lib/rubocop/cop/internal_affairs/useless_message_assertion.rb
|
306
|
+
- lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb
|
304
307
|
- lib/rubocop/cop/layout/access_modifier_indentation.rb
|
305
308
|
- lib/rubocop/cop/layout/argument_alignment.rb
|
306
309
|
- lib/rubocop/cop/layout/array_alignment.rb
|
@@ -366,6 +369,7 @@ files:
|
|
366
369
|
- lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb
|
367
370
|
- lib/rubocop/cop/layout/multiline_method_call_indentation.rb
|
368
371
|
- lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb
|
372
|
+
- lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb
|
369
373
|
- lib/rubocop/cop/layout/multiline_operation_indentation.rb
|
370
374
|
- lib/rubocop/cop/layout/parameter_alignment.rb
|
371
375
|
- lib/rubocop/cop/layout/redundant_line_break.rb
|
@@ -490,6 +494,7 @@ files:
|
|
490
494
|
- lib/rubocop/cop/lint/refinement_import_methods.rb
|
491
495
|
- lib/rubocop/cop/lint/regexp_as_condition.rb
|
492
496
|
- lib/rubocop/cop/lint/require_parentheses.rb
|
497
|
+
- lib/rubocop/cop/lint/require_range_parentheses.rb
|
493
498
|
- lib/rubocop/cop/lint/require_relative_self_path.rb
|
494
499
|
- lib/rubocop/cop/lint/rescue_exception.rb
|
495
500
|
- lib/rubocop/cop/lint/rescue_type.rb
|
@@ -578,7 +583,6 @@ files:
|
|
578
583
|
- lib/rubocop/cop/mixin/hash_shorthand_syntax.rb
|
579
584
|
- lib/rubocop/cop/mixin/hash_transform_method.rb
|
580
585
|
- lib/rubocop/cop/mixin/heredoc.rb
|
581
|
-
- lib/rubocop/cop/mixin/ignored_methods.rb
|
582
586
|
- lib/rubocop/cop/mixin/integer_node.rb
|
583
587
|
- lib/rubocop/cop/mixin/interpolation.rb
|
584
588
|
- lib/rubocop/cop/mixin/line_length_help.rb
|
@@ -695,6 +699,7 @@ files:
|
|
695
699
|
- lib/rubocop/cop/style/empty_block_parameter.rb
|
696
700
|
- lib/rubocop/cop/style/empty_case_condition.rb
|
697
701
|
- lib/rubocop/cop/style/empty_else.rb
|
702
|
+
- lib/rubocop/cop/style/empty_heredoc.rb
|
698
703
|
- lib/rubocop/cop/style/empty_lambda_parameter.rb
|
699
704
|
- lib/rubocop/cop/style/empty_literal.rb
|
700
705
|
- lib/rubocop/cop/style/empty_method.rb
|
@@ -967,7 +972,7 @@ metadata:
|
|
967
972
|
homepage_uri: https://rubocop.org/
|
968
973
|
changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
|
969
974
|
source_code_uri: https://github.com/rubocop/rubocop/
|
970
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
975
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.33/
|
971
976
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
972
977
|
rubygems_mfa_required: 'true'
|
973
978
|
post_install_message:
|
@@ -985,7 +990,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
985
990
|
- !ruby/object:Gem::Version
|
986
991
|
version: '0'
|
987
992
|
requirements: []
|
988
|
-
rubygems_version: 3.2
|
993
|
+
rubygems_version: 3.1.2
|
989
994
|
signing_key:
|
990
995
|
specification_version: 4
|
991
996
|
summary: Automatic Ruby code style checking tool.
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
# This module encapsulates the ability to ignore certain methods when
|
6
|
-
# parsing.
|
7
|
-
# Cops that use `IgnoredMethods` can accept either strings or regexes to match
|
8
|
-
# against.
|
9
|
-
module IgnoredMethods
|
10
|
-
# Configuration for IgnoredMethods. It is added to classes that include
|
11
|
-
# the module so that configuration can be set using the `ignored_methods`
|
12
|
-
# class macro.
|
13
|
-
module Config
|
14
|
-
attr_accessor :deprecated_key
|
15
|
-
|
16
|
-
def ignored_methods(**config)
|
17
|
-
self.deprecated_key = config[:deprecated_key]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.included(base)
|
22
|
-
base.extend(Config)
|
23
|
-
end
|
24
|
-
|
25
|
-
def ignored_method?(name)
|
26
|
-
ignored_methods.any? do |value|
|
27
|
-
case value
|
28
|
-
when Regexp
|
29
|
-
value.match? String(name)
|
30
|
-
else
|
31
|
-
value == String(name)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def ignored_methods
|
37
|
-
keys = %w[IgnoredMethods]
|
38
|
-
keys << deprecated_key if deprecated_key
|
39
|
-
|
40
|
-
cop_config.slice(*keys).values.reduce(&:concat)
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def deprecated_key
|
46
|
-
return unless self.class.respond_to?(:deprecated_key)
|
47
|
-
|
48
|
-
self.class.deprecated_key&.to_s
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|