rubocop 1.56.1 → 1.56.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +17 -9
- data/lib/rubocop/cop/layout/redundant_line_break.rb +1 -1
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +8 -4
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +5 -3
- data/lib/rubocop/cop/style/arguments_forwarding.rb +9 -1
- data/lib/rubocop/lsp/routes.rb +4 -1
- data/lib/rubocop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 061c4fd159baec4f143f014ae432ec3607b0846cb46b3a4566a224922b6c5c7b
|
4
|
+
data.tar.gz: 943c45cc27dbbb861f6b2a910216a016c06e2ace63824c30a7ad922caabfed59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d5900ca290d826af3658c1d481a7778b44a4d57455d69c96c603bac7679c4b275cd192339e683e6ba020201e0dbb23ee3e64f9fbc953cc5bf4832ce1c293bbb
|
7
|
+
data.tar.gz: dfc761f98d05680a21093ce5092b933ff8534f7b7ed5f7c46ec52586673db9ad60b495e896b429499d151c6af827a30d1e67c2e1bf397f9a7947b1c0bff836ab
|
@@ -57,16 +57,13 @@ module RuboCop
|
|
57
57
|
|
58
58
|
end_of_first_line = node.source_range.begin_pos - node.source_range.column
|
59
59
|
|
60
|
-
raw_lines(node)
|
60
|
+
lines = raw_lines(node)
|
61
|
+
lines.each_cons(2).with_index(node.first_line) do |(raw_line_one, raw_line_two), line_num|
|
61
62
|
end_of_first_line += raw_line_one.length
|
62
63
|
|
63
|
-
next unless continuation?(raw_line_one)
|
64
|
+
next unless continuation?(raw_line_one, line_num, node)
|
64
65
|
|
65
|
-
|
66
|
-
investigate_leading_style(raw_line_one, raw_line_two, end_of_first_line)
|
67
|
-
else
|
68
|
-
investigate_trailing_style(raw_line_one, raw_line_two, end_of_first_line)
|
69
|
-
end
|
66
|
+
investigate(raw_line_one, raw_line_two, end_of_first_line)
|
70
67
|
end
|
71
68
|
end
|
72
69
|
|
@@ -76,6 +73,14 @@ module RuboCop
|
|
76
73
|
processed_source.raw_source.lines[node.first_line - 1, line_range(node).size]
|
77
74
|
end
|
78
75
|
|
76
|
+
def investigate(first_line, second_line, end_of_first_line)
|
77
|
+
if enforced_style_leading?
|
78
|
+
investigate_leading_style(first_line, second_line, end_of_first_line)
|
79
|
+
else
|
80
|
+
investigate_trailing_style(first_line, second_line, end_of_first_line)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
79
84
|
def investigate_leading_style(first_line, second_line, end_of_first_line)
|
80
85
|
matches = first_line.match(LEADING_STYLE_OFFENSE)
|
81
86
|
return if matches.nil?
|
@@ -98,8 +103,11 @@ module RuboCop
|
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
101
|
-
def continuation?(line)
|
102
|
-
line.end_with?("\\\n")
|
106
|
+
def continuation?(line, line_num, node)
|
107
|
+
return false unless line.end_with?("\\\n")
|
108
|
+
|
109
|
+
# Ensure backslash isn't part of a token spanning to the next line.
|
110
|
+
node.children.none? { |c| c.first_line == line_num && c.multiline? }
|
103
111
|
end
|
104
112
|
|
105
113
|
def autocorrect(corrector, offense_range, insert_pos, spaces)
|
@@ -106,7 +106,7 @@ module RuboCop
|
|
106
106
|
|
107
107
|
def suitable_as_single_line?(node)
|
108
108
|
!comment_within?(node) &&
|
109
|
-
node.each_descendant(:if, :case, :kwbegin, :def).none? &&
|
109
|
+
node.each_descendant(:if, :case, :kwbegin, :def, :defs).none? &&
|
110
110
|
node.each_descendant(:dstr, :str).none? { |n| n.heredoc? || n.value.include?("\n") } &&
|
111
111
|
node.each_descendant(:begin).none? { |b| !b.single_line? }
|
112
112
|
end
|
@@ -51,10 +51,12 @@ module RuboCop
|
|
51
51
|
MAKE_FORCE_METHODS = %i[makedirs mkdir_p mkpath].freeze
|
52
52
|
MAKE_METHODS = %i[mkdir].freeze
|
53
53
|
REMOVE_FORCE_METHODS = %i[rm_f rm_rf].freeze
|
54
|
-
REMOVE_METHODS = %i[remove
|
55
|
-
|
56
|
-
RESTRICT_ON_SEND = (
|
57
|
-
|
54
|
+
REMOVE_METHODS = %i[remove delete unlink remove_file rm rmdir safe_unlink].freeze
|
55
|
+
RECURSIVE_REMOVE_METHODS = %i[remove_dir remove_entry remove_entry_secure].freeze
|
56
|
+
RESTRICT_ON_SEND = (
|
57
|
+
MAKE_METHODS + MAKE_FORCE_METHODS + REMOVE_METHODS + RECURSIVE_REMOVE_METHODS +
|
58
|
+
REMOVE_FORCE_METHODS
|
59
|
+
).freeze
|
58
60
|
|
59
61
|
# @!method send_exist_node(node)
|
60
62
|
def_node_search :send_exist_node, <<~PATTERN
|
@@ -140,6 +142,8 @@ module RuboCop
|
|
140
142
|
'mkdir_p'
|
141
143
|
elsif REMOVE_METHODS.include?(node.method_name)
|
142
144
|
'rm_f'
|
145
|
+
elsif RECURSIVE_REMOVE_METHODS.include?(node.method_name)
|
146
|
+
'rm_rf'
|
143
147
|
else
|
144
148
|
node.method_name
|
145
149
|
end
|
@@ -74,7 +74,7 @@ module RuboCop
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
77
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
78
78
|
def argument_match?(send_arg, def_arg)
|
79
79
|
def_arg_name = def_arg.children[0]
|
80
80
|
|
@@ -87,12 +87,14 @@ module RuboCop
|
|
87
87
|
send_arg.hash_type? &&
|
88
88
|
send_arg.pairs.any? { |pair| passing_keyword_arg?(pair, def_arg_name) }
|
89
89
|
when :kwrestarg
|
90
|
-
send_arg.each_child_node(:kwsplat).any?
|
90
|
+
send_arg.each_child_node(:kwsplat, :forwarded_kwrestarg).any? do |child|
|
91
|
+
child.source == def_arg.source
|
92
|
+
end
|
91
93
|
when :forward_arg
|
92
94
|
send_arg.forwarded_args_type?
|
93
95
|
end
|
94
96
|
end
|
95
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
97
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
@@ -291,7 +291,7 @@ module RuboCop
|
|
291
291
|
return false if any_arg_referenced?
|
292
292
|
return false if ruby_32_missing_rest_or_kwest?
|
293
293
|
return false unless offensive_block_forwarding?
|
294
|
-
return false if
|
294
|
+
return false if additional_kwargs_or_forwarded_kwargs?
|
295
295
|
|
296
296
|
no_additional_args? || (target_ruby_version >= 3.0 && no_post_splat_args?)
|
297
297
|
end
|
@@ -339,6 +339,14 @@ module RuboCop
|
|
339
339
|
[nil, :hash, :block_pass].include?(arg_after_splat&.type)
|
340
340
|
end
|
341
341
|
|
342
|
+
def additional_kwargs_or_forwarded_kwargs?
|
343
|
+
additional_kwargs? || forward_additional_kwargs?
|
344
|
+
end
|
345
|
+
|
346
|
+
def additional_kwargs?
|
347
|
+
@def_node.arguments.any? { |a| a.kwarg_type? || a.kwoptarg_type? }
|
348
|
+
end
|
349
|
+
|
342
350
|
def forward_additional_kwargs?
|
343
351
|
return false unless forwarded_kwrest_arg
|
344
352
|
|
data/lib/rubocop/lsp/routes.rb
CHANGED
@@ -45,7 +45,10 @@ module RuboCop
|
|
45
45
|
result: LanguageServer::Protocol::Interface::InitializeResult.new(
|
46
46
|
capabilities: LanguageServer::Protocol::Interface::ServerCapabilities.new(
|
47
47
|
document_formatting_provider: true,
|
48
|
-
diagnostic_provider:
|
48
|
+
diagnostic_provider: LanguageServer::Protocol::Interface::DiagnosticOptions.new(
|
49
|
+
inter_file_dependencies: false,
|
50
|
+
workspace_diagnostics: false
|
51
|
+
),
|
49
52
|
text_document_sync: LanguageServer::Protocol::Interface::TextDocumentSyncOptions.new(
|
50
53
|
change: LanguageServer::Protocol::Constant::TextDocumentSyncKind::FULL,
|
51
54
|
open_close: true
|
data/lib/rubocop/version.rb
CHANGED
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.56.
|
4
|
+
version: 1.56.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: 2023-08-
|
13
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: base64
|