diff --git a/bundle/regal/rules/style/unnecessary_some.rego b/bundle/regal/rules/style/unnecessary_some.rego index 624ba41d..ec120d8c 100644 --- a/bundle/regal/rules/style/unnecessary_some.rego +++ b/bundle/regal/rules/style/unnecessary_some.rego @@ -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 { diff --git a/bundle/regal/rules/style/unnecessary_some_test.rego b/bundle/regal/rules/style/unnecessary_some_test.rego index caebe3e8..134504a9 100644 --- a/bundle/regal/rules/style/unnecessary_some_test.rego +++ b/bundle/regal/rules/style/unnecessary_some_test.rego @@ -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() +}