v0.14.0
This release brings 2 new linter rules, a new output format, and many improvements and fixes.
New rule: boolean-assignment
Category: idiomatic
Assigning the result of a boolean expression is often redundant, and the expression is better placed in the rule body, following an if
. This also makes for a more readable rule.
# Instead of this
more_than_one_member := count(input.members) > 1
# Prefer this
more_than_one_member if count(input.members) > 1
For more information, see the docs on boolean-assignment.
New rule: redundant-existence-check
Category: bugs
Checking whether a reference is defined immediately before it's used isn't needed, as an undefined value will have evaluation fail either way:
# Instead of this
employee if {
input.user.email
endswith(input.user.email, "@acmecorp.com")
}
# Prefer this
employee if {
endswith(input.user.email, "@acmecorp.com")
}
For more information, see the docs on redundant-existence-check.
New SARIF output format
SARIF is a standardized output format used and supported by many tools working with static analysis and code quality. Use --format sarif
to have regal lint
generate standard SARIF output, which can then be consumed by a number of tools.
Bugs fixed
- Fix false positive in the unused-return-value rule, which could be triggered when a function was called in an argument provided to the
print
built-in - Fix false positive in prefer-package-imports that would only be triggered when linting custom rules
Other improvements
- The prefer-some-in-iteration rule will by default no longer flag iteration where a sub-attribute is used, like
input[_].item
- The use-in-operator rule has been extended to include more types of items, leading to better discovery of locations where
in
should be used - Remove
replace
directive ingo.mod
that made hard to integrate Regal as a library. Thanks, @jamietanna! - The project now uses markdownlint to ensure consistent formatting of its documentation
- The Go API now allows reading custom rules from an
fs.FS
filesystem - OPA dependency bumped to latest v0.59.0
- Use matrix to build and test Regal in CI for all supported operating systems
Documentation
- The README now includes a section covering the
opa check --strict
command, and how it relates to Regal - A new page featuring editor integrations has been added to the docs. Thanks, @eshepelyuk!
- A new page featuring Regal adopters has been added
Changelog
- e71ff0a: Docs: supported editors page (#483) (@eshepelyuk)
- 7138206: Add section on `opa check --strict' (#484) (@anderseknert)
- daf0b02: docs: minor readme updates (#485) (@charlieegan3)
- a7f0819: docs: Extend note in readme (#487) (@charlieegan3)
- 60668b9: Fix: false positive with
print
andunused-return-value
(#486) (@anderseknert) - f70e631: Rule:
boolean-assignment
(#488) (@anderseknert) - ef28546: Replace
replace
directive with direct version pinning (#491) (@jamietanna) - f073c74:
prefer-some-in-iteration
: except subattribute iteration (#489) (@anderseknert) - 98afac8: Add markdownlint for linting docs (#493) (@anderseknert)
- a34e172: build: Add matrix PR build (#495) (@charlieegan3)
- 265ad54: Rule:
redundant-existence-check
(@anderseknert) - 5d2d836: go.mod: switch back to 1.20 (#500) (@srenatus)
- 843699b: Revert change to do.rq (@charlieegan3)
- d48656a:
use-in-operator
: extend check to include static refs (#499) (@anderseknert) - 032b038:
prefer-package-imports
: except data.regal imports in custom rules (#498) (@anderseknert) - b067d04: pkg/version: remove spurious whitespace from String() (#502) (@srenatus)
- f7dca35: linter: Add WithCustomRulesFromFS SDK option (#503) (@charlieegan3)
- 58c5e2e: function-arg-return: fix docs typo (#504) (@srenatus)
- 4d5fc01: Add adopters file (#506) (@anderseknert)
- cb08880: Add Rego Playground as integrator (#508) (@anderseknert)
- 6876cfc: Add SARIF output format (#507) (@anderseknert)
- b9342d4: OPA v0.59.0 (#511) (@anderseknert)