rubocop-sorbet 0.7.7 → 0.7.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a1efe9f67422bb3173e5d5f91b3ccfd9f3862218af34495ca45e37be474ce6d
4
- data.tar.gz: aeef803f94dd5084efa7d95cb1e899dd1e901b0a992acdb1e1bfe5b3613b78d7
3
+ metadata.gz: 68f2d0d8c272caa3933e34350356e99c32e0ec42bec4b43a39c748ef2422d048
4
+ data.tar.gz: c0bd1e275d17d85ff1a6f63ab0bad42f47e5f3f17480ac4d06e5d70f4f52973d
5
5
  SHA512:
6
- metadata.gz: 607f488db395a271ab0fe3997f710f1f275d04c62b0fdd00bfb3bf4b3ffbd0274315d65d284440078fe92415b3ba7b66f364de415af004ab45f745238081de31
7
- data.tar.gz: d55d280a2c2404fe754bcb59445369b3c67c03329b4055700984e99effef6b6c53b7c44560925ee029f1a963649cbc65d30f49d30cb406fca7d92eafc83a6859
6
+ metadata.gz: 8746cfe46cc7c1f7ecc6f4310c21a725b34172168de624a02485c890b5441948e26fc4617b488365a055fa3d44ee2193a5eb41ab0c4423d06d3cea8d058ccb55
7
+ data.tar.gz: e32a6b29d524cbb963c69ba8bb7bbb6b8535ac9793c0ff80db7817aa9ce751e4a6d82161f50a2942fd3a0c17e61c70954bf4406718430cb72167564963348452
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.7.7)
4
+ rubocop-sorbet (0.7.8)
5
5
  rubocop (>= 0.90.0)
6
6
 
7
7
  GEM
@@ -54,7 +54,7 @@ GEM
54
54
  unparser (0.6.0)
55
55
  diff-lcs (~> 1.3)
56
56
  parser (>= 3.0.0)
57
- yard (0.9.25)
57
+ yard (0.9.36)
58
58
 
59
59
  PLATFORMS
60
60
  ruby
@@ -102,7 +102,7 @@ module RuboCop
102
102
  end
103
103
 
104
104
  class Property
105
- attr_reader :node, :kind, :name, :type, :default, :factory
105
+ attr_reader :node, :kind, :name, :default, :factory
106
106
 
107
107
  def initialize(node, kind, name, type, default:, factory:)
108
108
  @node = node
@@ -151,6 +151,11 @@ module RuboCop
151
151
  def nilable?
152
152
  type.start_with?("T.nilable(")
153
153
  end
154
+
155
+ def type
156
+ copy = @type.gsub(/[[:space:]]+/, "").strip # Remove newlines and spaces
157
+ copy.gsub(",", ", ") # Add a space after each comma
158
+ end
154
159
  end
155
160
 
156
161
  # @!method t_struct?(node)
@@ -215,8 +220,35 @@ module RuboCop
215
220
  sorted_props = props.sort_by { |prop| prop.default || prop.factory || prop.nilable? ? 1 : 0 }
216
221
 
217
222
  string = +"\n"
218
- string << "#{indent}sig { params(#{sorted_props.map(&:initialize_sig_param).join(", ")}).void }\n"
219
- string << "#{indent}def initialize(#{sorted_props.map(&:initialize_param).join(", ")})\n"
223
+
224
+ line = "#{indent}sig { params(#{sorted_props.map(&:initialize_sig_param).join(", ")}).void }\n"
225
+ if line.length <= max_line_length
226
+ string << line
227
+ else
228
+ string << "#{indent}sig do\n"
229
+ string << "#{indent} params(\n"
230
+ sorted_props.each do |prop|
231
+ string << "#{indent} #{prop.initialize_sig_param}"
232
+ string << "," if prop != sorted_props.last
233
+ string << "\n"
234
+ end
235
+ string << "#{indent} ).void\n"
236
+ string << "#{indent}end\n"
237
+ end
238
+
239
+ line = "#{indent}def initialize(#{sorted_props.map(&:initialize_param).join(", ")})\n"
240
+ if line.length <= max_line_length
241
+ string << line
242
+ else
243
+ string << "#{indent}def initialize(\n"
244
+ sorted_props.each do |prop|
245
+ string << "#{indent} #{prop.initialize_param}"
246
+ string << "," if prop != sorted_props.last
247
+ string << "\n"
248
+ end
249
+ string << "#{indent})\n"
250
+ end
251
+
220
252
  props.each do |prop|
221
253
  string << "#{indent} #{prop.initialize_assign}\n"
222
254
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Sorbet
5
- VERSION = "0.7.7"
5
+ VERSION = "0.7.8"
6
6
  end
7
7
  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.7.7
4
+ version: 0.7.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2024-02-09 00:00:00.000000000 Z
14
+ date: 2024-03-06 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec