rubocop 1.57.2 → 1.60.2
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 +4 -4
- data/config/default.yml +46 -3
- data/lib/rubocop/config.rb +0 -2
- data/lib/rubocop/config_loader.rb +0 -1
- data/lib/rubocop/config_obsoletion.rb +11 -8
- data/lib/rubocop/config_validator.rb +0 -2
- data/lib/rubocop/cop/base.rb +6 -0
- data/lib/rubocop/cop/bundler/gem_comment.rb +2 -2
- data/lib/rubocop/cop/exclude_limit.rb +1 -1
- data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/example_description.rb +4 -4
- data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +19 -20
- data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +53 -0
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +2 -2
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/end_alignment.rb +5 -1
- data/lib/rubocop/cop/layout/extra_spacing.rb +4 -10
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +22 -7
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
- 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 +7 -2
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +4 -4
- data/lib/rubocop/cop/layout/single_line_block_chain.rb +5 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +50 -20
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +4 -4
- 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/debugger.rb +2 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +3 -3
- data/lib/rubocop/cop/lint/float_comparison.rb +10 -0
- 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 +85 -0
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +6 -21
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -5
- data/lib/rubocop/cop/lint/number_conversion.rb +9 -4
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +43 -0
- 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/safe_navigation_chain.rb +3 -4
- data/lib/rubocop/cop/lint/self_assignment.rb +38 -0
- data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
- data/lib/rubocop/cop/lint/symbol_conversion.rb +7 -2
- data/lib/rubocop/cop/lint/syntax.rb +6 -3
- data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +1 -1
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +2 -2
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -2
- data/lib/rubocop/cop/lint/useless_times.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +14 -1
- data/lib/rubocop/cop/metrics/abc_size.rb +3 -3
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
- data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -0
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +12 -4
- data/lib/rubocop/cop/naming/constant_name.rb +1 -2
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
- data/lib/rubocop/cop/security/open.rb +2 -2
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +2 -2
- data/lib/rubocop/cop/style/accessor_grouping.rb +1 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +127 -17
- data/lib/rubocop/cop/style/array_first_last.rb +64 -0
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +21 -14
- data/lib/rubocop/cop/style/bisected_attr_accessor.rb +2 -2
- data/lib/rubocop/cop/style/case_like_if.rb +4 -4
- data/lib/rubocop/cop/style/class_check.rb +1 -0
- data/lib/rubocop/cop/style/collection_compact.rb +18 -8
- data/lib/rubocop/cop/style/combinable_loops.rb +13 -7
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +2 -2
- 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/empty_literal.rb +1 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +3 -14
- data/lib/rubocop/cop/style/exact_regexp_match.rb +2 -1
- data/lib/rubocop/cop/style/explicit_block_argument.rb +2 -2
- data/lib/rubocop/cop/style/hash_each_methods.rb +105 -11
- 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/inverse_methods.rb +6 -5
- 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 +17 -7
- 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 +2 -4
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +20 -0
- data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/missing_respond_to_missing.rb +2 -2
- 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 +3 -2
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +3 -3
- 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 +10 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +33 -10
- data/lib/rubocop/cop/style/redundant_return.rb +1 -1
- data/lib/rubocop/cop/style/redundant_self.rb +17 -2
- data/lib/rubocop/cop/style/redundant_sort.rb +9 -8
- data/lib/rubocop/cop/style/redundant_sort_by.rb +2 -2
- data/lib/rubocop/cop/style/redundant_string_escape.rb +1 -1
- data/lib/rubocop/cop/style/sample.rb +2 -1
- data/lib/rubocop/cop/style/select_by_regexp.rb +7 -6
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/semicolon.rb +8 -0
- 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/super_with_args_parentheses.rb +35 -0
- 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/html_formatter.rb +1 -2
- 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/result_cache.rb +0 -1
- data/lib/rubocop/rspec/shared_contexts.rb +6 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/runner.rb +1 -1
- data/lib/rubocop/server/cache.rb +1 -2
- data/lib/rubocop/server/client_command/exec.rb +0 -1
- data/lib/rubocop/server/server_command/exec.rb +0 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +4 -0
- metadata +15 -10
- /data/lib/rubocop/formatter/{git_hub_actions_formatter.rb → github_actions_formatter.rb} +0 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# Enforces the presence of parentheses in `super` containing arguments.
|
7
|
+
#
|
8
|
+
# `super` is a keyword and is provided as a distinct cop from those designed for method call.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# super name, age
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# super(name, age)
|
17
|
+
#
|
18
|
+
class SuperWithArgsParentheses < Base
|
19
|
+
extend AutoCorrector
|
20
|
+
|
21
|
+
MSG = 'Use parentheses for `super` with arguments.'
|
22
|
+
|
23
|
+
def on_super(node)
|
24
|
+
return if node.parenthesized?
|
25
|
+
|
26
|
+
add_offense(node) do |corrector|
|
27
|
+
range = node.loc.keyword.end.join(node.first_argument.source_range.begin)
|
28
|
+
corrector.replace(range, '(')
|
29
|
+
corrector.insert_after(node.last_argument, ')')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -37,6 +37,42 @@ module RuboCop
|
|
37
37
|
# # ArgumentError: wrong number of arguments (given 1, expected 0)
|
38
38
|
# ----
|
39
39
|
#
|
40
|
+
# It is also unsafe because `Symbol#to_proc` does not work with
|
41
|
+
# `protected` methods which would otherwise be accessible.
|
42
|
+
#
|
43
|
+
# For example:
|
44
|
+
#
|
45
|
+
# [source,ruby]
|
46
|
+
# ----
|
47
|
+
# class Box
|
48
|
+
# def initialize
|
49
|
+
# @secret = rand
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# def normal_matches?(*others)
|
53
|
+
# others.map { |other| other.secret }.any?(secret)
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# def symbol_to_proc_matches?(*others)
|
57
|
+
# others.map(&:secret).any?(secret)
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# protected
|
61
|
+
#
|
62
|
+
# attr_reader :secret
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# boxes = [Box.new, Box.new]
|
66
|
+
# Box.new.normal_matches?(*boxes)
|
67
|
+
# # => false
|
68
|
+
# boxes.first.normal_matches?(*boxes)
|
69
|
+
# # => true
|
70
|
+
# Box.new.symbol_to_proc_matches?(*boxes)
|
71
|
+
# # => NoMethodError: protected method `secret' called for #<Box...>
|
72
|
+
# boxes.first.symbol_to_proc_matches?(*boxes)
|
73
|
+
# # => NoMethodError: protected method `secret' called for #<Box...>
|
74
|
+
# ----
|
75
|
+
#
|
40
76
|
# @example
|
41
77
|
# # bad
|
42
78
|
# something.map { |s| s.upcase }
|
@@ -23,38 +23,35 @@ module RuboCop
|
|
23
23
|
|
24
24
|
minimum_target_ruby_version 2.4
|
25
25
|
|
26
|
-
MSG = 'Use
|
27
|
-
'`%<receiver>s.unpack(%<format>s)%<method>s`.'
|
26
|
+
MSG = 'Use `unpack1(%<format>s)` instead of `%<current>s`.'
|
28
27
|
RESTRICT_ON_SEND = %i[first [] slice at].freeze
|
29
28
|
|
30
29
|
# @!method unpack_and_first_element?(node)
|
31
30
|
def_node_matcher :unpack_and_first_element?, <<~PATTERN
|
32
31
|
{
|
33
|
-
(
|
34
|
-
(
|
32
|
+
(call $(call (...) :unpack $(...)) :first)
|
33
|
+
(call $(call (...) :unpack $(...)) {:[] :slice :at} (int 0))
|
35
34
|
}
|
36
35
|
PATTERN
|
37
36
|
|
38
37
|
def on_send(node)
|
39
38
|
unpack_and_first_element?(node) do |unpack_call, unpack_arg|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
corrector.remove(first_element_range(node, unpack_call))
|
39
|
+
first_element_range = first_element_range(node, unpack_call)
|
40
|
+
offense_range = unpack_call.loc.selector.join(node.source_range.end)
|
41
|
+
message = format(MSG, format: unpack_arg.source, current: offense_range.source)
|
42
|
+
|
43
|
+
add_offense(offense_range, message: message) do |corrector|
|
44
|
+
corrector.remove(first_element_range)
|
47
45
|
corrector.replace(unpack_call.loc.selector, 'unpack1')
|
48
46
|
end
|
49
47
|
end
|
50
48
|
end
|
49
|
+
alias on_csend on_send
|
51
50
|
|
52
51
|
private
|
53
52
|
|
54
53
|
def first_element_range(node, unpack_call)
|
55
|
-
|
56
|
-
unpack_call.source_range.end_pos,
|
57
|
-
node.source_range.end_pos)
|
54
|
+
unpack_call.source_range.end.join(node.source_range.end)
|
58
55
|
end
|
59
56
|
end
|
60
57
|
end
|
@@ -251,9 +251,18 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
251
251
|
"\ninclude::../partials/#{filename}[]\n"
|
252
252
|
end
|
253
253
|
|
254
|
+
# rubocop:disable Metrics/MethodLength
|
254
255
|
def print_cops_of_department(department)
|
255
256
|
selected_cops = cops_of_department(department)
|
256
|
-
content =
|
257
|
+
content = +<<~HEADER
|
258
|
+
////
|
259
|
+
Do NOT edit this file by hand directly, as it is automatically generated.
|
260
|
+
|
261
|
+
Please make any necessary changes to the cop documentation within the source files themselves.
|
262
|
+
////
|
263
|
+
|
264
|
+
= #{department}
|
265
|
+
HEADER
|
257
266
|
selected_cops.each { |cop| content << print_cop_with_doc(cop) }
|
258
267
|
content << footer_for_department(department)
|
259
268
|
file_name = "#{docs_path}/#{department_to_basename(department)}.adoc"
|
@@ -262,6 +271,7 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
262
271
|
file.write("#{content.strip}\n")
|
263
272
|
end
|
264
273
|
end
|
274
|
+
# rubocop:enable Metrics/MethodLength
|
265
275
|
|
266
276
|
def print_cop_with_doc(cop) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
267
277
|
cop_config = config.for_cop(cop)
|
@@ -54,10 +54,7 @@ module RuboCop
|
|
54
54
|
return enum_for(__method__, named: named) unless block_given?
|
55
55
|
|
56
56
|
parsed_tree&.traverse do |event, exp, _index|
|
57
|
-
yield(exp) if event
|
58
|
-
named == exp.respond_to?(:name) &&
|
59
|
-
exp.respond_to?(:capturing?) &&
|
60
|
-
exp.capturing?
|
57
|
+
yield(exp) if named_capturing?(exp, event, named)
|
61
58
|
end
|
62
59
|
|
63
60
|
self
|
@@ -65,6 +62,14 @@ module RuboCop
|
|
65
62
|
|
66
63
|
private
|
67
64
|
|
65
|
+
def named_capturing?(exp, event, named)
|
66
|
+
event == :enter &&
|
67
|
+
named == exp.respond_to?(:name) &&
|
68
|
+
!exp.text.start_with?('(?<=') &&
|
69
|
+
exp.respond_to?(:capturing?) &&
|
70
|
+
exp.capturing?
|
71
|
+
end
|
72
|
+
|
68
73
|
def with_interpolations_blanked
|
69
74
|
# Ignore the trailing regopt node
|
70
75
|
children[0...-1].map do |child|
|
@@ -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
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'cgi'
|
4
4
|
require 'erb'
|
5
|
-
require 'ostruct'
|
6
5
|
|
7
6
|
module RuboCop
|
8
7
|
module Formatter
|
@@ -87,7 +86,7 @@ module RuboCop
|
|
87
86
|
# rubocop:enable Lint/UselessMethodDefinition
|
88
87
|
|
89
88
|
def decorated_message(offense)
|
90
|
-
offense.message.gsub(/`(.+?)`/) { "<code>#{Regexp.last_match(1)}</code>" }
|
89
|
+
offense.message.gsub(/`(.+?)`/) { "<code>#{escape(Regexp.last_match(1))}</code>" }
|
91
90
|
end
|
92
91
|
|
93
92
|
def highlighted_source_line(offense)
|
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
|
data/lib/rubocop/result_cache.rb
CHANGED
@@ -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/runner.rb
CHANGED
data/lib/rubocop/server/cache.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'fileutils'
|
4
3
|
require 'pathname'
|
5
4
|
require_relative '../cache_config'
|
6
5
|
require_relative '../config_finder'
|
@@ -117,7 +116,7 @@ module RuboCop
|
|
117
116
|
|
118
117
|
def pid_running?
|
119
118
|
Process.kill(0, pid_path.read.to_i) == 1
|
120
|
-
rescue Errno::ESRCH, Errno::ENOENT, Errno::EACCES
|
119
|
+
rescue Errno::ESRCH, Errno::ENOENT, Errno::EACCES, Errno::EROFS
|
121
120
|
false
|
122
121
|
end
|
123
122
|
|
@@ -16,7 +16,6 @@ module RuboCop
|
|
16
16
|
# @api private
|
17
17
|
class Exec < Base
|
18
18
|
def run
|
19
|
-
Cache.status_path.delete if Cache.status_path.file?
|
20
19
|
# RuboCop output is colorized by default where there is a TTY.
|
21
20
|
# We must pass the --color option to preserve this behavior.
|
22
21
|
@args.unshift('--color') unless %w[--color --no-color].any? { |f| @args.include?(f) }
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -332,8 +332,10 @@ 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'
|
338
|
+
require_relative 'rubocop/cop/lint/literal_assignment_in_condition'
|
337
339
|
require_relative 'rubocop/cop/lint/literal_in_interpolation'
|
338
340
|
require_relative 'rubocop/cop/lint/loop'
|
339
341
|
require_relative 'rubocop/cop/lint/missing_cop_enable_directive'
|
@@ -454,6 +456,7 @@ require_relative 'rubocop/cop/style/alias'
|
|
454
456
|
require_relative 'rubocop/cop/style/and_or'
|
455
457
|
require_relative 'rubocop/cop/style/arguments_forwarding'
|
456
458
|
require_relative 'rubocop/cop/style/array_coercion'
|
459
|
+
require_relative 'rubocop/cop/style/array_first_last'
|
457
460
|
require_relative 'rubocop/cop/style/array_intersect'
|
458
461
|
require_relative 'rubocop/cop/style/array_join'
|
459
462
|
require_relative 'rubocop/cop/style/ascii_comments'
|
@@ -678,6 +681,7 @@ require_relative 'rubocop/cop/style/string_literals_in_interpolation'
|
|
678
681
|
require_relative 'rubocop/cop/style/string_methods'
|
679
682
|
require_relative 'rubocop/cop/style/strip'
|
680
683
|
require_relative 'rubocop/cop/style/struct_inheritance'
|
684
|
+
require_relative 'rubocop/cop/style/super_with_args_parentheses'
|
681
685
|
require_relative 'rubocop/cop/style/swap_values'
|
682
686
|
require_relative 'rubocop/cop/style/symbol_array'
|
683
687
|
require_relative 'rubocop/cop/style/symbol_literal'
|
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.2
|
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-24 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
|
@@ -134,7 +134,7 @@ dependencies:
|
|
134
134
|
requirements:
|
135
135
|
- - ">="
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: 1.
|
137
|
+
version: 1.30.0
|
138
138
|
- - "<"
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '2.0'
|
@@ -144,7 +144,7 @@ dependencies:
|
|
144
144
|
requirements:
|
145
145
|
- - ">="
|
146
146
|
- !ruby/object:Gem::Version
|
147
|
-
version: 1.
|
147
|
+
version: 1.30.0
|
148
148
|
- - "<"
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '2.0'
|
@@ -294,6 +294,7 @@ files:
|
|
294
294
|
- lib/rubocop/cop/internal_affairs/method_name_end_with.rb
|
295
295
|
- lib/rubocop/cop/internal_affairs/method_name_equal.rb
|
296
296
|
- lib/rubocop/cop/internal_affairs/node_destructuring.rb
|
297
|
+
- lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb
|
297
298
|
- lib/rubocop/cop/internal_affairs/node_matcher_directive.rb
|
298
299
|
- lib/rubocop/cop/internal_affairs/node_type_predicate.rb
|
299
300
|
- lib/rubocop/cop/internal_affairs/numblock_handler.rb
|
@@ -466,8 +467,10 @@ files:
|
|
466
467
|
- lib/rubocop/cop/lint/ineffective_access_modifier.rb
|
467
468
|
- lib/rubocop/cop/lint/inherit_exception.rb
|
468
469
|
- lib/rubocop/cop/lint/interpolation_check.rb
|
470
|
+
- lib/rubocop/cop/lint/it_without_arguments_in_block.rb
|
469
471
|
- lib/rubocop/cop/lint/lambda_without_literal_block.rb
|
470
472
|
- lib/rubocop/cop/lint/literal_as_condition.rb
|
473
|
+
- lib/rubocop/cop/lint/literal_assignment_in_condition.rb
|
471
474
|
- lib/rubocop/cop/lint/literal_in_interpolation.rb
|
472
475
|
- lib/rubocop/cop/lint/loop.rb
|
473
476
|
- lib/rubocop/cop/lint/missing_cop_enable_directive.rb
|
@@ -670,6 +673,7 @@ files:
|
|
670
673
|
- lib/rubocop/cop/style/and_or.rb
|
671
674
|
- lib/rubocop/cop/style/arguments_forwarding.rb
|
672
675
|
- lib/rubocop/cop/style/array_coercion.rb
|
676
|
+
- lib/rubocop/cop/style/array_first_last.rb
|
673
677
|
- lib/rubocop/cop/style/array_intersect.rb
|
674
678
|
- lib/rubocop/cop/style/array_join.rb
|
675
679
|
- lib/rubocop/cop/style/ascii_comments.rb
|
@@ -897,6 +901,7 @@ files:
|
|
897
901
|
- lib/rubocop/cop/style/string_methods.rb
|
898
902
|
- lib/rubocop/cop/style/strip.rb
|
899
903
|
- lib/rubocop/cop/style/struct_inheritance.rb
|
904
|
+
- lib/rubocop/cop/style/super_with_args_parentheses.rb
|
900
905
|
- lib/rubocop/cop/style/swap_values.rb
|
901
906
|
- lib/rubocop/cop/style/symbol_array.rb
|
902
907
|
- lib/rubocop/cop/style/symbol_literal.rb
|
@@ -959,7 +964,7 @@ files:
|
|
959
964
|
- lib/rubocop/formatter/file_list_formatter.rb
|
960
965
|
- lib/rubocop/formatter/formatter_set.rb
|
961
966
|
- lib/rubocop/formatter/fuubar_style_formatter.rb
|
962
|
-
- lib/rubocop/formatter/
|
967
|
+
- lib/rubocop/formatter/github_actions_formatter.rb
|
963
968
|
- lib/rubocop/formatter/html_formatter.rb
|
964
969
|
- lib/rubocop/formatter/json_formatter.rb
|
965
970
|
- lib/rubocop/formatter/junit_formatter.rb
|
@@ -1023,9 +1028,9 @@ licenses:
|
|
1023
1028
|
- MIT
|
1024
1029
|
metadata:
|
1025
1030
|
homepage_uri: https://rubocop.org/
|
1026
|
-
changelog_uri: https://github.com/rubocop/rubocop/
|
1031
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.60.2
|
1027
1032
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1028
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1033
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.60/
|
1029
1034
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1030
1035
|
rubygems_mfa_required: 'true'
|
1031
1036
|
post_install_message:
|
@@ -1043,7 +1048,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1043
1048
|
- !ruby/object:Gem::Version
|
1044
1049
|
version: '0'
|
1045
1050
|
requirements: []
|
1046
|
-
rubygems_version: 3.4.
|
1051
|
+
rubygems_version: 3.4.22
|
1047
1052
|
signing_key:
|
1048
1053
|
specification_version: 4
|
1049
1054
|
summary: Automatic Ruby code style checking tool.
|
File without changes
|