v0.41.0
We've been getting a new version of Regal for an exciting summer of high performance Rego development.
This release brings automatic Rego test generation, as well as squashing a bunch of issues under the hood with sweeping enhancements to the core language server code.
NOTE the combination of a release deployment issue and immutable releases had this release end up without any downloadable artifacts. This has been corrected in v0.41.1.
New Feature: Automatic Test Generation
A first pass at automatic test generation has landed in the language server (#1982), thanks to @SeanLedford! With a new code action available when working in a policy file, Regal can generate a test stub based on the current state of the workspace. This uses the values found in input.json to populate the with statements in the generated test.
Language Server Improvements
This release includes significant internal improvements to the language server.
Completion performance has seen a major improvement: for clients like VS Code that support a default replacement range, the completion payload is now roughly half the size it was before, and clients generally do no longer need to send continuous requests to the server for more suggestions once you start typing (#1992).
The folding range provider has been rewritten in Rego (#1979), and now additionally honours client capabilities like lineFoldingOnly and rangeLimit.
The handling of input.json and input.yaml files has been overhauled (#2002). These files are now tracked as first-class workspace state: they are parsed and cached when saved, and the server now requests update notifications for them from the client, rather than re-parsing the file on each evaluation, or debug sessions started.
OPA v1.17.0
Regal has been updated to OPA v1.17.0 (#2014). This OPA release notably introduces future.keywords.not, which improves the semantics of the not keyword by wrapping composite-expression negation in an implicit body. Thanks @johanfylling for making sure this also works in Regal now!
Regal's RoAST representation (and docs) have been updated to support the new ast.Not form introduced alongside this feature (#1985).
RoAST module.comments Representation
The RoAST representation of module.comments has changed (#1987). Comments are now represented as plain locations rather than base64-encoded text, allowing Regal to retrieve the original text from the source file directly with less bytes to transfer and parse. Note: this is a breaking change for custom rules that reference input.comments directly. Users should instead prefer to reference data.regal.ast.comments_decoded, which provides comment locations in the usual form and which will remain stable even through future format changes.
Bug Fixes
- Addressed a panic in
regal fixcaused by fixes being applied in non-deterministic order;opa-fmtcould reduce line count such thatuse-assignment-operatorwould then access out-of-bounds row numbers (#2003) as reported by @erazemk - The
unassigned-return-valuerule now correctly flags namespaced builtins likejson.match_schema(...)in addition to flat builtins likelower(...)(#2005) — thanks @mvanhorn for the fix and @anderseknert for the report - Nicer formatting of
withsequences (#1969) regal/ast: metadatalabelsfield is now recognized as a valid metadata key, aligned with OPA v1.17.0 (#1983, #1988) — thanks @srenatus- Regal fix now works regardless of local git state (#2011). Thanks @seiyab for the report in #2006
New Contributors
- @mvanhorn added pre-commit hooks for
regal fixin #1976 - @sspaink added support for recursive JSON schemas in OPA, and later applied that fix in our schemas #1967
All changes
- Use OPA main until next OPA release by @anderseknert in #1968
- Update ast.json else to use "#/$defs/rule" by @sspaink in #1967
- Nicer formatting of
withtest sequences by @anderseknert in #1969 - Various code quality improvements by @anderseknert in #1970
- Move initialize handler to Rego router by @anderseknert in #1977
- build(deps): bump the dependencies group with 2 updates by @dependabot[bot] in #1975
- feat(pre-commit): add regal-fix hooks for auto-fixing rules by @mvanhorn in #1976
- Cleanup by @anderseknert in #1978
- Move folding range provider to Rego handlers by @anderseknert in #1979
- build(deps): bump github/codeql-action from 4.35.2 to 4.35.3 in the dependencies group by @dependabot[bot] in #1981
- regal/ast: add 'id' to valid metadata keys by @srenatus in #1983
- Introduce passthrough handler type by @anderseknert in #1984
- roast: Add support for
ast.Notby @johanfylling in #1985 - regal/ast: update metadata fields by @srenatus in #1988
- Breaking: new RoAST representation of module.comments by @anderseknert in #1987
- New framework for testing language server handlers by @anderseknert in #1992
- Move location of LSP storage helpers by @anderseknert in #1993
- build(deps): bump github.com/go-git/go-git/v5 from 5.18.0 to 5.19.1 by @dependabot[bot] in #2001
- build(deps): bump github.com/go-git/go-git/v5 from 5.18.0 to 5.19.1 in /e2e/testbuild by @dependabot[bot] in #2000
- Improved handling of input.(json|yaml) files by @anderseknert in #2002
- build(deps): bump brace-expansion from 5.0.5 to 5.0.6 in /build by @dependabot[bot] in #1997
- build(deps): bump the dependencies group across 1 directory with 2 updates by @dependabot[bot] in #1998
- fixer: Apply linter fixes in deterministic order by @charlieegan3 in #2003
- [feature] First Pass at Automatic Test Generation in Regal by @SeanLedford in #1982
- fix(rules): unassigned-return-value now covers namespaced builtins by @mvanhorn in #2005
- [bugfix] Remove the settings.json change that was introduced in a recent PR by @SeanLedford in #2010
- lsp: Introduce workspace abstraction by @anderseknert in #2009
- cmd: Remove git validation from fix command by @charlieegan3 in #2011
- Extract file polling into waitForFile helper by @charlieegan3 in #2013
- deps: Update opa to 1.17.0 by @charlieegan3 in #2014
- Use logger in Rego router by @anderseknert in #2012
- build: Add capabilities verification to build check by @charlieegan3 in #2015
- build(deps): bump github.com/containerd/containerd/v2 from 2.2.3 to 2.2.4 in /e2e/testbuild by @dependabot[bot] in #2007
- build(deps): bump the dependencies group with 3 updates by @dependabot[bot] in #2008
- Unify common aggregation and aggregated data by @anderseknert in #2016
- build(deps): bump github/codeql-action from 4.36.0 to 4.36.1 in the dependencies group by @dependabot[bot] in #2017
- debug: Determine abs debugging path for input.json by @charlieegan3 in #2018
- Use common aggregate data in circular-import by @anderseknert in #2019
Full Changelog: v0.40.0...v0.41.0