rubocop-sorbet 0.13.0 → 0.13.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/.github/workflows/stale.yml +1 -1
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb +26 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c51ae13ac2c32733024c71003fa884392ea9ba66a7a02638a7f000f1ca59ffc3
|
|
4
|
+
data.tar.gz: 3d665a684394894867652ee120361c9e03d2f41a6ef713d91b89f6a927bde8ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47098214ac3bf1ca4d3c26ebce8a7668bf02179180d4c7407965c4d3a6e436df67af6e7850b19787e5bbbe5265ebc35a5958bc424c4fb043d69cf7b157cdba76
|
|
7
|
+
data.tar.gz: bb120a2eab93d930a407a3d34e1f1d407eda219cfb0410d4a0a31cb8ccfc91d2d410634c8eb0c7d81e38af406631c458b29145c5f5e0e61455c0764d9477ab75
|
data/.github/workflows/stale.yml
CHANGED
|
@@ -12,7 +12,7 @@ jobs:
|
|
|
12
12
|
stale:
|
|
13
13
|
runs-on: ubuntu-latest
|
|
14
14
|
steps:
|
|
15
|
-
- uses: actions/stale@
|
|
15
|
+
- uses: actions/stale@1e223db275d687790206a7acac4d1a11bd6fe629 # v10.4.0
|
|
16
16
|
with:
|
|
17
17
|
stale-pr-message: >
|
|
18
18
|
This PR has been automatically marked as stale because it has not had
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.13.
|
|
1
|
+
0.13.1
|
|
@@ -31,6 +31,11 @@ module RuboCop
|
|
|
31
31
|
VALID_STYLES = ["sig", "rbs", "both"].freeze
|
|
32
32
|
VALID_AUTOCORRECT_STYLES = ["sig", "rbs"].freeze
|
|
33
33
|
|
|
34
|
+
# Represents a method parameter with its name and AST node kind.
|
|
35
|
+
# @kind is the RuboCop AST node type (:arg, :optarg, :restarg, :kwarg,
|
|
36
|
+
# :kwoptarg, :kwrestarg, :forward_arg, :blockarg).
|
|
37
|
+
Param = Struct.new(:name, :kind)
|
|
38
|
+
|
|
34
39
|
# @!method accessor?(node)
|
|
35
40
|
def_node_matcher(:accessor?, <<-PATTERN)
|
|
36
41
|
(send nil? {:attr_reader :attr_writer :attr_accessor} ...)
|
|
@@ -140,7 +145,7 @@ module RuboCop
|
|
|
140
145
|
if arg.blockarg_type? && suggest.respond_to?(:has_block=)
|
|
141
146
|
suggest.has_block = true
|
|
142
147
|
else
|
|
143
|
-
suggest.params << arg.children.first
|
|
148
|
+
suggest.params << Param.new(arg.children.first, arg.type)
|
|
144
149
|
end
|
|
145
150
|
end
|
|
146
151
|
end
|
|
@@ -156,7 +161,7 @@ module RuboCop
|
|
|
156
161
|
def add_accessor_parameter_if_needed(suggest, symbol, method)
|
|
157
162
|
return unless symbol && writer_or_accessor?(method)
|
|
158
163
|
|
|
159
|
-
suggest.params << symbol.value
|
|
164
|
+
suggest.params << Param.new(symbol.value, :arg)
|
|
160
165
|
end
|
|
161
166
|
|
|
162
167
|
def set_void_return_for_writer(suggest, method)
|
|
@@ -278,7 +283,7 @@ module RuboCop
|
|
|
278
283
|
def generate_params
|
|
279
284
|
return "" if @params.empty?
|
|
280
285
|
|
|
281
|
-
param_list = @params.map { |param| "#{param}: #{@param_placeholder}" }.join(", ")
|
|
286
|
+
param_list = @params.map { |param| "#{param.name}: #{@param_placeholder}" }.join(", ")
|
|
282
287
|
"params(#{param_list})."
|
|
283
288
|
end
|
|
284
289
|
|
|
@@ -310,7 +315,7 @@ module RuboCop
|
|
|
310
315
|
private
|
|
311
316
|
|
|
312
317
|
def generate_signature
|
|
313
|
-
param_types = @params.map {
|
|
318
|
+
param_types = @params.map { |param| rbs_param(param) }.join(", ")
|
|
314
319
|
return_type = @returns || "untyped"
|
|
315
320
|
|
|
316
321
|
signature = if @params.empty?
|
|
@@ -324,6 +329,23 @@ module RuboCop
|
|
|
324
329
|
|
|
325
330
|
signature
|
|
326
331
|
end
|
|
332
|
+
|
|
333
|
+
def rbs_param(param)
|
|
334
|
+
case param.kind
|
|
335
|
+
when :kwarg
|
|
336
|
+
"#{param.name}: untyped"
|
|
337
|
+
when :kwoptarg
|
|
338
|
+
"?#{param.name}: untyped"
|
|
339
|
+
when :optarg
|
|
340
|
+
"?untyped"
|
|
341
|
+
when :restarg
|
|
342
|
+
"*untyped"
|
|
343
|
+
when :kwrestarg
|
|
344
|
+
"**untyped"
|
|
345
|
+
else
|
|
346
|
+
"untyped"
|
|
347
|
+
end
|
|
348
|
+
end
|
|
327
349
|
end
|
|
328
350
|
end
|
|
329
351
|
end
|