rubocop 1.64.1 → 1.65.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +11 -1
- data/lib/rubocop/config_loader.rb +1 -1
- data/lib/rubocop/config_loader_resolver.rb +9 -3
- data/lib/rubocop/cop/cop.rb +22 -4
- data/lib/rubocop/cop/gemspec/add_runtime_dependency.rb +38 -0
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +3 -3
- data/lib/rubocop/cop/layout/assignment_indentation.rb +3 -2
- data/lib/rubocop/cop/layout/case_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/condition_position.rb +0 -4
- data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +1 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +20 -20
- data/lib/rubocop/cop/layout/space_around_operators.rb +3 -0
- data/lib/rubocop/cop/legacy/corrector.rb +12 -2
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +0 -2
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +0 -2
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +0 -2
- data/lib/rubocop/cop/lint/boolean_symbol.rb +0 -2
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +0 -13
- data/lib/rubocop/cop/lint/debugger.rb +0 -4
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +0 -10
- data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -5
- data/lib/rubocop/cop/lint/duplicate_hash_key.rb +0 -4
- data/lib/rubocop/cop/lint/duplicate_methods.rb +0 -10
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +0 -4
- data/lib/rubocop/cop/lint/else_layout.rb +0 -2
- data/lib/rubocop/cop/lint/empty_ensure.rb +1 -11
- data/lib/rubocop/cop/lint/empty_interpolation.rb +0 -4
- data/lib/rubocop/cop/lint/empty_when.rb +1 -3
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -6
- data/lib/rubocop/cop/lint/float_comparison.rb +3 -1
- data/lib/rubocop/cop/lint/float_out_of_range.rb +0 -4
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +0 -10
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +15 -12
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +0 -7
- data/lib/rubocop/cop/lint/interpolation_check.rb +0 -4
- data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +0 -4
- data/lib/rubocop/cop/lint/loop.rb +6 -12
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -7
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +0 -4
- data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +0 -5
- data/lib/rubocop/cop/lint/percent_string_array.rb +0 -4
- data/lib/rubocop/cop/lint/percent_symbol_array.rb +0 -4
- data/lib/rubocop/cop/lint/rand_one.rb +0 -4
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +3 -1
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +0 -4
- data/lib/rubocop/cop/lint/require_parentheses.rb +0 -4
- data/lib/rubocop/cop/lint/rescue_exception.rb +0 -4
- data/lib/rubocop/cop/lint/return_in_void_context.rb +0 -2
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +0 -4
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +6 -10
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +2 -9
- data/lib/rubocop/cop/lint/unified_integer.rb +0 -4
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -0
- data/lib/rubocop/cop/lint/unreachable_code.rb +0 -5
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -5
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +0 -4
- data/lib/rubocop/cop/lint/useless_setter_call.rb +0 -4
- data/lib/rubocop/cop/lint/void.rb +5 -0
- data/lib/rubocop/cop/metrics/block_nesting.rb +19 -7
- data/lib/rubocop/cop/mixin/alignment.rb +5 -1
- data/lib/rubocop/cop/mixin/allowed_methods.rb +7 -1
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +15 -3
- data/lib/rubocop/cop/mixin/configurable_max.rb +5 -1
- data/lib/rubocop/cop/mixin/rescue_node.rb +4 -0
- data/lib/rubocop/cop/naming/predicate_name.rb +52 -26
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +10 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +1 -1
- data/lib/rubocop/cop/style/def_with_parentheses.rb +0 -2
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +0 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +12 -11
- data/lib/rubocop/cop/style/file_read.rb +2 -5
- data/lib/rubocop/cop/style/file_write.rb +2 -5
- data/lib/rubocop/cop/style/global_std_stream.rb +7 -1
- data/lib/rubocop/cop/style/hash_except.rb +8 -5
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +0 -1
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
- data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +77 -43
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +5 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/missing_else.rb +0 -4
- data/lib/rubocop/cop/style/multiline_when_then.rb +0 -4
- data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +0 -1
- data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -24
- data/lib/rubocop/cop/style/send_with_literal_method_name.rb +15 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +21 -2
- data/lib/rubocop/cop/style/super_arguments.rb +28 -10
- data/lib/rubocop/cop/style/symbol_proc.rb +8 -1
- data/lib/rubocop/cop/style/while_until_do.rb +0 -2
- data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +32 -24
- data/lib/rubocop/cop/team.rb +8 -0
- data/lib/rubocop/cop/util.rb +7 -1
- data/lib/rubocop/cop/variable_force.rb +13 -1
- data/lib/rubocop/cops_documentation_generator.rb +1 -1
- data/lib/rubocop/core_ext/string.rb +2 -6
- data/lib/rubocop/ext/regexp_node.rb +9 -31
- data/lib/rubocop/ext/regexp_parser.rb +4 -21
- data/lib/rubocop/formatter/html_formatter.rb +3 -1
- data/lib/rubocop/options.rb +3 -1
- data/lib/rubocop/rspec/shared_contexts.rb +20 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/server/cache.rb +10 -0
- data/lib/rubocop/server/client_command/exec.rb +2 -2
- data/lib/rubocop/server/client_command/start.rb +1 -1
- data/lib/rubocop/server/core.rb +4 -0
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +6 -0
- metadata +7 -6
@@ -15,39 +15,17 @@ module RuboCop
|
|
15
15
|
# see `ext/regexp_parser`.
|
16
16
|
attr_reader :parsed_tree
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
super
|
18
|
+
def assign_properties(*)
|
19
|
+
super
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
origin = loc.begin.end
|
29
|
-
@parsed_tree&.each_expression(true) { |e| e.origin = origin }
|
30
|
-
end
|
31
|
-
# Please remove this `else` branch when support for regexp_parser 1.8 will be dropped.
|
32
|
-
# It's for compatibility with regexp_parser 1.8 and will never be maintained.
|
33
|
-
else
|
34
|
-
def assign_properties(*)
|
35
|
-
super
|
36
|
-
|
37
|
-
str = with_interpolations_blanked
|
38
|
-
begin
|
39
|
-
@parsed_tree = Regexp::Parser.parse(str, options: options)
|
40
|
-
rescue StandardError
|
41
|
-
@parsed_tree = nil
|
42
|
-
else
|
43
|
-
origin = loc.begin.end
|
44
|
-
source = @parsed_tree.to_s
|
45
|
-
@parsed_tree.each_expression(true) do |e|
|
46
|
-
e.origin = origin
|
47
|
-
e.source = source
|
48
|
-
end
|
49
|
-
end
|
21
|
+
str = with_interpolations_blanked
|
22
|
+
@parsed_tree = begin
|
23
|
+
Regexp::Parser.parse(str, options: options)
|
24
|
+
rescue StandardError
|
25
|
+
nil
|
50
26
|
end
|
27
|
+
origin = loc.begin.end
|
28
|
+
@parsed_tree&.each_expression(true) { |e| e.origin = origin }
|
51
29
|
end
|
52
30
|
|
53
31
|
def each_capture(named: ANY)
|
@@ -22,26 +22,9 @@ module RuboCop
|
|
22
22
|
module Base
|
23
23
|
attr_accessor :origin
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@expression ||= origin.adjust(begin_pos: ts, end_pos: ts + full_length)
|
29
|
-
end
|
30
|
-
# Please remove this `else` branch when support for regexp_parser 1.8 will be dropped.
|
31
|
-
# It's for compatibility with regexp_parser 1.8 and will never be maintained.
|
32
|
-
else
|
33
|
-
attr_accessor :source
|
34
|
-
|
35
|
-
def start_index
|
36
|
-
# ts is a byte index; convert it to a character index
|
37
|
-
@start_index ||= source.byteslice(0, ts).length
|
38
|
-
end
|
39
|
-
|
40
|
-
# Shortcut to `loc.expression`
|
41
|
-
def expression
|
42
|
-
end_pos = start_index + full_length
|
43
|
-
@expression ||= origin.adjust(begin_pos: start_index, end_pos: end_pos)
|
44
|
-
end
|
25
|
+
# Shortcut to `loc.expression`
|
26
|
+
def expression
|
27
|
+
@expression ||= origin.adjust(begin_pos: ts, end_pos: ts + full_length)
|
45
28
|
end
|
46
29
|
|
47
30
|
# @returns a location map like `parser` does, with:
|
@@ -69,8 +52,8 @@ module RuboCop
|
|
69
52
|
|
70
53
|
body = expression.adjust(end_pos: -q.text.length)
|
71
54
|
q.origin = origin
|
72
|
-
q.source = source if q.respond_to?(:source=) # for regexp_parser 1.8
|
73
55
|
q_loc = q.expression
|
56
|
+
|
74
57
|
{ body: body, quantifier: q_loc }
|
75
58
|
end
|
76
59
|
end
|
@@ -52,7 +52,9 @@ module RuboCop
|
|
52
52
|
|
53
53
|
template = File.read(TEMPLATE_PATH, encoding: Encoding::UTF_8)
|
54
54
|
erb = ERB.new(template)
|
55
|
-
html = erb.result(context.binding).lines.map
|
55
|
+
html = erb.result(context.binding).lines.map do |line|
|
56
|
+
line.match?(/\A\s*\z/) ? "\n" : line
|
57
|
+
end.join
|
56
58
|
|
57
59
|
output.write html
|
58
60
|
end
|
data/lib/rubocop/options.rb
CHANGED
@@ -615,7 +615,9 @@ module RuboCop
|
|
615
615
|
version: 'Display version.',
|
616
616
|
verbose_version: 'Display verbose version.',
|
617
617
|
parallel: ['Use available CPUs to execute inspection in',
|
618
|
-
'parallel. Default is true.'
|
618
|
+
'parallel. Default is true.',
|
619
|
+
'You can specify the number of parallel processes using',
|
620
|
+
'the $PARALLEL_PROCESSOR_COUNT environment variable.'],
|
619
621
|
stdin: ['Pipe source from STDIN, using FILE in offense',
|
620
622
|
'reports. This is useful for editor integration.'],
|
621
623
|
editor_mode: ['Optimize real-time feedback in editors,',
|
@@ -50,6 +50,26 @@ RSpec.shared_context 'isolated environment' do # rubocop:disable Metrics/BlockLe
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# Workaround for https://github.com/rubocop/rubocop/issues/12978,
|
54
|
+
# there should already be no gemfile in the temp directory
|
55
|
+
RSpec.shared_context 'isolated bundler' do
|
56
|
+
around do |example|
|
57
|
+
# No bundler env and reset cached gemfile path
|
58
|
+
Bundler.with_unbundled_env do
|
59
|
+
old_values = Bundler.instance_variables.to_h do |name|
|
60
|
+
[name, Bundler.instance_variable_get(name)]
|
61
|
+
end
|
62
|
+
Bundler.instance_variables.each { |name| Bundler.remove_instance_variable(name) }
|
63
|
+
example.call
|
64
|
+
ensure
|
65
|
+
Bundler.instance_variables.each { |name| Bundler.remove_instance_variable(name) }
|
66
|
+
old_values.each do |name, value|
|
67
|
+
Bundler.instance_variable_set(name, value)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
53
73
|
RSpec.shared_context 'maintain registry' do
|
54
74
|
around(:each) { |example| RuboCop::Cop::Registry.with_temporary_global { example.run } }
|
55
75
|
|
@@ -13,6 +13,7 @@ RSpec.configure do |config|
|
|
13
13
|
config.include HostEnvironmentSimulatorHelper
|
14
14
|
config.include_context 'config', :config
|
15
15
|
config.include_context 'isolated environment', :isolated_environment
|
16
|
+
config.include_context 'isolated bundler', :isolated_bundler
|
16
17
|
config.include_context 'lsp', :lsp
|
17
18
|
config.include_context 'maintain registry', :restore_registry
|
18
19
|
config.include_context 'ruby 2.0', :ruby20
|
data/lib/rubocop/server/cache.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'digest'
|
3
4
|
require 'pathname'
|
4
5
|
require_relative '../cache_config'
|
5
6
|
require_relative '../config_finder'
|
@@ -19,6 +20,7 @@ module RuboCop
|
|
19
20
|
# @api private
|
20
21
|
class Cache
|
21
22
|
GEMFILE_NAMES = %w[Gemfile gems.rb].freeze
|
23
|
+
LOCKFILE_NAMES = %w[Gemfile.lock gems.locked].freeze
|
22
24
|
|
23
25
|
class << self
|
24
26
|
attr_accessor :cache_root_path
|
@@ -41,6 +43,14 @@ module RuboCop
|
|
41
43
|
@project_dir_cache_key ||= project_dir[1..].tr('/', '+')
|
42
44
|
end
|
43
45
|
|
46
|
+
def restart_key
|
47
|
+
lockfile_path = LOCKFILE_NAMES.map do |lockfile_name|
|
48
|
+
Pathname(project_dir).join(lockfile_name)
|
49
|
+
end.find(&:exist?)
|
50
|
+
|
51
|
+
Digest::SHA1.hexdigest(lockfile_path&.read || RuboCop::Version::STRING)
|
52
|
+
end
|
53
|
+
|
44
54
|
def dir
|
45
55
|
Pathname.new(File.join(cache_path, project_dir_cache_key)).tap do |d|
|
46
56
|
d.mkpath unless d.exist?
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def incompatible_version?
|
44
|
-
Cache.version_path.read !=
|
44
|
+
Cache.version_path.read != Cache.restart_key
|
45
45
|
end
|
46
46
|
|
47
47
|
def stderr
|
@@ -54,7 +54,7 @@ module RuboCop
|
|
54
54
|
end
|
55
55
|
|
56
56
|
status = Cache.status_path.read
|
57
|
-
raise "RuboCop server: '#{status}' is not a valid status!"
|
57
|
+
raise "RuboCop server: '#{status}' is not a valid status!" unless /\A\d+\z/.match?(status)
|
58
58
|
|
59
59
|
status.to_i
|
60
60
|
end
|
data/lib/rubocop/server/core.rb
CHANGED
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'English'
|
4
|
+
|
5
|
+
# fileutils is autoloaded by pathname,
|
6
|
+
# but must be explicitly loaded here for inclusion in `$LOADED_FEATURES`.
|
7
|
+
require 'fileutils'
|
8
|
+
|
4
9
|
before_us = $LOADED_FEATURES.dup
|
5
10
|
require 'rainbow'
|
6
11
|
|
@@ -169,6 +174,7 @@ require_relative 'rubocop/cop/bundler/gem_version'
|
|
169
174
|
require_relative 'rubocop/cop/bundler/insecure_protocol_source'
|
170
175
|
require_relative 'rubocop/cop/bundler/ordered_gems'
|
171
176
|
|
177
|
+
require_relative 'rubocop/cop/gemspec/add_runtime_dependency'
|
172
178
|
require_relative 'rubocop/cop/gemspec/dependency_version'
|
173
179
|
require_relative 'rubocop/cop/gemspec/deprecated_attribute_assignment'
|
174
180
|
require_relative 'rubocop/cop/gemspec/development_dependencies'
|
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.65.1
|
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: 2024-
|
13
|
+
date: 2024-08-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
97
|
+
version: '2.4'
|
98
98
|
- - "<"
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '3.0'
|
@@ -104,7 +104,7 @@ dependencies:
|
|
104
104
|
requirements:
|
105
105
|
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: '
|
107
|
+
version: '2.4'
|
108
108
|
- - "<"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.0'
|
@@ -270,6 +270,7 @@ files:
|
|
270
270
|
- lib/rubocop/cop/documentation.rb
|
271
271
|
- lib/rubocop/cop/exclude_limit.rb
|
272
272
|
- lib/rubocop/cop/force.rb
|
273
|
+
- lib/rubocop/cop/gemspec/add_runtime_dependency.rb
|
273
274
|
- lib/rubocop/cop/gemspec/dependency_version.rb
|
274
275
|
- lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb
|
275
276
|
- lib/rubocop/cop/gemspec/development_dependencies.rb
|
@@ -1034,9 +1035,9 @@ licenses:
|
|
1034
1035
|
- MIT
|
1035
1036
|
metadata:
|
1036
1037
|
homepage_uri: https://rubocop.org/
|
1037
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1038
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.65.1
|
1038
1039
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1039
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1040
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.65/
|
1040
1041
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1041
1042
|
rubygems_mfa_required: 'true'
|
1042
1043
|
post_install_message:
|