rubocop 1.58.0 → 1.60.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +3 -3
- data/config/default.yml +9 -1
- data/lib/rubocop/config.rb +0 -2
- data/lib/rubocop/config_loader.rb +0 -1
- data/lib/rubocop/config_validator.rb +0 -2
- data/lib/rubocop/cop/base.rb +6 -0
- data/lib/rubocop/cop/exclude_limit.rb +1 -1
- data/lib/rubocop/cop/layout/end_alignment.rb +5 -1
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +16 -1
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +1 -1
- data/lib/rubocop/cop/layout/redundant_line_break.rb +2 -1
- data/lib/rubocop/cop/layout/single_line_block_chain.rb +1 -0
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -2
- data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
- data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +2 -1
- data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +56 -0
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +23 -2
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +6 -21
- data/lib/rubocop/cop/lint/number_conversion.rb +9 -4
- data/lib/rubocop/cop/lint/redundant_with_index.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
- data/lib/rubocop/cop/lint/self_assignment.rb +1 -0
- data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
- data/lib/rubocop/cop/lint/syntax.rb +6 -3
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +2 -2
- data/lib/rubocop/cop/lint/useless_times.rb +1 -1
- data/lib/rubocop/cop/metrics/abc_size.rb +3 -3
- data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -0
- data/lib/rubocop/cop/naming/block_forwarding.rb +10 -2
- data/lib/rubocop/cop/naming/constant_name.rb +1 -2
- data/lib/rubocop/cop/registry.rb +4 -4
- data/lib/rubocop/cop/security/open.rb +2 -2
- data/lib/rubocop/cop/style/arguments_forwarding.rb +16 -3
- data/lib/rubocop/cop/style/array_first_last.rb +1 -1
- data/lib/rubocop/cop/style/class_check.rb +1 -0
- data/lib/rubocop/cop/style/collection_compact.rb +7 -6
- data/lib/rubocop/cop/style/combinable_loops.rb +11 -0
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
- data/lib/rubocop/cop/style/date_time.rb +5 -4
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +7 -7
- data/lib/rubocop/cop/style/each_with_object.rb +2 -2
- data/lib/rubocop/cop/style/eval_with_location.rb +0 -11
- data/lib/rubocop/cop/style/exact_regexp_match.rb +2 -1
- data/lib/rubocop/cop/style/hash_each_methods.rb +29 -4
- data/lib/rubocop/cop/style/hash_except.rb +2 -1
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +4 -1
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +39 -2
- data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +3 -2
- data/lib/rubocop/cop/style/map_to_hash.rb +9 -4
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +14 -5
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +1 -3
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +20 -0
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -3
- data/lib/rubocop/cop/style/next.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
- data/lib/rubocop/cop/style/operator_method_call.rb +2 -2
- data/lib/rubocop/cop/style/parallel_assignment.rb +2 -2
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +8 -0
- data/lib/rubocop/cop/style/redundant_argument.rb +1 -0
- data/lib/rubocop/cop/style/redundant_each.rb +7 -4
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +3 -3
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +8 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +15 -7
- data/lib/rubocop/cop/style/redundant_self.rb +17 -2
- data/lib/rubocop/cop/style/redundant_sort.rb +8 -7
- data/lib/rubocop/cop/style/redundant_sort_by.rb +2 -2
- data/lib/rubocop/cop/style/sample.rb +2 -1
- data/lib/rubocop/cop/style/select_by_regexp.rb +6 -5
- data/lib/rubocop/cop/style/single_argument_dig.rb +5 -2
- data/lib/rubocop/cop/style/slicing_with_range.rb +76 -10
- data/lib/rubocop/cop/style/string_chars.rb +1 -0
- data/lib/rubocop/cop/style/strip.rb +7 -4
- data/lib/rubocop/cop/style/symbol_proc.rb +36 -0
- data/lib/rubocop/cop/style/unpack_first.rb +11 -14
- data/lib/rubocop/cops_documentation_generator.rb +11 -1
- data/lib/rubocop/ext/regexp_node.rb +9 -4
- data/lib/rubocop/formatter/disabled_config_formatter.rb +17 -6
- data/lib/rubocop/formatter/json_formatter.rb +0 -1
- data/lib/rubocop/formatter.rb +1 -1
- data/lib/rubocop/lsp/routes.rb +1 -1
- data/lib/rubocop/options.rb +0 -8
- data/lib/rubocop/rspec/shared_contexts.rb +6 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/server/cache.rb +0 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +1 -0
- metadata +8 -7
- /data/lib/rubocop/formatter/{git_hub_actions_formatter.rb → github_actions_formatter.rb} +0 -0
@@ -30,7 +30,8 @@ module RuboCop
|
|
30
30
|
@files_with_offenses ||= {}
|
31
31
|
end
|
32
32
|
|
33
|
-
def file_started(_file,
|
33
|
+
def file_started(_file, options)
|
34
|
+
@config_for_pwd = options[:config_store].for_pwd
|
34
35
|
@exclude_limit_option = @options[:exclude_limit]
|
35
36
|
@exclude_limit = Integer(@exclude_limit_option ||
|
36
37
|
RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS)
|
@@ -115,9 +116,13 @@ module RuboCop
|
|
115
116
|
def set_max(cfg, cop_name)
|
116
117
|
return unless cfg[:exclude_limit]
|
117
118
|
|
118
|
-
|
119
|
-
|
120
|
-
if
|
119
|
+
max_set_in_user_config =
|
120
|
+
@config_for_pwd.for_cop(cop_name)['Max'] != default_config(cop_name)['Max']
|
121
|
+
if !max_set_in_user_config &&
|
122
|
+
# In case auto_gen_only_exclude is set, only modify the maximum if the files are not
|
123
|
+
# excluded one by one.
|
124
|
+
(!@options[:auto_gen_only_exclude] ||
|
125
|
+
@files_with_offenses[cop_name].size > @exclude_limit)
|
121
126
|
cfg.merge!(cfg[:exclude_limit])
|
122
127
|
end
|
123
128
|
|
@@ -192,8 +197,8 @@ module RuboCop
|
|
192
197
|
# 'Enabled' option will be put into file only if exclude
|
193
198
|
# limit is exceeded.
|
194
199
|
rejected_keys = ['Enabled']
|
195
|
-
rejected_keys <<
|
196
|
-
cfg.reject { |key|
|
200
|
+
rejected_keys << /\AEnforcedStyle\w*/ unless auto_gen_enforced_style?
|
201
|
+
cfg.reject { |key| include_or_match?(rejected_keys, key) }
|
197
202
|
end
|
198
203
|
|
199
204
|
def output_offending_files(output_buffer, cfg, cop_name)
|
@@ -262,6 +267,12 @@ module RuboCop
|
|
262
267
|
def no_exclude_limit?
|
263
268
|
@options[:no_exclude_limit] == false
|
264
269
|
end
|
270
|
+
|
271
|
+
# Returns true if the given arr include the given elm or if any of the
|
272
|
+
# given arr is a regexp that matches the given elm.
|
273
|
+
def include_or_match?(arr, elm)
|
274
|
+
arr.include?(elm) || arr.any? { |x| x.is_a?(Regexp) && x.match?(elm) }
|
275
|
+
end
|
265
276
|
end
|
266
277
|
end
|
267
278
|
end
|
data/lib/rubocop/formatter.rb
CHANGED
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
require_relative 'formatter/emacs_style_formatter'
|
15
15
|
require_relative 'formatter/file_list_formatter'
|
16
16
|
require_relative 'formatter/fuubar_style_formatter'
|
17
|
-
require_relative 'formatter/
|
17
|
+
require_relative 'formatter/github_actions_formatter'
|
18
18
|
require_relative 'formatter/html_formatter'
|
19
19
|
require_relative 'formatter/json_formatter'
|
20
20
|
require_relative 'formatter/junit_formatter'
|
data/lib/rubocop/lsp/routes.rb
CHANGED
data/lib/rubocop/options.rb
CHANGED
@@ -364,10 +364,6 @@ module RuboCop
|
|
364
364
|
raise OptionArgumentError, '-C/--cache argument must be true or false'
|
365
365
|
end
|
366
366
|
|
367
|
-
if display_only_fail_level_offenses_with_autocorrect?
|
368
|
-
raise OptionArgumentError, '--autocorrect cannot be used with ' \
|
369
|
-
'--display-only-fail-level-offenses.'
|
370
|
-
end
|
371
367
|
validate_auto_gen_config
|
372
368
|
validate_autocorrect
|
373
369
|
validate_display_only_failed
|
@@ -460,10 +456,6 @@ module RuboCop
|
|
460
456
|
(@options[:only] & %w[Lint/RedundantCopDisableDirective RedundantCopDisableDirective]).any?
|
461
457
|
end
|
462
458
|
|
463
|
-
def display_only_fail_level_offenses_with_autocorrect?
|
464
|
-
@options.key?(:display_only_fail_level_offenses) && @options.key?(:autocorrect)
|
465
|
-
end
|
466
|
-
|
467
459
|
def except_syntax?
|
468
460
|
@options.key?(:except) && (@options[:except] & %w[Lint/Syntax Syntax]).any?
|
469
461
|
end
|
@@ -128,6 +128,12 @@ RSpec.shared_context 'mock console output' do
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
RSpec.shared_context 'lsp mode' do
|
132
|
+
before do
|
133
|
+
allow(cop).to receive(:lsp_mode?).and_return(true)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
131
137
|
RSpec.shared_context 'ruby 2.0' do
|
132
138
|
let(:ruby_version) { 2.0 }
|
133
139
|
end
|
@@ -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 'lsp mode', :lsp_mode
|
16
17
|
config.include_context 'maintain registry', :restore_registry
|
17
18
|
config.include_context 'ruby 2.0', :ruby20
|
18
19
|
config.include_context 'ruby 2.1', :ruby21
|
data/lib/rubocop/server/cache.rb
CHANGED
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -332,6 +332,7 @@ require_relative 'rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler'
|
|
332
332
|
require_relative 'rubocop/cop/lint/ineffective_access_modifier'
|
333
333
|
require_relative 'rubocop/cop/lint/inherit_exception'
|
334
334
|
require_relative 'rubocop/cop/lint/interpolation_check'
|
335
|
+
require_relative 'rubocop/cop/lint/it_without_arguments_in_block'
|
335
336
|
require_relative 'rubocop/cop/lint/lambda_without_literal_block'
|
336
337
|
require_relative 'rubocop/cop/lint/literal_as_condition'
|
337
338
|
require_relative 'rubocop/cop/lint/literal_assignment_in_condition'
|
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.60.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:
|
13
|
+
date: 2024-01-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -60,14 +60,14 @@ dependencies:
|
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 3.
|
63
|
+
version: 3.3.0.2
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 3.
|
70
|
+
version: 3.3.0.2
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: rainbow
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -467,6 +467,7 @@ files:
|
|
467
467
|
- lib/rubocop/cop/lint/ineffective_access_modifier.rb
|
468
468
|
- lib/rubocop/cop/lint/inherit_exception.rb
|
469
469
|
- lib/rubocop/cop/lint/interpolation_check.rb
|
470
|
+
- lib/rubocop/cop/lint/it_without_arguments_in_block.rb
|
470
471
|
- lib/rubocop/cop/lint/lambda_without_literal_block.rb
|
471
472
|
- lib/rubocop/cop/lint/literal_as_condition.rb
|
472
473
|
- lib/rubocop/cop/lint/literal_assignment_in_condition.rb
|
@@ -963,7 +964,7 @@ files:
|
|
963
964
|
- lib/rubocop/formatter/file_list_formatter.rb
|
964
965
|
- lib/rubocop/formatter/formatter_set.rb
|
965
966
|
- lib/rubocop/formatter/fuubar_style_formatter.rb
|
966
|
-
- lib/rubocop/formatter/
|
967
|
+
- lib/rubocop/formatter/github_actions_formatter.rb
|
967
968
|
- lib/rubocop/formatter/html_formatter.rb
|
968
969
|
- lib/rubocop/formatter/json_formatter.rb
|
969
970
|
- lib/rubocop/formatter/junit_formatter.rb
|
@@ -1027,9 +1028,9 @@ licenses:
|
|
1027
1028
|
- MIT
|
1028
1029
|
metadata:
|
1029
1030
|
homepage_uri: https://rubocop.org/
|
1030
|
-
changelog_uri: https://github.com/rubocop/rubocop/
|
1031
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.60.0
|
1031
1032
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1032
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1033
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.60/
|
1033
1034
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1034
1035
|
rubygems_mfa_required: 'true'
|
1035
1036
|
post_install_message:
|
File without changes
|