Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linter: using a local in an assertion. #723

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }