Skip to content

Commit

Permalink
Fix false positive in unnecessary-some (StyraInc#460)
Browse files Browse the repository at this point in the history
Fixes StyraInc#459

Signed-off-by: Anders Eknert <[email protected]>
  • Loading branch information
anderseknert authored and srenatus committed Oct 1, 2024
1 parent 31ab02d commit e9b8942
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bundle/regal/rules/style/unnecessary_some.rego
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ report contains violation if {

walk(rule, [_, value])

value[0].type == "call"
value[0].value[0].type == "ref"
symbols := value.symbols

some_is_unnecessary(value)
symbols[0].type == "call"
symbols[0].value[0].type == "ref"

violation := result.fail(rego.metadata.chain(), result.location(value))
some_is_unnecessary(symbols)

violation := result.fail(rego.metadata.chain(), result.location(symbols))
}

some_is_unnecessary(value) if {
Expand Down
7 changes: 7 additions & 0 deletions bundle/regal/rules/style/unnecessary_some_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,10 @@ test_success_some_key_value_using_var_for_key if {
r := rule.report with input as module
r == set()
}

test_success_just_in_head if {
module := ast.with_future_keywords(`rule := [1 in []]`)

r := rule.report with input as module
r == set()
}

0 comments on commit e9b8942

Please sign in to comment.