rubocop 1.71.1 → 1.73.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 +3 -3
- data/config/default.yml +54 -11
- data/config/internal_affairs.yml +16 -0
- data/lib/rubocop/cli/command/suggest_extensions.rb +7 -1
- data/lib/rubocop/comment_config.rb +1 -1
- data/lib/rubocop/config.rb +4 -0
- data/lib/rubocop/config_loader.rb +44 -8
- data/lib/rubocop/config_loader_resolver.rb +23 -9
- data/lib/rubocop/config_validator.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/example_description.rb +4 -2
- data/lib/rubocop/cop/internal_affairs/location_exists.rb +116 -0
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
- data/lib/rubocop/cop/internal_affairs/undefined_config.rb +7 -1
- data/lib/rubocop/cop/internal_affairs.rb +1 -16
- data/lib/rubocop/cop/layout/block_alignment.rb +2 -0
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +4 -4
- data/lib/rubocop/cop/layout/else_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +0 -6
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +26 -1
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +22 -2
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +3 -3
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
- data/lib/rubocop/cop/lint/cop_directive_syntax.rb +84 -0
- data/lib/rubocop/cop/lint/duplicate_methods.rb +0 -14
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +10 -5
- data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
- data/lib/rubocop/cop/lint/float_comparison.rb +1 -6
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
- data/lib/rubocop/cop/lint/literal_as_condition.rb +99 -9
- data/lib/rubocop/cop/lint/mixed_case_range.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +0 -21
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +252 -0
- data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +111 -0
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/useless_constant_scoping.rb +80 -0
- data/lib/rubocop/cop/lint/void.rb +7 -6
- data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +7 -7
- data/lib/rubocop/cop/mixin/alignment.rb +2 -2
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
- data/lib/rubocop/cop/mixin/comments_help.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +18 -18
- data/lib/rubocop/cop/mixin/hash_subset.rb +19 -4
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +74 -74
- data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/range_help.rb +3 -3
- data/lib/rubocop/cop/mixin/string_help.rb +1 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +12 -0
- data/lib/rubocop/cop/naming/block_forwarding.rb +3 -3
- data/lib/rubocop/cop/naming/predicate_name.rb +44 -0
- data/lib/rubocop/cop/naming/variable_name.rb +64 -6
- data/lib/rubocop/cop/style/accessor_grouping.rb +19 -5
- data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -3
- data/lib/rubocop/cop/style/commented_keyword.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +2 -3
- data/lib/rubocop/cop/style/endless_method.rb +163 -18
- data/lib/rubocop/cop/style/explicit_block_argument.rb +14 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +1 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +46 -0
- data/lib/rubocop/cop/style/redundant_format.rb +250 -0
- data/lib/rubocop/cop/style/redundant_parentheses.rb +18 -4
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +3 -3
- data/lib/rubocop/cop/style/string_concatenation.rb +1 -1
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/utils/format_string.rb +7 -5
- data/lib/rubocop/cop/variable_force/variable.rb +13 -1
- data/lib/rubocop/cops_documentation_generator.rb +12 -1
- data/lib/rubocop/directive_comment.rb +35 -2
- data/lib/rubocop/lsp/runtime.rb +2 -0
- data/lib/rubocop/lsp/server.rb +0 -2
- data/lib/rubocop/options.rb +26 -11
- data/lib/rubocop/path_util.rb +4 -0
- data/lib/rubocop/plugin/configuration_integrator.rb +143 -0
- data/lib/rubocop/plugin/load_error.rb +26 -0
- data/lib/rubocop/plugin/loader.rb +100 -0
- data/lib/rubocop/plugin/not_supported_error.rb +29 -0
- data/lib/rubocop/plugin.rb +46 -0
- data/lib/rubocop/rake_task.rb +4 -1
- data/lib/rubocop/rspec/cop_helper.rb +9 -0
- data/lib/rubocop/rspec/shared_contexts.rb +15 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/server/cache.rb +35 -2
- data/lib/rubocop/server/cli.rb +2 -2
- data/lib/rubocop/version.rb +17 -2
- data/lib/rubocop.rb +5 -1
- data/lib/ruby_lsp/rubocop/addon.rb +7 -10
- data/lib/ruby_lsp/rubocop/{wraps_built_in_lsp_runtime.rb → runtime_adapter.rb} +5 -8
- metadata +35 -10
- data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../feature_loader'
|
4
|
+
require_relative 'load_error'
|
5
|
+
|
6
|
+
module RuboCop
|
7
|
+
module Plugin
|
8
|
+
# A class for loading and resolving plugins.
|
9
|
+
# @api private
|
10
|
+
class Loader
|
11
|
+
# rubocop:disable Layout/LineLength
|
12
|
+
DEFAULT_PLUGIN_CONFIG = {
|
13
|
+
'enabled' => true,
|
14
|
+
'require_path' => nil, # If not set, will be set to the plugin name
|
15
|
+
'plugin_class_name' => nil # If not set, looks for gemspec `spec.metadata["default_lint_roller_plugin"]`
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
# rubocop:enable Layout/LineLength
|
19
|
+
class << self
|
20
|
+
def load(plugins)
|
21
|
+
normalized_plugin_configs = normalize(plugins)
|
22
|
+
normalized_plugin_configs.filter_map do |plugin_name, plugin_config|
|
23
|
+
next unless plugin_config['enabled']
|
24
|
+
|
25
|
+
plugin_class = constantize_plugin_from(plugin_name, plugin_config)
|
26
|
+
|
27
|
+
plugin_class.new(plugin_config)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# rubocop:disable Metrics/MethodLength
|
34
|
+
def normalize(plugin_configs)
|
35
|
+
plugin_configs.to_h do |plugin_config|
|
36
|
+
if plugin_config == Plugin::OBSOLETE_INTERNAL_AFFAIRS_PLUGIN_NAME
|
37
|
+
warn Rainbow(<<~MESSAGE).yellow
|
38
|
+
Specify `rubocop-internal_affairs` instead of `rubocop/cop/internal_affairs` in your configuration.
|
39
|
+
MESSAGE
|
40
|
+
plugin_config = Plugin::INTERNAL_AFFAIRS_PLUGIN_NAME
|
41
|
+
end
|
42
|
+
|
43
|
+
if plugin_config.is_a?(Hash)
|
44
|
+
plugin_name = plugin_config.keys.first
|
45
|
+
|
46
|
+
[
|
47
|
+
plugin_name, DEFAULT_PLUGIN_CONFIG.merge(
|
48
|
+
{ 'require_path' => plugin_name }, plugin_config.values.first
|
49
|
+
)
|
50
|
+
]
|
51
|
+
# NOTE: Compatibility is maintained when `require: rubocop/cop/internal_affairs` remains
|
52
|
+
# specified in `.rubocop.yml`.
|
53
|
+
elsif (builtin_plugin_config = Plugin::BUILTIN_INTERNAL_PLUGINS[plugin_config])
|
54
|
+
[plugin_config, builtin_plugin_config]
|
55
|
+
else
|
56
|
+
[plugin_config, DEFAULT_PLUGIN_CONFIG.merge('require_path' => plugin_config)]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def constantize_plugin_from(plugin_name, plugin_config)
|
62
|
+
if plugin_name.is_a?(String) || plugin_name.is_a?(Symbol)
|
63
|
+
constantize(plugin_name, plugin_config)
|
64
|
+
else
|
65
|
+
plugin_name
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# rubocop:enable Metrics/MethodLength
|
70
|
+
def constantize(plugin_name, plugin_config)
|
71
|
+
require_plugin(plugin_config['require_path'])
|
72
|
+
|
73
|
+
if (constant_name = plugin_config['plugin_class_name'])
|
74
|
+
begin
|
75
|
+
Kernel.const_get(constant_name)
|
76
|
+
rescue StandardError
|
77
|
+
raise <<~MESSAGE
|
78
|
+
Failed while configuring plugin `#{plugin_name}': no constant with name `#{constant_name}' was found.
|
79
|
+
MESSAGE
|
80
|
+
end
|
81
|
+
else
|
82
|
+
constantize_plugin_from_gemspec_metadata(plugin_name)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def require_plugin(require_path)
|
87
|
+
FeatureLoader.load(config_directory_path: Dir.pwd, feature: require_path)
|
88
|
+
end
|
89
|
+
|
90
|
+
def constantize_plugin_from_gemspec_metadata(plugin_name)
|
91
|
+
plugin_class_name = Gem.loaded_specs[plugin_name].metadata['default_lint_roller_plugin']
|
92
|
+
|
93
|
+
Kernel.const_get(plugin_class_name)
|
94
|
+
rescue LoadError, StandardError
|
95
|
+
raise Plugin::LoadError, plugin_name
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Plugin
|
5
|
+
# An exception raised when a plugin is not supported by the RuboCop engine.
|
6
|
+
# @api private
|
7
|
+
class NotSupportedError < Error
|
8
|
+
def initialize(unsupported_plugins)
|
9
|
+
super
|
10
|
+
|
11
|
+
@unsupported_plugins = unsupported_plugins
|
12
|
+
end
|
13
|
+
|
14
|
+
def message
|
15
|
+
if @unsupported_plugins.one?
|
16
|
+
about = @unsupported_plugins.first.about
|
17
|
+
|
18
|
+
"#{about.name} #{about.version} is not a plugin supported by RuboCop engine."
|
19
|
+
else
|
20
|
+
unsupported_plugin_names = @unsupported_plugins.map do |plugin|
|
21
|
+
"#{plugin.about.name} #{plugin.about.version}"
|
22
|
+
end.join(', ')
|
23
|
+
|
24
|
+
"#{unsupported_plugin_names} are not plugins supported by RuboCop engine."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'plugin/configuration_integrator'
|
4
|
+
require_relative 'plugin/loader'
|
5
|
+
|
6
|
+
module RuboCop
|
7
|
+
# Provides a plugin for RuboCop extensions that conform to lint_roller.
|
8
|
+
# https://github.com/standardrb/lint_roller
|
9
|
+
# @api private
|
10
|
+
module Plugin
|
11
|
+
BUILTIN_INTERNAL_PLUGINS = {
|
12
|
+
'rubocop-internal_affairs' => {
|
13
|
+
'enabled' => true,
|
14
|
+
'require_path' => 'rubocop/cop/internal_affairs/plugin',
|
15
|
+
'plugin_class_name' => 'RuboCop::InternalAffairs::Plugin'
|
16
|
+
}
|
17
|
+
}.freeze
|
18
|
+
INTERNAL_AFFAIRS_PLUGIN_NAME = Plugin::BUILTIN_INTERNAL_PLUGINS.keys.first
|
19
|
+
OBSOLETE_INTERNAL_AFFAIRS_PLUGIN_NAME = 'rubocop/cop/internal_affairs'
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def plugin_capable?(feature_name)
|
23
|
+
return true if BUILTIN_INTERNAL_PLUGINS.key?(feature_name)
|
24
|
+
return true if feature_name == OBSOLETE_INTERNAL_AFFAIRS_PLUGIN_NAME
|
25
|
+
|
26
|
+
begin
|
27
|
+
# When not using Bundler. Makes the spec available but does not require it.
|
28
|
+
gem feature_name
|
29
|
+
rescue Gem::LoadError
|
30
|
+
# The user requested a gem that they do not have installed
|
31
|
+
end
|
32
|
+
return false unless (spec = Gem.loaded_specs[feature_name])
|
33
|
+
|
34
|
+
!!spec.metadata['default_lint_roller_plugin']
|
35
|
+
end
|
36
|
+
|
37
|
+
def integrate_plugins(rubocop_config, plugins)
|
38
|
+
plugins = Plugin::Loader.load(plugins)
|
39
|
+
|
40
|
+
ConfigurationIntegrator.integrate_plugins_into_rubocop_config(rubocop_config, plugins)
|
41
|
+
|
42
|
+
plugins
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/rubocop/rake_task.rb
CHANGED
@@ -12,7 +12,8 @@ module RuboCop
|
|
12
12
|
# Use global Rake namespace here to avoid namespace issues with custom
|
13
13
|
# rubocop-rake tasks
|
14
14
|
class RakeTask < ::Rake::TaskLib
|
15
|
-
attr_accessor :name, :verbose, :fail_on_error, :patterns, :formatters, :
|
15
|
+
attr_accessor :name, :verbose, :fail_on_error, :patterns, :formatters, :plugins, :requires,
|
16
|
+
:options
|
16
17
|
|
17
18
|
def initialize(name = :rubocop, *args, &task_block)
|
18
19
|
super()
|
@@ -54,6 +55,7 @@ module RuboCop
|
|
54
55
|
|
55
56
|
def full_options
|
56
57
|
formatters.map { |f| ['--format', f] }.flatten
|
58
|
+
.concat(plugins.map { |plugin| ['--plugin', plugin] }.flatten)
|
57
59
|
.concat(requires.map { |r| ['--require', r] }.flatten)
|
58
60
|
.concat(options.flatten)
|
59
61
|
.concat(patterns)
|
@@ -64,6 +66,7 @@ module RuboCop
|
|
64
66
|
@verbose = true
|
65
67
|
@fail_on_error = true
|
66
68
|
@patterns = []
|
69
|
+
@plugins = []
|
67
70
|
@requires = []
|
68
71
|
@options = []
|
69
72
|
@formatters = []
|
@@ -13,6 +13,15 @@ module CopHelper
|
|
13
13
|
let(:parser_engine) { ENV.fetch('PARSER_ENGINE', :parser_whitequark).to_sym }
|
14
14
|
let(:rails_version) { false }
|
15
15
|
|
16
|
+
before(:all) do
|
17
|
+
next if ENV['RUBOCOP_CORE_DEVELOPMENT']
|
18
|
+
|
19
|
+
plugins = Gem.loaded_specs.filter_map do |feature_name, feature_specification|
|
20
|
+
feature_name if feature_specification.metadata['default_lint_roller_plugin']
|
21
|
+
end
|
22
|
+
RuboCop::Plugin.integrate_plugins(RuboCop::Config.new, plugins)
|
23
|
+
end
|
24
|
+
|
16
25
|
def inspect_source(source, file = nil)
|
17
26
|
RuboCop::Formatter::DisabledConfigFormatter.config_to_allow_offenses = {}
|
18
27
|
RuboCop::Formatter::DisabledConfigFormatter.detected_styles = {}
|
@@ -80,6 +80,21 @@ RSpec.shared_context 'maintain registry' do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
RSpec.shared_context 'maintain default configuration' do
|
84
|
+
around(:each) do |example|
|
85
|
+
# Make a copy of the current configuration that will not change when source hash changes
|
86
|
+
default_configuration = RuboCop::ConfigLoader.default_configuration
|
87
|
+
config = RuboCop::Config.create(
|
88
|
+
default_configuration.to_h.clone,
|
89
|
+
default_configuration.loaded_path
|
90
|
+
)
|
91
|
+
|
92
|
+
example.run
|
93
|
+
|
94
|
+
RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
83
98
|
# This context assumes nothing and defines `cop`, among others.
|
84
99
|
RSpec.shared_context 'config' do # rubocop:disable Metrics/BlockLength
|
85
100
|
### Meant to be overridden at will
|
@@ -15,6 +15,7 @@ RSpec.configure do |config|
|
|
15
15
|
config.include_context 'isolated bundler', :isolated_bundler
|
16
16
|
config.include_context 'lsp', :lsp
|
17
17
|
config.include_context 'maintain registry', :restore_registry
|
18
|
+
config.include_context 'maintain default configuration', :restore_configuration
|
18
19
|
config.include_context 'ruby 2.0', :ruby20
|
19
20
|
config.include_context 'ruby 2.1', :ruby21
|
20
21
|
config.include_context 'ruby 2.2', :ruby22
|
data/lib/rubocop/server/cache.rb
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'digest'
|
4
4
|
require 'pathname'
|
5
|
+
require 'yaml'
|
5
6
|
require_relative '../cache_config'
|
6
7
|
require_relative '../config_finder'
|
8
|
+
require_relative '../path_util'
|
7
9
|
|
8
10
|
#
|
9
11
|
# This code is based on https://github.com/fohte/rubocop-daemon.
|
@@ -50,9 +52,11 @@ module RuboCop
|
|
50
52
|
end.find(&:exist?)
|
51
53
|
version_data = lockfile_path&.read || RuboCop::Version::STRING
|
52
54
|
config_data = Pathname(ConfigFinder.find_config_path(Dir.pwd)).read
|
53
|
-
|
55
|
+
yaml = YAML.safe_load(config_data, permitted_classes: [Regexp, Symbol], aliases: true)
|
56
|
+
inherit_from_data = inherit_from_data(yaml)
|
57
|
+
require_data = require_data(yaml)
|
54
58
|
|
55
|
-
Digest::SHA1.hexdigest(version_data + config_data +
|
59
|
+
Digest::SHA1.hexdigest(version_data + config_data + inherit_from_data + require_data)
|
56
60
|
end
|
57
61
|
# rubocop:enable Metrics/AbcSize
|
58
62
|
|
@@ -164,6 +168,35 @@ module RuboCop
|
|
164
168
|
def write_version_file(version)
|
165
169
|
version_path.write(version)
|
166
170
|
end
|
171
|
+
|
172
|
+
def inherit_from_data(yaml)
|
173
|
+
return '' unless (inherit_from_paths = yaml['inherit_from'])
|
174
|
+
|
175
|
+
Array(inherit_from_paths).map do |path|
|
176
|
+
next if PathUtil.remote_file?(path)
|
177
|
+
|
178
|
+
path = Pathname(path)
|
179
|
+
|
180
|
+
path.exist? ? path.read : ''
|
181
|
+
end.join
|
182
|
+
end
|
183
|
+
|
184
|
+
def require_data(yaml)
|
185
|
+
return '' unless (require_paths = yaml['require'])
|
186
|
+
|
187
|
+
Array(require_paths).map do |path|
|
188
|
+
# NOTE: This targets only relative or absolute path specifications.
|
189
|
+
# For example, specifications like `require: rubocop-performance`,
|
190
|
+
# which can be loaded from `$LOAD_PATH`, are ignored.
|
191
|
+
next unless path.start_with?('.', '/')
|
192
|
+
|
193
|
+
# NOTE: `.so` files are not typically specified, so only `.rb` files are targeted.
|
194
|
+
path = "#{path}.rb" unless path.end_with?('.rb')
|
195
|
+
path = Pathname(path)
|
196
|
+
|
197
|
+
path.exist? ? path.read : ''
|
198
|
+
end.join
|
199
|
+
end
|
167
200
|
end
|
168
201
|
end
|
169
202
|
end
|
data/lib/rubocop/server/cli.rb
CHANGED
@@ -86,7 +86,7 @@ module RuboCop
|
|
86
86
|
end
|
87
87
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
88
88
|
|
89
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
89
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
90
90
|
def run_command(server_command, detach:)
|
91
91
|
case server_command
|
92
92
|
when '--server'
|
@@ -107,7 +107,7 @@ module RuboCop
|
|
107
107
|
Server::ClientCommand::Status.new.run
|
108
108
|
end
|
109
109
|
end
|
110
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
110
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
111
111
|
|
112
112
|
def fetch_cache_root_path_from(arguments)
|
113
113
|
cache_root = arguments.detect { |argument| argument.start_with?('--cache-root') }
|
data/lib/rubocop/version.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# This module holds the RuboCop version information.
|
5
5
|
module Version
|
6
|
-
STRING = '1.
|
6
|
+
STRING = '1.73.1'
|
7
7
|
|
8
8
|
MSG = '%<version>s (using %<parser_version>s, ' \
|
9
9
|
'rubocop-ast %<rubocop_ast_version>s, ' \
|
@@ -63,9 +63,21 @@ module RuboCop
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# @api private
|
66
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
66
67
|
def self.extension_versions(env)
|
68
|
+
plugins = config_for_pwd(env).loaded_plugins
|
69
|
+
plugin_versions = plugins.filter_map do |plugin|
|
70
|
+
next if Plugin::BUILTIN_INTERNAL_PLUGINS.key?(plugin.about.name)
|
71
|
+
next unless (plugin_name = plugin.about.name)
|
72
|
+
|
73
|
+
" - #{plugin_name} #{plugin.about.version}"
|
74
|
+
end
|
75
|
+
|
76
|
+
# TODO: It needs to be maintained for a while to ensure compatibility with extensions that
|
77
|
+
# don't support plugins. It should be removed in future once the old style becomes obsolete.
|
67
78
|
features = config_for_pwd(env).loaded_features.sort
|
68
|
-
features.
|
79
|
+
features -= plugins.map { |plugin| plugin.about.name }
|
80
|
+
feature_versions = features.filter_map do |loaded_feature|
|
69
81
|
next unless (match = loaded_feature.match(/rubocop-(?<feature>.*)/))
|
70
82
|
|
71
83
|
# Get the expected name of the folder containing the extension code.
|
@@ -84,7 +96,10 @@ module RuboCop
|
|
84
96
|
|
85
97
|
" - #{loaded_feature} #{feature_version}"
|
86
98
|
end
|
99
|
+
|
100
|
+
plugin_versions + feature_versions
|
87
101
|
end
|
102
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
88
103
|
|
89
104
|
# @api private
|
90
105
|
def self.target_ruby_version(env)
|
data/lib/rubocop.rb
CHANGED
@@ -148,7 +148,6 @@ require_relative 'rubocop/cop/mixin/comments_help' # relies on visibility_help
|
|
148
148
|
require_relative 'rubocop/cop/mixin/def_node' # relies on visibility_help
|
149
149
|
|
150
150
|
require_relative 'rubocop/cop/utils/format_string'
|
151
|
-
require_relative 'rubocop/cop/utils/regexp_ranges'
|
152
151
|
|
153
152
|
require_relative 'rubocop/cop/migration/department_name'
|
154
153
|
|
@@ -304,6 +303,7 @@ require_relative 'rubocop/cop/lint/constant_definition_in_block'
|
|
304
303
|
require_relative 'rubocop/cop/lint/constant_overwritten_in_rescue'
|
305
304
|
require_relative 'rubocop/cop/lint/constant_reassignment'
|
306
305
|
require_relative 'rubocop/cop/lint/constant_resolution'
|
306
|
+
require_relative 'rubocop/cop/lint/cop_directive_syntax'
|
307
307
|
require_relative 'rubocop/cop/lint/debugger'
|
308
308
|
require_relative 'rubocop/cop/lint/deprecated_class_methods'
|
309
309
|
require_relative 'rubocop/cop/lint/deprecated_constants'
|
@@ -384,6 +384,7 @@ require_relative 'rubocop/cop/lint/redundant_require_statement'
|
|
384
384
|
require_relative 'rubocop/cop/lint/redundant_safe_navigation'
|
385
385
|
require_relative 'rubocop/cop/lint/redundant_splat_expansion'
|
386
386
|
require_relative 'rubocop/cop/lint/redundant_string_coercion'
|
387
|
+
require_relative 'rubocop/cop/lint/redundant_type_conversion'
|
387
388
|
require_relative 'rubocop/cop/lint/redundant_with_index'
|
388
389
|
require_relative 'rubocop/cop/lint/redundant_with_object'
|
389
390
|
require_relative 'rubocop/cop/lint/refinement_import_methods'
|
@@ -405,6 +406,7 @@ require_relative 'rubocop/cop/lint/shadowed_exception'
|
|
405
406
|
require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
|
406
407
|
require_relative 'rubocop/cop/lint/struct_new_override'
|
407
408
|
require_relative 'rubocop/cop/lint/suppressed_exception'
|
409
|
+
require_relative 'rubocop/cop/lint/suppressed_exception_in_number_conversion'
|
408
410
|
require_relative 'rubocop/cop/lint/symbol_conversion'
|
409
411
|
require_relative 'rubocop/cop/lint/syntax'
|
410
412
|
require_relative 'rubocop/cop/lint/to_enum_arguments'
|
@@ -425,6 +427,7 @@ require_relative 'rubocop/cop/lint/uri_escape_unescape'
|
|
425
427
|
require_relative 'rubocop/cop/lint/uri_regexp'
|
426
428
|
require_relative 'rubocop/cop/lint/useless_access_modifier'
|
427
429
|
require_relative 'rubocop/cop/lint/useless_assignment'
|
430
|
+
require_relative 'rubocop/cop/lint/useless_constant_scoping'
|
428
431
|
require_relative 'rubocop/cop/lint/useless_defined'
|
429
432
|
require_relative 'rubocop/cop/lint/useless_else_without_rescue'
|
430
433
|
require_relative 'rubocop/cop/lint/useless_method_definition'
|
@@ -604,6 +607,7 @@ require_relative 'rubocop/cop/style/redundant_each'
|
|
604
607
|
require_relative 'rubocop/cop/style/redundant_fetch_block'
|
605
608
|
require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
|
606
609
|
require_relative 'rubocop/cop/style/redundant_filter_chain'
|
610
|
+
require_relative 'rubocop/cop/style/redundant_format'
|
607
611
|
require_relative 'rubocop/cop/style/redundant_heredoc_delimiter_quotes'
|
608
612
|
require_relative 'rubocop/cop/style/redundant_initialize'
|
609
613
|
require_relative 'rubocop/cop/style/redundant_interpolation_unfreeze'
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
require_relative '../../rubocop'
|
4
4
|
require_relative '../../rubocop/lsp/logger'
|
5
|
-
require_relative '
|
5
|
+
require_relative 'runtime_adapter'
|
6
6
|
|
7
7
|
module RubyLsp
|
8
8
|
module RuboCop
|
9
9
|
# A Ruby LSP add-on for RuboCop.
|
10
10
|
class Addon < RubyLsp::Addon
|
11
11
|
def initializer
|
12
|
-
@
|
12
|
+
@runtime_adapter = nil
|
13
13
|
end
|
14
14
|
|
15
15
|
def name
|
@@ -21,11 +21,8 @@ module RubyLsp
|
|
21
21
|
"Activating RuboCop LSP addon #{::RuboCop::Version::STRING}.", prefix: '[RuboCop]'
|
22
22
|
)
|
23
23
|
|
24
|
-
|
25
|
-
@
|
26
|
-
|
27
|
-
global_state.register_formatter('rubocop', @wraps_built_in_lsp_runtime)
|
28
|
-
|
24
|
+
@runtime_adapter = RuntimeAdapter.new
|
25
|
+
global_state.register_formatter('rubocop', @runtime_adapter)
|
29
26
|
register_additional_file_watchers(global_state, message_queue)
|
30
27
|
|
31
28
|
::RuboCop::LSP::Logger.log(
|
@@ -34,7 +31,7 @@ module RubyLsp
|
|
34
31
|
end
|
35
32
|
|
36
33
|
def deactivate
|
37
|
-
@
|
34
|
+
@runtime_adapter = nil
|
38
35
|
end
|
39
36
|
|
40
37
|
# rubocop:disable Layout/LineLength, Metrics/MethodLength
|
@@ -67,9 +64,9 @@ module RubyLsp
|
|
67
64
|
def workspace_did_change_watched_files(changes)
|
68
65
|
return unless changes.any? { |change| change[:uri].end_with?('.rubocop.yml') }
|
69
66
|
|
70
|
-
@
|
67
|
+
@runtime_adapter = RuntimeAdapter.new
|
71
68
|
|
72
|
-
::RuboCop::LSP::Logger(<<~MESSAGE, prefix: '[RuboCop]')
|
69
|
+
::RuboCop::LSP::Logger.log(<<~MESSAGE, prefix: '[RuboCop]')
|
73
70
|
Re-initialized RuboCop LSP addon #{::RuboCop::Version::STRING} due to .rubocop.yml file change.
|
74
71
|
MESSAGE
|
75
72
|
end
|
@@ -4,18 +4,15 @@ require_relative '../../rubocop/lsp/runtime'
|
|
4
4
|
|
5
5
|
module RubyLsp
|
6
6
|
module RuboCop
|
7
|
-
#
|
8
|
-
|
7
|
+
# Provides an adapter to bridge RuboCop's built-in LSP runtime with Ruby LSP's add-on.
|
8
|
+
# @api private
|
9
|
+
class RuntimeAdapter
|
9
10
|
include RubyLsp::Requests::Support::Formatter
|
10
11
|
|
11
12
|
def initialize
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def init!
|
16
|
-
config = ::RuboCop::ConfigStore.new
|
13
|
+
config_store = ::RuboCop::ConfigStore.new
|
17
14
|
|
18
|
-
@runtime = ::RuboCop::LSP::Runtime.new(
|
15
|
+
@runtime = ::RuboCop::LSP::Runtime.new(config_store)
|
19
16
|
end
|
20
17
|
|
21
18
|
def run_diagnostic(uri, document)
|
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.73.1
|
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: 2025-
|
12
|
+
date: 2025-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -29,16 +29,30 @@ dependencies:
|
|
29
29
|
name: language_server-protocol
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 3.17.0
|
34
|
+
version: 3.17.0.2
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 3.17.0.2
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: lint_roller
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.1.0
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
40
54
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
55
|
+
version: 1.1.0
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: parallel
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -272,6 +286,7 @@ files:
|
|
272
286
|
- lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb
|
273
287
|
- lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb
|
274
288
|
- lib/rubocop/cop/internal_affairs/lambda_or_proc.rb
|
289
|
+
- lib/rubocop/cop/internal_affairs/location_exists.rb
|
275
290
|
- lib/rubocop/cop/internal_affairs/location_expression.rb
|
276
291
|
- lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb
|
277
292
|
- lib/rubocop/cop/internal_affairs/method_name_end_with.rb
|
@@ -288,6 +303,7 @@ files:
|
|
288
303
|
- lib/rubocop/cop/internal_affairs/offense_location_keyword.rb
|
289
304
|
- lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb
|
290
305
|
- lib/rubocop/cop/internal_affairs/operator_keyword.rb
|
306
|
+
- lib/rubocop/cop/internal_affairs/plugin.rb
|
291
307
|
- lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb
|
292
308
|
- lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb
|
293
309
|
- lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb
|
@@ -419,6 +435,7 @@ files:
|
|
419
435
|
- lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb
|
420
436
|
- lib/rubocop/cop/lint/constant_reassignment.rb
|
421
437
|
- lib/rubocop/cop/lint/constant_resolution.rb
|
438
|
+
- lib/rubocop/cop/lint/cop_directive_syntax.rb
|
422
439
|
- lib/rubocop/cop/lint/debugger.rb
|
423
440
|
- lib/rubocop/cop/lint/deprecated_class_methods.rb
|
424
441
|
- lib/rubocop/cop/lint/deprecated_constants.rb
|
@@ -498,6 +515,7 @@ files:
|
|
498
515
|
- lib/rubocop/cop/lint/redundant_safe_navigation.rb
|
499
516
|
- lib/rubocop/cop/lint/redundant_splat_expansion.rb
|
500
517
|
- lib/rubocop/cop/lint/redundant_string_coercion.rb
|
518
|
+
- lib/rubocop/cop/lint/redundant_type_conversion.rb
|
501
519
|
- lib/rubocop/cop/lint/redundant_with_index.rb
|
502
520
|
- lib/rubocop/cop/lint/redundant_with_object.rb
|
503
521
|
- lib/rubocop/cop/lint/refinement_import_methods.rb
|
@@ -520,6 +538,7 @@ files:
|
|
520
538
|
- lib/rubocop/cop/lint/shared_mutable_default.rb
|
521
539
|
- lib/rubocop/cop/lint/struct_new_override.rb
|
522
540
|
- lib/rubocop/cop/lint/suppressed_exception.rb
|
541
|
+
- lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb
|
523
542
|
- lib/rubocop/cop/lint/symbol_conversion.rb
|
524
543
|
- lib/rubocop/cop/lint/syntax.rb
|
525
544
|
- lib/rubocop/cop/lint/to_enum_arguments.rb
|
@@ -540,6 +559,7 @@ files:
|
|
540
559
|
- lib/rubocop/cop/lint/uri_regexp.rb
|
541
560
|
- lib/rubocop/cop/lint/useless_access_modifier.rb
|
542
561
|
- lib/rubocop/cop/lint/useless_assignment.rb
|
562
|
+
- lib/rubocop/cop/lint/useless_constant_scoping.rb
|
543
563
|
- lib/rubocop/cop/lint/useless_defined.rb
|
544
564
|
- lib/rubocop/cop/lint/useless_else_without_rescue.rb
|
545
565
|
- lib/rubocop/cop/lint/useless_method_definition.rb
|
@@ -865,6 +885,7 @@ files:
|
|
865
885
|
- lib/rubocop/cop/style/redundant_fetch_block.rb
|
866
886
|
- lib/rubocop/cop/style/redundant_file_extension_in_require.rb
|
867
887
|
- lib/rubocop/cop/style/redundant_filter_chain.rb
|
888
|
+
- lib/rubocop/cop/style/redundant_format.rb
|
868
889
|
- lib/rubocop/cop/style/redundant_freeze.rb
|
869
890
|
- lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb
|
870
891
|
- lib/rubocop/cop/style/redundant_initialize.rb
|
@@ -950,7 +971,6 @@ files:
|
|
950
971
|
- lib/rubocop/cop/team.rb
|
951
972
|
- lib/rubocop/cop/util.rb
|
952
973
|
- lib/rubocop/cop/utils/format_string.rb
|
953
|
-
- lib/rubocop/cop/utils/regexp_ranges.rb
|
954
974
|
- lib/rubocop/cop/variable_force.rb
|
955
975
|
- lib/rubocop/cop/variable_force/assignment.rb
|
956
976
|
- lib/rubocop/cop/variable_force/branch.rb
|
@@ -1008,6 +1028,11 @@ files:
|
|
1008
1028
|
- lib/rubocop/options.rb
|
1009
1029
|
- lib/rubocop/path_util.rb
|
1010
1030
|
- lib/rubocop/platform.rb
|
1031
|
+
- lib/rubocop/plugin.rb
|
1032
|
+
- lib/rubocop/plugin/configuration_integrator.rb
|
1033
|
+
- lib/rubocop/plugin/load_error.rb
|
1034
|
+
- lib/rubocop/plugin/loader.rb
|
1035
|
+
- lib/rubocop/plugin/not_supported_error.rb
|
1011
1036
|
- lib/rubocop/rake_task.rb
|
1012
1037
|
- lib/rubocop/remote_config.rb
|
1013
1038
|
- lib/rubocop/result_cache.rb
|
@@ -1043,15 +1068,15 @@ files:
|
|
1043
1068
|
- lib/rubocop/warning.rb
|
1044
1069
|
- lib/rubocop/yaml_duplication_checker.rb
|
1045
1070
|
- lib/ruby_lsp/rubocop/addon.rb
|
1046
|
-
- lib/ruby_lsp/rubocop/
|
1071
|
+
- lib/ruby_lsp/rubocop/runtime_adapter.rb
|
1047
1072
|
homepage: https://github.com/rubocop/rubocop
|
1048
1073
|
licenses:
|
1049
1074
|
- MIT
|
1050
1075
|
metadata:
|
1051
1076
|
homepage_uri: https://rubocop.org/
|
1052
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1077
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.73.1
|
1053
1078
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1054
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1079
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.73/
|
1055
1080
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1056
1081
|
rubygems_mfa_required: 'true'
|
1057
1082
|
rdoc_options: []
|