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

lint: Advertise regal fix command #1016

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

charlieegan3
Copy link
Member

@charlieegan3 charlieegan3 commented Aug 28, 2024

Fixes #1014

This is the most simple implementation I could think of for this one!

…/regal regal-fix-prompt ➜ go run main.go lint package.rego

Rule:           opa-fmt
Description:    File should be formatted with `opa fmt`
Category:       style
Location:       package.rego:1:1
Text:           package p
Documentation:  https://docs.styra.com/regal/rules/style/opa-fmt

Rule:           use-rego-v1
Description:    Use `import rego.v1`
Category:       imports
Location:       package.rego:1:1
Text:           package p
Documentation:  https://docs.styra.com/regal/rules/imports/use-rego-v1

Rule:           use-assignment-operator
Description:    Prefer := over = for assignment
Category:       style
Location:       package.rego:3:3
Text:           x = 5
Documentation:  https://docs.styra.com/regal/rules/style/use-assignment-operator

1 file linted. 3 violations found.

Hint: 2/3 violations can be automatically fixed (use-rego-v1, use-assignment-operator)
      Run regal fix --help for more details.
exit status 3

}

f := fixer.NewFixer()
f.RegisterFixes(fixes.NewDefaultFixes()...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to consider what to do here if we make the new directory-package-mismatch rule custom and not "default"... but let's just make a note on that for now.

@anderseknert anderseknert merged commit 683f8de into StyraInc:main Aug 28, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inform users about regal fix when regal lint output contains fixable violations
2 participants