sonicop 26.8.113 → 26.9.100
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/Cargo.lock +35 -43
- data/Cargo.toml +5 -5
- data/lib/sonicop/version.rb +1 -1
- data/src/rules/gemspec/require_mfa.rs +1 -1
- data/src/rules/layout/access_modifier_indentation.rs +1 -1
- data/src/rules/layout/block_alignment.rs +1 -1
- data/src/rules/layout/block_end_newline.rs +1 -1
- data/src/rules/layout/empty_lines_around_arguments.rs +1 -1
- data/src/rules/layout/empty_lines_around_exception_handling_keywords.rs +1 -1
- data/src/rules/layout/first_argument_indentation.rs +1 -1
- data/src/rules/layout/first_array_element_indentation.rs +1 -1
- data/src/rules/layout/first_hash_element_indentation.rs +1 -1
- data/src/rules/layout/heredoc_argument_closing_parenthesis.rs +1 -1
- data/src/rules/layout/indentation_width.rs +1 -1
- data/src/rules/layout/multiline_brace.rs +1 -1
- data/src/rules/layout/multiline_expression.rs +2 -2
- data/src/rules/layout/space_inside_array_percent_literal.rs +1 -1
- data/src/rules/layout/space_inside_block_braces.rs +1 -1
- data/src/rules/layout/space_inside_hash_literal_braces.rs +1 -1
- data/src/rules/layout/space_inside_percent_literal_delimiters.rs +1 -1
- data/src/rules/layout/space_inside_string_interpolation.rs +1 -1
- data/src/rules/layout/support.rs +2 -5
- data/src/rules/layout/tokens.rs +1 -3
- data/src/rules/lint/access_modifier.rs +1 -1
- data/src/rules/lint/empty_conditional_body.rs +1 -1
- data/src/rules/lint/literal_in_interpolation.rs +2 -2
- data/src/rules/lint/literals.rs +89 -48
- data/src/rules/lint/loop.rs +1 -2
- data/src/rules/lint/nil_receiver.rs +1 -1
- data/src/rules/lint/node_equality.rs +5 -2
- data/src/rules/lint/non_atomic_file_operation.rs +1 -1
- data/src/rules/lint/regexp.rs +1 -1
- data/src/rules/lint/suppressed_exception.rs +1 -1
- data/src/rules/lint/syntax.rs +1 -1
- data/src/rules/lint/unreachable_loop.rs +27 -11
- data/src/rules/lint/variable_force.rs +1 -1
- data/src/rules/metrics/locals.rs +1 -1
- data/src/rules/mod.rs +83 -4
- data/src/rules/naming/support.rs +1 -1
- data/src/rules/node_ext.rs +45 -14
- data/src/rules/send_node.rs +2 -2
- data/src/rules/style/access_modifier_declarations.rs +11 -4
- data/src/rules/style/class_and_module_children.rs +2 -2
- data/src/rules/style/command_literal.rs +1 -1
- data/src/rules/style/concat_array_literals.rs +1 -1
- data/src/rules/style/conditional_assignment.rs +1 -1
- data/src/rules/style/def_with_parentheses.rs +1 -1
- data/src/rules/style/empty_else.rs +1 -1
- data/src/rules/style/format_string_token.rs +2 -2
- data/src/rules/style/hash_as_last_array_item.rs +1 -1
- data/src/rules/style/hash_conversion.rs +1 -1
- data/src/rules/style/hash_fetch_chain.rs +1 -1
- data/src/rules/style/infinite_loop.rs +1 -1
- data/src/rules/style/lambda.rs +1 -1
- data/src/rules/style/literal.rs +2 -2
- data/src/rules/style/missing_else.rs +3 -3
- data/src/rules/style/multiline_block_chain.rs +1 -1
- data/src/rules/style/multiline_memoization.rs +1 -1
- data/src/rules/style/non_nil_check.rs +1 -1
- data/src/rules/style/percent.rs +1 -1
- data/src/rules/style/percent_array.rs +3 -3
- data/src/rules/style/redundant_format.rs +2 -2
- data/src/rules/style/redundant_regexp_character_class.rs +1 -1
- data/src/rules/style/redundant_regexp_constructor.rs +1 -1
- data/src/rules/style/redundant_regexp_escape.rs +1 -1
- data/src/rules/style/regexp_literal.rs +1 -1
- data/src/rules/style/require_order.rs +6 -2
- data/src/rules/style/single_line_methods.rs +1 -1
- data/src/rules/style/string_concatenation.rs +2 -2
- data/src/rules/style/struct_inheritance.rs +1 -1
- data/src/rules/style/trailing_body_on_method_definition.rs +1 -1
- data/src/rules/style/trailing_comma.rs +1 -1
- data/src/rules/style/trailing_method_end_statement.rs +1 -1
- 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: a163c5bd6a8d400159bd4ba0f973dffb08ec9a588554d11ba4d1240962b7f4ed
|
|
4
|
+
data.tar.gz: 23e90583b4aafc8fbe66ecee0202d0fedddf45ed75d90e6060a7d5fb77345343
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0cb9a7320c8bbbe4b3fa3d773486cf66460bc5f29eb43161226dd195566210ec7cab52757c4543a01a6d9f127e0508bcb3ccb9c1ddcd95dbc6908678a202115a
|
|
7
|
+
data.tar.gz: faa62e145f9d96b10db86cf60a9a565a3c6033b8a4b28c994ecb76d99a1a4e8e79ed30775a85e1b512988117901f7b9ddb3ff19e9a8e9d116e34125a0eed03f2
|
data/Cargo.lock
CHANGED
|
@@ -67,12 +67,6 @@ version = "1.0.104"
|
|
|
67
67
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
68
68
|
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
|
69
69
|
|
|
70
|
-
[[package]]
|
|
71
|
-
name = "arrayref"
|
|
72
|
-
version = "0.3.9"
|
|
73
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
74
|
-
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
|
|
75
|
-
|
|
76
70
|
[[package]]
|
|
77
71
|
name = "arrayvec"
|
|
78
72
|
version = "0.7.8"
|
|
@@ -114,11 +108,10 @@ checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
|
|
|
114
108
|
|
|
115
109
|
[[package]]
|
|
116
110
|
name = "blake3"
|
|
117
|
-
version = "1.8.
|
|
111
|
+
version = "1.8.7"
|
|
118
112
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
119
|
-
checksum = "
|
|
113
|
+
checksum = "6d9e454fc11f76977dc803893aff6304ed33d6a26efae8696573bea74baa27ae"
|
|
120
114
|
dependencies = [
|
|
121
|
-
"arrayref",
|
|
122
115
|
"arrayvec",
|
|
123
116
|
"cc",
|
|
124
117
|
"cfg-if",
|
|
@@ -145,9 +138,9 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
|
|
145
138
|
|
|
146
139
|
[[package]]
|
|
147
140
|
name = "cc"
|
|
148
|
-
version = "1.4.
|
|
141
|
+
version = "1.4.5"
|
|
149
142
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
150
|
-
checksum = "
|
|
143
|
+
checksum = "005ec2760ca554fae18df7a11195552ec576cd665632a881bc011d5bb2fd4d80"
|
|
151
144
|
dependencies = [
|
|
152
145
|
"find-msvc-tools",
|
|
153
146
|
"shlex",
|
|
@@ -191,7 +184,7 @@ dependencies = [
|
|
|
191
184
|
"heck",
|
|
192
185
|
"proc-macro2",
|
|
193
186
|
"quote",
|
|
194
|
-
"syn 3.0.
|
|
187
|
+
"syn 3.0.5",
|
|
195
188
|
]
|
|
196
189
|
|
|
197
190
|
[[package]]
|
|
@@ -230,18 +223,18 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
|
|
230
223
|
|
|
231
224
|
[[package]]
|
|
232
225
|
name = "cpufeatures"
|
|
233
|
-
version = "0.3.
|
|
226
|
+
version = "0.3.1"
|
|
234
227
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
235
|
-
checksum = "
|
|
228
|
+
checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
|
|
236
229
|
dependencies = [
|
|
237
230
|
"libc",
|
|
238
231
|
]
|
|
239
232
|
|
|
240
233
|
[[package]]
|
|
241
234
|
name = "crossbeam-deque"
|
|
242
|
-
version = "0.8.
|
|
235
|
+
version = "0.8.8"
|
|
243
236
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
244
|
-
checksum = "
|
|
237
|
+
checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
|
|
245
238
|
dependencies = [
|
|
246
239
|
"crossbeam-epoch",
|
|
247
240
|
"crossbeam-utils",
|
|
@@ -249,24 +242,24 @@ dependencies = [
|
|
|
249
242
|
|
|
250
243
|
[[package]]
|
|
251
244
|
name = "crossbeam-epoch"
|
|
252
|
-
version = "0.9.
|
|
245
|
+
version = "0.9.21"
|
|
253
246
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
254
|
-
checksum = "
|
|
247
|
+
checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
|
|
255
248
|
dependencies = [
|
|
256
249
|
"crossbeam-utils",
|
|
257
250
|
]
|
|
258
251
|
|
|
259
252
|
[[package]]
|
|
260
253
|
name = "crossbeam-utils"
|
|
261
|
-
version = "0.8.
|
|
254
|
+
version = "0.8.23"
|
|
262
255
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
263
|
-
checksum = "
|
|
256
|
+
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
|
264
257
|
|
|
265
258
|
[[package]]
|
|
266
259
|
name = "der"
|
|
267
|
-
version = "0.8.
|
|
260
|
+
version = "0.8.2"
|
|
268
261
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
269
|
-
checksum = "
|
|
262
|
+
checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a"
|
|
270
263
|
dependencies = [
|
|
271
264
|
"pem-rfc7468",
|
|
272
265
|
"zeroize",
|
|
@@ -280,9 +273,9 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
|
|
|
280
273
|
|
|
281
274
|
[[package]]
|
|
282
275
|
name = "either"
|
|
283
|
-
version = "1.
|
|
276
|
+
version = "1.18.0"
|
|
284
277
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
285
|
-
checksum = "
|
|
278
|
+
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
|
|
286
279
|
|
|
287
280
|
[[package]]
|
|
288
281
|
name = "encoding_rs"
|
|
@@ -317,9 +310,9 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
|
|
|
317
310
|
|
|
318
311
|
[[package]]
|
|
319
312
|
name = "find-msvc-tools"
|
|
320
|
-
version = "0.1.
|
|
313
|
+
version = "0.1.12"
|
|
321
314
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
322
|
-
checksum = "
|
|
315
|
+
checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d"
|
|
323
316
|
|
|
324
317
|
[[package]]
|
|
325
318
|
name = "foreign-types"
|
|
@@ -416,9 +409,9 @@ dependencies = [
|
|
|
416
409
|
|
|
417
410
|
[[package]]
|
|
418
411
|
name = "indexmap"
|
|
419
|
-
version = "2.14.
|
|
412
|
+
version = "2.14.2"
|
|
420
413
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
421
|
-
checksum = "
|
|
414
|
+
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
|
422
415
|
dependencies = [
|
|
423
416
|
"equivalent",
|
|
424
417
|
"hashbrown",
|
|
@@ -450,9 +443,9 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
|
|
450
443
|
|
|
451
444
|
[[package]]
|
|
452
445
|
name = "log"
|
|
453
|
-
version = "0.4.
|
|
446
|
+
version = "0.4.34"
|
|
454
447
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
455
|
-
checksum = "
|
|
448
|
+
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
|
456
449
|
|
|
457
450
|
[[package]]
|
|
458
451
|
name = "memchr"
|
|
@@ -749,7 +742,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
|
749
742
|
dependencies = [
|
|
750
743
|
"proc-macro2",
|
|
751
744
|
"quote",
|
|
752
|
-
"syn 3.0.
|
|
745
|
+
"syn 3.0.5",
|
|
753
746
|
]
|
|
754
747
|
|
|
755
748
|
[[package]]
|
|
@@ -793,7 +786,7 @@ checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
|
|
793
786
|
|
|
794
787
|
[[package]]
|
|
795
788
|
name = "sonicop"
|
|
796
|
-
version = "26.
|
|
789
|
+
version = "26.9.100"
|
|
797
790
|
dependencies = [
|
|
798
791
|
"anyhow",
|
|
799
792
|
"assert_cmd",
|
|
@@ -840,9 +833,9 @@ dependencies = [
|
|
|
840
833
|
|
|
841
834
|
[[package]]
|
|
842
835
|
name = "syn"
|
|
843
|
-
version = "3.0.
|
|
836
|
+
version = "3.0.5"
|
|
844
837
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
845
|
-
checksum = "
|
|
838
|
+
checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
|
|
846
839
|
dependencies = [
|
|
847
840
|
"proc-macro2",
|
|
848
841
|
"quote",
|
|
@@ -880,13 +873,12 @@ checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683"
|
|
|
880
873
|
|
|
881
874
|
[[package]]
|
|
882
875
|
name = "tree-sitter"
|
|
883
|
-
version = "0.
|
|
876
|
+
version = "0.27.0"
|
|
884
877
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
885
|
-
checksum = "
|
|
878
|
+
checksum = "2038684e0058edba0d17302619f62eabce4a8e11c6ac59506996a8d79848851d"
|
|
886
879
|
dependencies = [
|
|
887
880
|
"cc",
|
|
888
881
|
"regex",
|
|
889
|
-
"regex-syntax",
|
|
890
882
|
"serde_json",
|
|
891
883
|
"streaming-iterator",
|
|
892
884
|
"tree-sitter-language",
|
|
@@ -894,9 +886,9 @@ dependencies = [
|
|
|
894
886
|
|
|
895
887
|
[[package]]
|
|
896
888
|
name = "tree-sitter-language"
|
|
897
|
-
version = "0.1.
|
|
889
|
+
version = "0.1.8"
|
|
898
890
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
899
|
-
checksum = "
|
|
891
|
+
checksum = "ca0d1bf6fdd806e43ae5198f82f527056d359def39e54e67a0f478ac09dac081"
|
|
900
892
|
|
|
901
893
|
[[package]]
|
|
902
894
|
name = "tree-sitter-ruby"
|
|
@@ -921,9 +913,9 @@ checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
|
|
921
913
|
|
|
922
914
|
[[package]]
|
|
923
915
|
name = "ureq"
|
|
924
|
-
version = "3.4.
|
|
916
|
+
version = "3.4.1"
|
|
925
917
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
926
|
-
checksum = "
|
|
918
|
+
checksum = "af5546be8f5378d5414f83733f5c9a2526f4645829edbc1c41790aeef1b38e8b"
|
|
927
919
|
dependencies = [
|
|
928
920
|
"base64",
|
|
929
921
|
"der",
|
|
@@ -938,9 +930,9 @@ dependencies = [
|
|
|
938
930
|
|
|
939
931
|
[[package]]
|
|
940
932
|
name = "ureq-proto"
|
|
941
|
-
version = "0.6.
|
|
933
|
+
version = "0.6.2"
|
|
942
934
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
943
|
-
checksum = "
|
|
935
|
+
checksum = "fabc3e92916c89c95b20eef7b06b00b066bc217ef9ea3a4ac9bf1a7e35261e10"
|
|
944
936
|
dependencies = [
|
|
945
937
|
"base64",
|
|
946
938
|
"http",
|
data/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "sonicop"
|
|
3
|
-
version = "26.
|
|
3
|
+
version = "26.9.100"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
rust-version = "1.85"
|
|
6
6
|
description = "A fast, native RuboCop-compatible Ruby linter and formatter"
|
|
@@ -16,7 +16,7 @@ path = "src/main.rs"
|
|
|
16
16
|
|
|
17
17
|
[dependencies]
|
|
18
18
|
anyhow = "1.0.104"
|
|
19
|
-
blake3 = "1.8.
|
|
19
|
+
blake3 = "1.8.7"
|
|
20
20
|
clap = { version = "4.6.6", features = ["derive", "wrap_help"] }
|
|
21
21
|
encoding_rs = "0.8.35"
|
|
22
22
|
fs2 = "0.4.3"
|
|
@@ -29,15 +29,15 @@ serde_json = "1.0.151"
|
|
|
29
29
|
serde_yaml_ng = "0.10"
|
|
30
30
|
shell-words = "1.1.1"
|
|
31
31
|
tempfile = "3.27.0"
|
|
32
|
-
tree-sitter = "0.
|
|
32
|
+
tree-sitter = "0.27.0"
|
|
33
33
|
tree-sitter-ruby = { git = "https://github.com/owayo/tree-sitter-ruby.git", tag = "v26.8.103" }
|
|
34
|
-
ureq = { version = "3.4", default-features = false, features = ["native-tls"] }
|
|
34
|
+
ureq = { version = "3.4.1", default-features = false, features = ["native-tls"] }
|
|
35
35
|
|
|
36
36
|
[dev-dependencies]
|
|
37
37
|
assert_cmd = "2.2.2"
|
|
38
38
|
|
|
39
39
|
[build-dependencies]
|
|
40
|
-
blake3 = "1.8.
|
|
40
|
+
blake3 = "1.8.7"
|
|
41
41
|
|
|
42
42
|
[profile.release]
|
|
43
43
|
lto = "thin"
|
data/lib/sonicop/version.rb
CHANGED
|
@@ -279,7 +279,7 @@ fn is_plain_string(node: Node<'_>) -> bool {
|
|
|
279
279
|
|
|
280
280
|
/// `node.loc.end`: the `}` or `end` a hash or a block closes with.
|
|
281
281
|
fn closing_delimiter<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
282
|
-
let last = node.child(
|
|
282
|
+
let last = node.child(node.child_count().checked_sub(1)?)?;
|
|
283
283
|
matches!(last.kind_str(), "}" | "end").then_some(last)
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -103,6 +103,6 @@ fn body_container<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
fn closing_brace<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
106
|
-
let last = node.child(
|
|
106
|
+
let last = node.child(node.child_count().checked_sub(1)?)?;
|
|
107
107
|
(last.kind_str() == "}").then_some(last)
|
|
108
108
|
}
|
|
@@ -75,7 +75,7 @@ impl<'tree> Block<'_, 'tree> {
|
|
|
75
75
|
|
|
76
76
|
/// `node.loc.end`: the `end` or the `}`.
|
|
77
77
|
fn closing(&self) -> Option<Node<'tree>> {
|
|
78
|
-
let count =
|
|
78
|
+
let count = self.braces.child_count();
|
|
79
79
|
self.braces.child(count.checked_sub(1)?)
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -69,7 +69,7 @@ pub(super) fn check(context: &RuleContext<'_>, offenses: &mut Vec<Offense>) {
|
|
|
69
69
|
|
|
70
70
|
/// `node.loc.end`: the `}` or `end` the block closes with.
|
|
71
71
|
fn closing_keyword<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
72
|
-
let last = node.child(
|
|
72
|
+
let last = node.child(node.child_count().checked_sub(1)?)?;
|
|
73
73
|
matches!(last.kind_str(), "}" | "end").then_some(last)
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -179,6 +179,6 @@ fn closing_delimiter(list: Node<'_>) -> Option<usize> {
|
|
|
179
179
|
if first.kind_str() != "(" {
|
|
180
180
|
return None;
|
|
181
181
|
}
|
|
182
|
-
let last = list.child(
|
|
182
|
+
let last = list.child(list.child_count().checked_sub(1)?)?;
|
|
183
183
|
(last.kind_str() == ")").then(|| last.start_byte())
|
|
184
184
|
}
|
|
@@ -124,6 +124,6 @@ fn last_body_and_end_on_same_line(
|
|
|
124
124
|
|
|
125
125
|
/// `node.loc.end`: the `end` of a definition or a `begin`, or the `}` a brace block closes with.
|
|
126
126
|
fn closing_keyword<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
127
|
-
let last = node.child(
|
|
127
|
+
let last = node.child(node.child_count().checked_sub(1)?)?;
|
|
128
128
|
matches!(last.kind_str(), "end" | "}").then_some(last)
|
|
129
129
|
}
|
|
@@ -286,7 +286,7 @@ fn dispatch(context: &RuleContext<'_>, call: Node<'_>) -> Option<SendParent> {
|
|
|
286
286
|
/// `node.loc.end`: the parenthesis a call's argument list closes with.
|
|
287
287
|
fn closing_parenthesis<'tree>(call: Node<'tree>) -> Option<Node<'tree>> {
|
|
288
288
|
let list = call.field("arguments")?;
|
|
289
|
-
let last = list.child(
|
|
289
|
+
let last = list.child(list.child_count().checked_sub(1)?)?;
|
|
290
290
|
(last.kind_str() == ")").then_some(last)
|
|
291
291
|
}
|
|
292
292
|
|
|
@@ -174,7 +174,7 @@ fn check_right_bracket(
|
|
|
174
174
|
fn closing<'tree>(array: Node<'tree>) -> Option<Node<'tree>> {
|
|
175
175
|
let count = array.child_count();
|
|
176
176
|
array
|
|
177
|
-
.child(
|
|
177
|
+
.child(count.checked_sub(1)?)
|
|
178
178
|
.filter(|child| matches!(child.kind_str(), "]" | ")"))
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -198,7 +198,7 @@ fn check_right_brace(
|
|
|
198
198
|
|
|
199
199
|
fn closing<'tree>(hash: Node<'tree>) -> Option<Node<'tree>> {
|
|
200
200
|
let count = hash.child_count();
|
|
201
|
-
hash.child(
|
|
201
|
+
hash.child(count.checked_sub(1)?)
|
|
202
202
|
.filter(|child| child.kind_str() == "}")
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -383,5 +383,5 @@ fn closing_token<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
fn last_child<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
386
|
-
node.child(
|
|
386
|
+
node.child(node.child_count().checked_sub(1)?)
|
|
387
387
|
}
|
|
@@ -750,7 +750,7 @@ fn has_kind(node: Node<'_>, kind: &str) -> bool {
|
|
|
750
750
|
}
|
|
751
751
|
|
|
752
752
|
fn last_child<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
753
|
-
let count =
|
|
753
|
+
let count = node.child_count();
|
|
754
754
|
node.child(count.checked_sub(1)?)
|
|
755
755
|
}
|
|
756
756
|
|
|
@@ -348,7 +348,7 @@ pub(super) fn delimiters<'tree>(
|
|
|
348
348
|
let open = node
|
|
349
349
|
.child(0)
|
|
350
350
|
.filter(|child| openers.contains(&child.kind_str()))?;
|
|
351
|
-
let last =
|
|
351
|
+
let last = node.child_count().checked_sub(1)?;
|
|
352
352
|
let close = node
|
|
353
353
|
.child(last)
|
|
354
354
|
.filter(|child| child.start_byte() > open.start_byte())?;
|
|
@@ -209,7 +209,7 @@ impl<'tree> UpNode<'tree> {
|
|
|
209
209
|
block
|
|
210
210
|
.child_count()
|
|
211
211
|
.checked_sub(1)
|
|
212
|
-
.and_then(|last| block.child(last
|
|
212
|
+
.and_then(|last| block.child(last)),
|
|
213
213
|
)
|
|
214
214
|
{
|
|
215
215
|
return open.start_position().row == close.start_position().row;
|
|
@@ -426,7 +426,7 @@ impl<'tree> UpNode<'tree> {
|
|
|
426
426
|
/// `block_node.loc.end`: the `}` or `end` the block closes with.
|
|
427
427
|
pub(super) fn block_end(self) -> Option<Range<usize>> {
|
|
428
428
|
let block = block_of(self.node)?;
|
|
429
|
-
let last = block.child(block.child_count().checked_sub(1)?
|
|
429
|
+
let last = block.child(block.child_count().checked_sub(1)?)?;
|
|
430
430
|
matches!(last.kind_str(), "}" | "end").then(|| last.byte_range())
|
|
431
431
|
}
|
|
432
432
|
|
|
@@ -12,7 +12,7 @@ pub(super) fn check(context: &RuleContext<'_>, offenses: &mut Vec<Offense>) {
|
|
|
12
12
|
let count = node.child_count();
|
|
13
13
|
let (Some(open), Some(close)) = (
|
|
14
14
|
node.child(0),
|
|
15
|
-
node.child(
|
|
15
|
+
node.child(count.saturating_sub(1)),
|
|
16
16
|
) else {
|
|
17
17
|
continue;
|
|
18
18
|
};
|
|
@@ -304,7 +304,7 @@ struct Braces<'tree> {
|
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
fn last_child<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
307
|
-
node.child(
|
|
307
|
+
node.child(node.child_count().checked_sub(1)?)
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
/// Whether `BlockNode#body` would be anything but `nil` upstream. A `;` only separates statements
|
|
@@ -34,7 +34,7 @@ pub(super) fn check(context: &RuleContext<'_>, offenses: &mut Vec<Offense>) {
|
|
|
34
34
|
let count = node.child_count();
|
|
35
35
|
let (Some(open), Some(close)) = (
|
|
36
36
|
node.child(0),
|
|
37
|
-
node.child(
|
|
37
|
+
node.child(count.saturating_sub(1)),
|
|
38
38
|
) else {
|
|
39
39
|
continue;
|
|
40
40
|
};
|
|
@@ -92,7 +92,7 @@ fn push(
|
|
|
92
92
|
/// The literal's opening and closing delimiter spans.
|
|
93
93
|
fn delimiters(node: Node<'_>) -> Option<(Range<usize>, Range<usize>)> {
|
|
94
94
|
let first = node.child(0)?;
|
|
95
|
-
let last = node.child(
|
|
95
|
+
let last = node.child(node.child_count().saturating_sub(1))?;
|
|
96
96
|
if first.end_byte() > last.start_byte() {
|
|
97
97
|
return None;
|
|
98
98
|
}
|
|
@@ -12,7 +12,7 @@ pub(super) fn check(context: &RuleContext<'_>, offenses: &mut Vec<Offense>) {
|
|
|
12
12
|
let count = node.child_count();
|
|
13
13
|
let (Some(open), Some(close)) = (
|
|
14
14
|
node.child(0),
|
|
15
|
-
node.child(
|
|
15
|
+
node.child(count.saturating_sub(1)),
|
|
16
16
|
) else {
|
|
17
17
|
continue;
|
|
18
18
|
};
|
data/src/rules/layout/support.rs
CHANGED
|
@@ -487,10 +487,7 @@ pub(super) fn string_interiors(
|
|
|
487
487
|
if count < 2 {
|
|
488
488
|
continue;
|
|
489
489
|
}
|
|
490
|
-
let (Some(first), Some(last)) = (
|
|
491
|
-
node.child(0),
|
|
492
|
-
node.child(u32::try_from(count).unwrap_or(0).saturating_sub(1)),
|
|
493
|
-
) else {
|
|
490
|
+
let (Some(first), Some(last)) = (node.child(0), node.child(count.saturating_sub(1))) else {
|
|
494
491
|
continue;
|
|
495
492
|
};
|
|
496
493
|
if first.end_byte() <= last.start_byte() {
|
|
@@ -810,7 +807,7 @@ pub(super) fn end_keyword<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
|
810
807
|
}
|
|
811
808
|
|
|
812
809
|
fn last_child<'tree>(node: Node<'tree>) -> Option<Node<'tree>> {
|
|
813
|
-
node.child(
|
|
810
|
+
node.child(node.child_count().checked_sub(1)?)
|
|
814
811
|
}
|
|
815
812
|
|
|
816
813
|
/// `start_line_range`: the line an offset sits on, without its indentation or its trailing blanks.
|
data/src/rules/layout/tokens.rs
CHANGED
|
@@ -322,9 +322,7 @@ fn delimiter_kind(literal: Node<'_>, part: Node<'_>) -> TokenKind {
|
|
|
322
322
|
if literal.kind_str() != "string" {
|
|
323
323
|
return TokenKind::Other;
|
|
324
324
|
}
|
|
325
|
-
let last =
|
|
326
|
-
.unwrap_or(0)
|
|
327
|
-
.saturating_sub(1);
|
|
325
|
+
let last = literal.child_count().saturating_sub(1);
|
|
328
326
|
if literal.child(0) == Some(part) {
|
|
329
327
|
return TokenKind::StringBegin;
|
|
330
328
|
}
|
|
@@ -200,6 +200,6 @@ fn then_keyword<'tree>(node: Node<'tree>, context: &'tree RuleContext<'_>) -> Op
|
|
|
200
200
|
|
|
201
201
|
/// `node.loc.end`: the `end` keyword, which an `elsif` borrows from the `if` it belongs to.
|
|
202
202
|
fn end_keyword<'tree>(node: Node<'tree>, context: &RuleContext<'_>) -> Option<Node<'tree>> {
|
|
203
|
-
let last = node.child(
|
|
203
|
+
let last = node.child(node.child_count().checked_sub(1)?)?;
|
|
204
204
|
(context.source.node_text(last) == "end").then_some(last)
|
|
205
205
|
}
|
|
@@ -344,7 +344,7 @@ fn symbol_content<'a>(node: Node<'_>, context: &'a RuleContext<'_>) -> &'a str {
|
|
|
344
344
|
_ => {
|
|
345
345
|
let opener = node.child(0).map_or(0, |open| open.end_byte());
|
|
346
346
|
let closer = node
|
|
347
|
-
.child(node.child_count().saturating_sub(1)
|
|
347
|
+
.child(node.child_count().saturating_sub(1))
|
|
348
348
|
.map_or(node.end_byte(), |close| close.start_byte());
|
|
349
349
|
&context.source.text()[opener..closer.max(opener)]
|
|
350
350
|
}
|
|
@@ -360,7 +360,7 @@ fn array_value(node: Node<'_>, context: &RuleContext<'_>) -> String {
|
|
|
360
360
|
.child(0)
|
|
361
361
|
.map_or(node.start_byte(), |open| open.end_byte());
|
|
362
362
|
let closer = node
|
|
363
|
-
.child(node.child_count().saturating_sub(1)
|
|
363
|
+
.child(node.child_count().saturating_sub(1))
|
|
364
364
|
.map_or(node.end_byte(), |close| close.start_byte());
|
|
365
365
|
let words: Vec<String> = context.source.text()[opener..closer.max(opener)]
|
|
366
366
|
.split_whitespace()
|