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

Ref-head rules aren't currently handled by Regal #276

Closed
anderseknert opened this issue Aug 28, 2023 · 1 comment · Fixed by #278
Closed

Ref-head rules aren't currently handled by Regal #276

anderseknert opened this issue Aug 28, 2023 · 1 comment · Fixed by #278
Labels
bug Something isn't working

Comments

@anderseknert
Copy link
Member

Running Regal against some modern Rego where ref-head rules are used, I'm seeing some false positives. This isn't particularly strange considering we've not really had those in mind before, but that's definitely something we should do, and I'd suggest going through all rules where this would be relevant and add test cases to assert these rules are dealt with correctly. Example:

p.rego

package p

import future.keywords.if

a["b"] if input.c
$ regal lint p.rego
Rule:         	use-assignment-operator
Description:  	Prefer := over = for assignment
Category:     	style
Location:     	p.rego:5:1
Text:         	a["b"] if input.c
Documentation:	https://docs.styra.com/regal/rules/style/use-assignment-operator

1 file linted. 1 violation found.

This is obviously not right, as there's no explicit assignment happening here. I'm sure there are more false positives in other rules, so let's try to fix this.

@anderseknert anderseknert added the bug Something isn't working label Aug 28, 2023
@anderseknert
Copy link
Member Author

While this issue is valid, the example above wasn't great, and it took me quite some time to understand why: open-policy-agent/opa#6184

anderseknert added a commit that referenced this issue Aug 30, 2023
The name attribute is not present in ref-head rules, so
make sure things keep working when those are around.

Fixes #276

Note though that the rules don't yet necessarily take
all ref names into account. Will look at that separately.
Just fix the bug for now.

Signed-off-by: Anders Eknert <[email protected]>
anderseknert added a commit that referenced this issue Aug 30, 2023
The name attribute is not present in ref-head rules, so
make sure things keep working when those are around.

Fixes #276

Note though that the rules don't yet necessarily take
all ref names into account. Will look at that separately.
Just fix the bug for now.

Signed-off-by: Anders Eknert <[email protected]>
srenatus pushed a commit to srenatus/regal that referenced this issue Oct 1, 2024
The name attribute is not present in ref-head rules, so
make sure things keep working when those are around.

Fixes StyraInc#276

Note though that the rules don't yet necessarily take
all ref names into account. Will look at that separately.
Just fix the bug for now.

Signed-off-by: Anders Eknert <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant