v0.25.0
This release brings 2 new rules to the Regal linter as well as a number of improvements to the Regal Language Server.
Rules
New rule unused-output-variable
Category: bugs
In this example, if x
is unused later in the rule, it is considered an unused output variable.
package policy
allow if {
some x
role := input.user.roles[x]
# do something with "role", but not "x"
}
Unused output variables should be replaced by wildcards (_
), as it makes it clear that the variable isn't going to be used.
For more information, see the docs on unused-output-variable.
New rule use-strings-count
Category: idiomatic
strings.count
is a new OPA built-in function and should be used in place of counting indexes (count(indexof_n("foobarbaz", "a"))
) as was common before.
Not only is strings.count
more readable, but it also performs better.
For more information, see the docs on use-strings-count.
Other Rule Updates
The argument-always-wildcard
rule will now ignore mock_
prefixed functions by default, as wildcard arguments are commonly used in mocked functions.
Linter
- The JUnit XML output format is now a supported by
regal lint
. This can be used by e.g. GitLab CI/CD jobs to have linter violations printed in the code view in GitLab merge requests. Thanks @sebhoss for the work on this one! - Regal's version of OPA has been updated to v0.67.0, you'll need to be using this version to use the remediation for the
use-strings-count
rule. - The
--var-values
flag fromopa test
(added to OPA in v0.66.0) is now supported by theregal test
command. This allows custom policy authors to see the the variable values in scope of a failed test.
Regal Language Server
Code Lens Support
Regal now provides a Code Lens for direct evaluation of packages or rules within the editor, providing immediate feedback. In supported editors, you can now evaluate a package or rule by pressing "Evaluate" above its declaration, with the results displayed in-line.
code.lens.eval.mov
Input data provided via input.json
, and data.json
/data.yaml
files from bundle directories in the workspace are also available at evaluation time.
Improved Formatter
The language server can now be configured to use regal fix
as a formatter when saving buffers. In VS Code, setting opa.formatter
to regal-fix
will enable this feature.
Other editors can use this by setting the initializationOptions.formatter
.
New Contributors
Thanks @rinx for their work on creating the Regal Nix package! (and updating our docs) and @sebhoss for the JUnit output format.
Changelog
- 6a0a9b5: docs: add nixpkgs/regal to the adopters list (#920) (@rinx)
- 3abd5c0: Rule: unused-output-variable (#922) (@anderseknert)
- d3a77ce: Ensure
unused-output-variable
actually is output variable (#925) (@anderseknert) - 8382e1c: Add
except-function-name-pattern
option toargument-always-wildcard
(#924) (@anderseknert) - 886ef2e: Add
--var-values
flag toregal test
command (#930) (@anderseknert) - 69a9923: Fix false positive in
messy-rule
when ref head rules are used (#927) (@anderseknert) - 3d4e14a: build(deps): bump github/codeql-action from 3.25.12 to 3.25.13 (#932) (@dependabot[bot])
- 2a29cd2: Add JUnit output format (#929) (@sebhoss)
- c0348af: lsp: Address bug in multi file test case (#933) (@charlieegan3)
- 7565b81: docs: Update notes on neovim and packaging (#934) (@charlieegan3)
- 4a4f705: build(deps): bump github/codeql-action from 3.25.13 to 3.25.14 (#938) (@dependabot[bot])
- 5b2055b: reporter: Trim long lines of location text (#937) (@charlieegan3)
- 6c92606: Bump OPA version to v0.67.0 (#941) (@anderseknert)
- 68b2c5d: build(deps): bump ossf/scorecard-action from 2.3.3 to 2.4.0 (#946) (@dependabot[bot])
- 99fb078: build(deps): bump github/codeql-action from 3.25.14 to 3.25.15 (#945) (@dependabot[bot])
- f2b1029: Include function args in
ast.vars
(andprefer-snake-case
rule) (#947) (@anderseknert) - 7bc7868: Extend
redundant-existence-check
to fail redundant ref checks (#949) (@anderseknert) - 8a8b8ad: Rule:
prefer-strings-count
(#948) (@anderseknert) - 29f74d9: lsp: Add Neovim as known client identifier (#951) (@charlieegan3)
- af89fef: build(deps): bump golangci/golangci-lint-action from 6.0.1 to 6.1.0 (#952) (@dependabot[bot])
- d070132: lsp: Skip textDocument/completion for ignored files (#953) (@charlieegan3)
- 565f509: lsp: Poll workspace state to detect state changes (#954) (@charlieegan3)
- 4f86595: lsp: Notify when a fix fails (#955) (@charlieegan3)
- 27afe15: lsp/format,cmd/fix: Apply rego.v1 formatting by default (#958) (@charlieegan3)
- b3a79c0: build(deps): bump actions/upload-artifact from 4.3.4 to 4.3.5 (#961) (@dependabot[bot])
- 7bd66d9: Allow using
regal fix
as a formatter (#960) (@anderseknert) - dfe21e6: lsp: Auto update examples index (#956) (@charlieegan3)
- ba7c196: fix: Remove foo dir (#962) (@charlieegan3)
- 8414b8b: lsp: Update example index with PRs not commits (#963) (@charlieegan3)
- e000dd0: lsp: Update example index PR title (#966) (@charlieegan3)
- 3f3ad8e: perf: Walk less (#965) (@anderseknert)
- 95d1eb1: lsp: Update rego-by-examples index (#967) (@github-actions[bot])
- a318e6c: lsp: Add code lens support for evaluating rules (#968) (@anderseknert)
- 01b64a4: build(deps): bump actions/upload-artifact from 4.3.5 to 4.3.6 (#970) (@dependabot[bot])
- 6614f5e: build(deps): bump github/codeql-action from 3.25.15 to 3.26.0 (#971) (@dependabot[bot])
- 086cb25: docs: Fix spelling mistakes (#969) (@charlieegan3)
- 63e7155: LSP: Provide output.json option for non-VS Code clients (#972) (@anderseknert)
- ff67859: Fix code lens issue with ref head rules (#973) (@anderseknert)
- f6e2e14: lsp: No error when missing keywords for hover (#974) (@charlieegan3)
- 4ba405e: lsp: Generate correct rule name when during Eval (#975) (@charlieegan3)
- f2ac449: lsp: include
print
output in eval response (#978) (@anderseknert) - 3236efd: Add end location to
metasyntactic-variable
violations (#977) (@anderseknert) - e886f35: Add end location to
line-length
violation (#981) (@anderseknert) - 4ebdd7e: Add end location to
non-raw-regex-pattern
violations (#980) (@anderseknert) - 04b8a75: lsp/perf: don't traverse .git or .idea dirs (#984) (@anderseknert)
- fc0dc04: Document the Code Lens Evaluation feature (#983) (@anderseknert)
- c5aa188: lsp: Workspace eval, return rule head locations (#985) (@charlieegan3)
- 789fccf: build(deps): bump github/codeql-action from 3.26.0 to 3.26.1 (#986) (@dependabot[bot])
- acbdb88: lsp: Implement bundle use in workspace Eval (#987) (@charlieegan3)
- e4fcb0f: build(deps): bump github/codeql-action from 3.26.1 to 3.26.2 (#988) (@dependabot[bot])
- 1e14d08: Update capabilities.json to include
strings.count
(#990) (@anderseknert)