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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5dcbac6e0a2af2d4bed5b33ef9bd2d9cfad4608a400dc2f81e0c8c338543615
4
- data.tar.gz: 9960e81847d7cda7ffb4b94d9dff22ac65f3c2b9c74664c931684b492d7da14e
3
+ metadata.gz: c51ae13ac2c32733024c71003fa884392ea9ba66a7a02638a7f000f1ca59ffc3
4
+ data.tar.gz: 3d665a684394894867652ee120361c9e03d2f41a6ef713d91b89f6a927bde8ea
5
5
  SHA512:
6
- metadata.gz: 7a0e44a9cc6fd67dd8fb564015f9dfee1e76c510d2b5e3dd853cffb72ee4f6b30948593f8d96f008749fdcbb5a70b02b11342396787a8e48f1fd9b11a6f308cd
7
- data.tar.gz: 647911f5d12c0a8459e92ee71b0cd3bc01b7d4e8b15195555e82194499f4b57423d2307854f080f00132bf64f86d2356cefc6b22c545cda00b24427cbbb4fd9c
6
+ metadata.gz: 47098214ac3bf1ca4d3c26ebce8a7668bf02179180d4c7407965c4d3a6e436df67af6e7850b19787e5bbbe5265ebc35a5958bc424c4fb043d69cf7b157cdba76
7
+ data.tar.gz: bb120a2eab93d930a407a3d34e1f1d407eda219cfb0410d4a0a31cb8ccfc91d2d410634c8eb0c7d81e38af406631c458b29145c5f5e0e61455c0764d9477ab75
@@ -12,7 +12,7 @@ jobs:
12
12
  stale:
13
13
  runs-on: ubuntu-latest
14
14
  steps:
15
- - uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.13.0)
4
+ rubocop-sorbet (0.13.1)
5
5
  lint_roller
6
6
  rubocop (>= 1.75.2)
7
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.0
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 { "untyped" }.join(", ")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-sorbet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu