mt-lang 0.4.21 → 0.4.22
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/docs/language-manual.md +1 -0
- data/lib/milk_tea/base.rb +1 -1
- data/lib/milk_tea/tooling/linter/visitors.rb +17 -0
- data/lib/milk_tea/tooling/linter.rb +4 -3
- 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: 60f503669467624ebec5461f2f5fb5c3dae9216718b4c445f182323b90e9f505
|
|
4
|
+
data.tar.gz: d5ace59e3fdadbe3a7ea75f740d0d1d2953088d1799b42e9e6899c900e50595a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e74f76c097577a41ccc21462f7ede0d2c2a77f84f883e0ca3026b6b3f966e4b87ba3cfc91eca5dc16165edbc50a6f2bcff6be7ef6be751a1ba95f86b472b6e00
|
|
7
|
+
data.tar.gz: 652e7de9f0afd01aeac1358af1c47a2a19bce244ec53838b5cfc65b103d44cafea61210d01ca766bf390d4b649268d50d6ac2c057ce40e09f64e25b24c4a3d76
|
data/docs/language-manual.md
CHANGED
|
@@ -1553,6 +1553,7 @@ The auto-fix column corresponds to `mtc lint --fix`.
|
|
|
1553
1553
|
| `shadow` | warning | — | Local binding shadows an outer binding with the same name |
|
|
1554
1554
|
| `trailing-list-comma` | hint | yes | Trailing comma in call argument list is redundant |
|
|
1555
1555
|
| `unreachable-code` | warning | — | Code after a guaranteed terminator cannot execute |
|
|
1556
|
+
| `redundant-unsafe` | hint | — | `unsafe` block contains no unsafe operations and can be removed |
|
|
1556
1557
|
| `unused-import` | warning | yes | Import alias is never referenced |
|
|
1557
1558
|
| `unused-local` | warning | — | Local binding is never referenced |
|
|
1558
1559
|
| `unused-param` | warning | — | Parameter is never referenced |
|
data/lib/milk_tea/base.rb
CHANGED
|
@@ -209,6 +209,7 @@ module MilkTea
|
|
|
209
209
|
check_prefer_try(statement.expression, statement.arms)
|
|
210
210
|
end
|
|
211
211
|
when AST::UnsafeStmt
|
|
212
|
+
check_redundant_unsafe(statement)
|
|
212
213
|
@unsafe_depth += 1
|
|
213
214
|
with_scope { visit_statement_list(statement.body) }
|
|
214
215
|
@unsafe_depth -= 1
|
|
@@ -314,6 +315,7 @@ module MilkTea
|
|
|
314
315
|
check_prefer_or_pattern(expression.arms, body_of: ->(arm) { arm.value })
|
|
315
316
|
end
|
|
316
317
|
when AST::UnsafeExpr
|
|
318
|
+
check_redundant_unsafe(expression)
|
|
317
319
|
@unsafe_depth += 1
|
|
318
320
|
visit_expression(expression.expression)
|
|
319
321
|
@unsafe_depth -= 1
|
|
@@ -362,6 +364,21 @@ module MilkTea
|
|
|
362
364
|
nil
|
|
363
365
|
end
|
|
364
366
|
end
|
|
367
|
+
def check_redundant_unsafe(node)
|
|
368
|
+
return unless @sema_facts
|
|
369
|
+
return if @sema_facts.required_unsafe_lines.include?(node.line)
|
|
370
|
+
|
|
371
|
+
@warnings << Warning.new(
|
|
372
|
+
path: @path,
|
|
373
|
+
line: node.line,
|
|
374
|
+
column: node.column,
|
|
375
|
+
length: "unsafe".length,
|
|
376
|
+
code: "redundant-unsafe",
|
|
377
|
+
message: "unsafe block contains no unsafe operations and can be removed",
|
|
378
|
+
severity: :hint,
|
|
379
|
+
)
|
|
380
|
+
end
|
|
381
|
+
|
|
365
382
|
def visit_type_argument(argument)
|
|
366
383
|
visit_expression(argument.value) if argument.respond_to?(:value)
|
|
367
384
|
end
|
|
@@ -22,17 +22,17 @@ module MilkTea
|
|
|
22
22
|
borrow-and-mutate
|
|
23
23
|
constant-condition
|
|
24
24
|
dead-assignment
|
|
25
|
-
duplicate-if-condition
|
|
26
25
|
directional-ffi-arg
|
|
27
26
|
doc-tag
|
|
27
|
+
duplicate-if-condition
|
|
28
28
|
event-capacity
|
|
29
29
|
line-too-long
|
|
30
30
|
loop-single-iteration
|
|
31
31
|
missing-return
|
|
32
32
|
noop-compound-assignment
|
|
33
|
-
platform-api-drift
|
|
34
|
-
owning-release-leak
|
|
35
33
|
owning-release-double
|
|
34
|
+
owning-release-leak
|
|
35
|
+
platform-api-drift
|
|
36
36
|
prefer-conditional-expression
|
|
37
37
|
prefer-inline-if
|
|
38
38
|
prefer-inline-methods
|
|
@@ -51,6 +51,7 @@ module MilkTea
|
|
|
51
51
|
redundant-null-check
|
|
52
52
|
redundant-return
|
|
53
53
|
redundant-type-annotation
|
|
54
|
+
redundant-unsafe
|
|
54
55
|
reserved-primitive-name
|
|
55
56
|
self-assignment
|
|
56
57
|
self-comparison
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mt-lang
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.22
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Long (Teefan) Tran
|
|
@@ -630,7 +630,7 @@ metadata:
|
|
|
630
630
|
homepage_uri: https://teefan.github.io/mt-lang/
|
|
631
631
|
source_code_uri: https://github.com/teefan/mt-lang
|
|
632
632
|
post_install_message: |
|
|
633
|
-
Milk Tea 0.4.
|
|
633
|
+
Milk Tea 0.4.22 installed!
|
|
634
634
|
|
|
635
635
|
System requirements:
|
|
636
636
|
- A C compiler (gcc or clang) must be available on PATH
|