v0.17.0
This is a fairly big release, adding 4 new linter rules and a whole bunch of improvements and fixes.
New rule: with-outside-test-context
Category: performance
This is the first rule in the new performance
category, with more to follow in future releases. The with
keyword is known to most as a way to mock values and functions in unit tests. While it's occasionally useful in other contexts, it comes with some major performance implications when used outside of tests. This new rule warns when with
is encoutered outside the context of tests.
For more information, see the docs on with-outside-test-context.
New rule: circular-import
Category: imports
A circular import is when a package imports itself, either by directly importing itself, or indirectly by importing a which in turn imports a series of packages that eventually import the original package. As long as recursive rules definitions are avoided, circular imports are permitted in Rego. However, such import graphs are not advisable and a signal of poorly structured policy code.
For more information, see the docs on circular-import.
New rule: rule-name-repeats-package
Category: style
When rules are referenced outside the package in which they are defined, they will be referenced using the package path. For example, the allow
rule in the example
package, is available at data.example.allow
. When rule names include all or part of their package paths, this creates repetition in such references. For example, authz_allow
in a package authz
is referenced with: data.authz.authz_allow
. This repetition is undesirable as the reference is longer than needed, and harder to read.
For more information, see the docs on rule-name-repeats-package.
New rule: double negative
Category: style
While rules using double negatives — like not no_funds — occasionally make sense, it is often worth considering whether the rule could be rewritten without the negative. For example, not no_funds could be rewritten as funds or has_funds, or funds_available.
For more information, see the docs on double-negative.
Improvements
- The Regal language server now supports client shutdown messages
- The docs on how to ignore rules and files have been greatly improved. Thanks @bdumpp and @orenzohar for the suggestion!
Bugs Fixed
- Fix false positive in prefer-some-in-iteration rule when old-style iteration was used inside of arrays, sets and objects
- Fix false positive in prefer-some-in-iteration rule when old-style iteration was used inside of rule head key (i.e.
contains
) - Fix false positive in external-reference rule when using
=
for assignment (although you shouldn't!) - The Regal language server now correctly handles URIs and paths on Windows
Ecosystem
The setup-regal GitHub Action has been promoted to v1. This fixes the warning in pipelines about depending on an old Node version. Make sure to update your workflows!
Changelog
- f2d07d9: lsp: Support lsp client shutdown message (#539) (@charlieegan3)
- 5418cea: docs: add workflow to auto update docs (#541) (@charlieegan3)
- e98d1fc: Update permissions to allow running actions (#542) (@charlieegan3)
- f2d996a: Update docs with deploy key (#543) (@charlieegan3)
- daf2a16: docs: make path when updating version (#544) (@charlieegan3)
- 4007105: docs: correctly set version when updating (#545) (@charlieegan3)
- 46a84e7: docs: allow updating with workflow dispatch (#546) (@charlieegan3)
- cd2cd9f: docs: use pinned addon (#547) (@charlieegan3)
- 6bdebb6: docs: update action no longer needs local write (#549) (@charlieegan3)
- 7896c73: Use v1 of setup-regal (#551) (@anderseknert)
- 1c6d1ba: Bump golangci/golangci-lint-action from 3.7.0 to 4.0.0 (#552) (@dependabot[bot])
- 5dbc6d8: Fix golangci-lint violations (#554) (@anderseknert)
- ee878c0: Use filepath.WalkDir (#556) (@anderseknert)
- 7f9ddad: Rule: circular-import and rule-name-repeats-package (#558) (@charlieegan3)
- ee2cd46: rules: Add double negative rule (#557) (@charlieegan3)
- 22f6a10: Rule:
with-outside-test-context
(#555) (@anderseknert) - 2bb5dd6: Docs: Make it obvious how to ignore rules and files (#562) (@anderseknert)
- 6ecc6af: Fix false positive in
external-reference
(#563) (@anderseknert) - 4625e7a: Fix false positive in
prefer-some-in-iteration
(#564) (@anderseknert) - f11eef4:
prefer-some-iteration
: fix false positive in rule head key (#565) (@anderseknert) - ece9977: lsp: Correctly handle URIs and paths on Windows (#569) (@charlieegan3)