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

rule: Require ordering of default rule before other rule heads #699

Closed
charlieegan3 opened this issue May 8, 2024 · 0 comments · Fixed by #716
Closed

rule: Require ordering of default rule before other rule heads #699

charlieegan3 opened this issue May 8, 2024 · 0 comments · Fixed by #716

Comments

@charlieegan3
Copy link
Member

charlieegan3 commented May 8, 2024

This is an idea for a new rule.

The example below would violate the rule, as the default keyword is after the other rule head.

package example

import rego.v1

allow if input.admin

default allow := false

This fix:

package example

import rego.v1

default allow := false

allow if input.admin

The rationale for this would be that as more rule heads are added, the default definition is pushed farther and farther down the file and this more likely to be missed.

This rule should only apply to rule heads in one source file, if the default is elsewhere, then that's ok.

@charlieegan3 charlieegan3 added the good first issue Good for newcomers label May 8, 2024
anderseknert added a commit that referenced this issue May 13, 2024
Simple rule to check that `default` rules are placed before non-default rules.

Fixes #699

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue May 14, 2024
Simple rule to check that `default` rules are placed before non-default rules.

Fixes #699

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue May 14, 2024
Simple rule to check that `default` rules are placed before non-default rules.

Fixes #699

Signed-off-by: Anders Eknert <anders@styra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants