platformos-check 0.3.3 → 0.4.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b962e236b71ab785e3e566413ae86c64c6d767d26d8871606cc639b1eae7023e
|
4
|
+
data.tar.gz: 0df29d550f5779ebe29ac285809144998d49cd7a8d8049769ac023d65cdde3de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8bcd3931092d2621dd74f174790ecc13213db17c56d11a9a174bdda6b5e7e22f8526b93553225fa6d884eb4af74e5249c2f78da2e88ad794f3b4064f935be33
|
7
|
+
data.tar.gz: ba1ca314fc5d0a154f2f74f52002204da03ce80edae7763e633b46fca31e56329f63f8e7343c52093c081c304c31e9462e5c8f52add1d328cf372e63005826fb
|
data/CHANGELOG.md
CHANGED
@@ -4,12 +4,11 @@ This check prevents errors by making sure that no undefined variables are being
|
|
4
4
|
|
5
5
|
## Check Details
|
6
6
|
|
7
|
-
This check is aimed at eliminating undefined object errors.
|
7
|
+
This check is aimed at eliminating undefined object errors. Additionally it reports any missing or unused attributes in render, function and background tags.
|
8
8
|
|
9
9
|
:-1: Examples of **incorrect** code for this check:
|
10
10
|
|
11
11
|
```liquid
|
12
|
-
{% assign greetings = "Hello" %}
|
13
12
|
{% if greeting == "Hello" %}
|
14
13
|
Hello
|
15
14
|
{% endif %}
|
@@ -31,7 +30,7 @@ This check is aimed at eliminating undefined object errors.
|
|
31
30
|
```liquid
|
32
31
|
{% liquid
|
33
32
|
# my_function body
|
34
|
-
assign my_arg = my_arg
|
33
|
+
assign my_arg = my_arg | default: nil
|
35
34
|
return my_arg
|
36
35
|
%}
|
37
36
|
```
|
@@ -196,9 +196,12 @@ module PlatformosCheck
|
|
196
196
|
|
197
197
|
def check_undefined(info, all_global_objects, render_node)
|
198
198
|
all_variables = info.all_variables
|
199
|
-
|
199
|
+
potentially_unused_variables = render_node.value.attributes.keys if render_node
|
200
200
|
info.each_variable_lookup(!!render_node) do |(key, node)|
|
201
201
|
name, line_number = key
|
202
|
+
|
203
|
+
potentially_unused_variables&.delete(name)
|
204
|
+
|
202
205
|
next if all_variables.include?(name)
|
203
206
|
next if all_global_objects.include?(name)
|
204
207
|
|
@@ -213,6 +216,11 @@ module PlatformosCheck
|
|
213
216
|
add_offense("Undefined object `#{name}`", node:, line_number:)
|
214
217
|
end
|
215
218
|
end
|
219
|
+
|
220
|
+
potentially_unused_variables -= render_node.value.internal_attributes if render_node && render_node.value.respond_to?(:internal_attributes)
|
221
|
+
potentially_unused_variables&.each do |name|
|
222
|
+
add_offense("Unused argument `#{name}`", node: render_node)
|
223
|
+
end
|
216
224
|
end
|
217
225
|
end
|
218
226
|
end
|
@@ -5,6 +5,7 @@ module PlatformosCheck
|
|
5
5
|
class Background < Base
|
6
6
|
PARTIAL_SYNTAX = /(#{Liquid::VariableSignature}+)\s*=\s*(.*)\s*/om
|
7
7
|
CLOSE_TAG_SYNTAX = /\A(.*)(?-mix:\{%-?)\s*(\w+)\s*(.*)?(?-mix:%\})\z/m # based on Liquid::Raw::FullTokenPossiblyInvalid
|
8
|
+
INTERNAL_ATTRIBUTES = %w[delay priority max_attempts source_name]
|
8
9
|
|
9
10
|
attr_reader :to, :from, :attributes, :value_expr, :partial_syntax, :partial_name
|
10
11
|
|
@@ -27,6 +28,10 @@ module PlatformosCheck
|
|
27
28
|
@attributes = attributes_expr
|
28
29
|
end
|
29
30
|
|
31
|
+
def internal_attributes
|
32
|
+
INTERNAL_ATTRIBUTES
|
33
|
+
end
|
34
|
+
|
30
35
|
def parse(tokens)
|
31
36
|
return super if @partial_syntax
|
32
37
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: platformos-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Bliszczyk
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-09-
|
13
|
+
date: 2023-09-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: graphql
|