rubocop-sorbet 0.7.7 → 0.7.8
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/Gemfile.lock +2 -2
- data/lib/rubocop/cop/sorbet/forbid_t_struct.rb +35 -3
- data/lib/rubocop/sorbet/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: 68f2d0d8c272caa3933e34350356e99c32e0ec42bec4b43a39c748ef2422d048
|
4
|
+
data.tar.gz: c0bd1e275d17d85ff1a6f63ab0bad42f47e5f3f17480ac4d06e5d70f4f52973d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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, :
|
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
|
-
|
219
|
-
|
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
|
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.
|
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-
|
14
|
+
date: 2024-03-06 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|