Skip to content

Commit

Permalink
Fix linter: using a local in an assertion. (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
netomi committed Jun 10, 2024
1 parent 04f3751 commit e0c6a9e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions linter/internal/variables/find_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func findVariablesInObject(node *ast.DesugaredObject, info *common.VariableInfo,
for _, local := range node.Locals {
findVariables(local.Body, info, scopeInside)
}
for _, assert := range node.Asserts {
findVariables(assert, info, scopeInside)
}
for _, field := range node.Fields {
findVariables(field.Body, info, scopeInside)
findVariables(field.Name, info, scopeOutside)
Expand Down
6 changes: 6 additions & 0 deletions linter/testdata/local_used_in_assertion.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
local input = [1,2,3],
local knownItems = [1,2],
local unknownItems = std.filter(function(i) !(i in knownItems), input),
assert unknownItems == [] : "unexpected items: %s" % std.join(",",unknownItems)
}
Empty file.
5 changes: 0 additions & 5 deletions testdata/local_in_object_assertion.linter.golden
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
../testdata/local_in_object_assertion:1:9-15 Unused variable: x

{ local x = 42, assert x == 42 }


0 comments on commit e0c6a9e

Please sign in to comment.