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 this is the same code as that of v0.41.0 — just that the combination of a release deployment issue and immutable releases just had that one end up without any downloadable artifacts. That is now corrected!
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 fix caused by fixes being applied in non-deterministic order; opa-fmt could reduce line count such that use-assignment-operator would then access out-of-bounds row numbers (#2003) as reported by @erazemk
The unassigned-return-value rule now correctly flags namespaced builtins like json.match_schema(...) in addition to flat builtins like lower(...) (#2005) — thanks @mvanhorn for the fix and @anderseknert for the report
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 fix caused by fixes being applied in non-deterministic order; opa-fmt could reduce line count such that use-assignment-operator would then access out-of-bounds row numbers (#2003) as reported by @erazemk
The unassigned-return-value rule now correctly flags namespaced builtins like json.match_schema(...) in addition to flat builtins like lower(...) (#2005) — thanks @mvanhorn for the fix and @anderseknert for the report
Today we celebrate Regal who turns v0.40.0 just in time for the GitHub download tracker to report 1 million total downloads. Quite the milestone! Thank you all for the encouragement, support and contributions during these past 3 years. Together we're redefining the policy development experience, and we have a lot more of that planned for the future. Stay tuned!
This release includes 2 new linter rules, and many new features and improvements to both the linter and language server.
Linter
New Rule: invalid-regexp
Category: bugs
The new invalid-regexp rule scans regular expressions found in policies and reports invalid patterns that would otherwise fail at runtime.
Avoid
packagepolicyinvalidifregexp.match("[a-z","test")
Prefer
packagepolicyvalidifregexp.match("[a-z]","test")
New Rule: superfluous-object-get
Category: idiomatic
The superfluous-object-get rule flags calls to object.get where using the built-in function provides no benefit compared to using a reference directly, and without the call.
Avoid
packagepolicysuperfluousif{# the default value (`""`) isn't used in the expression,# so object.get provides no benefit hereobject.get(input,["user","department"],"")=="engineering"}
More cases of superfluous object.get will be added to this rule as we encounter them.
Improvements
The naming-convention rule now accepts a list of allowed names in addition to regex patterns
The non-loop-expression rule now identifies more types of expressions that could be moved out of iteration
All rules now contain a related_resources item in their metadata pointing to the docs for the rule
The regal new rule command now generates a Related Resources section in the new rule's documentation template
(thanks @mvanhorn!)
Bugs Fixed
Fixed two false positives reported in the non-loop-expression rule
The server now exits with an error if the --profile flag is used without --format json (thanks @mvanhorn!)
Language Server
Evaluate and Debug Actions
Any input.json or input.yaml file found in the workspace will be used for input during evaluation and debugging sessions, but this wasn't obvious without reading the docs. The Evaluate and Debug code lenses / commands will now present a dialog option asking to create an input.json file in the project workspace in case one isn't found. This file is populated with dummy JSON data based on references to input found in the policy, and should be edited by the user to provide more relevant data.
The hover provider showing tooltips for built-in functions and keywords has been rewritten in Rego, and additionally saw a few improvements land as part of that process:
Links to examples for built-in functions now point to the correct location in the OPA docs
The print function now shows up in hover results as well
Hover provider now less resource intensive, and all information rendered just in time for display
Inlay Hints Improvements
The inlay hint provider (that provides names of function arguments to be displayed at call sites) has also been rewritten in Rego, and the server now implements also the inlayHint/resolve handler, which improves performance by only calculating inlay hint details when the client requests them for display.
Additionally, the inlay hint provider now properly takes the range of the active editor view into account, and will only spend resources calculating hints for code that the user can actually can see.
Semantic Tokens in Comprehensions and every Expressions
The language server's semantic token provider (providing context-based syntax highlighting) now provides semantic tokens inside of comprehensions and every expressions in addition to previously supported contexts. Additionally, most of the semantic token logic is now implemented entirely in Rego.
Improved Language Server Initialization
This release contains a number of fixes and improvements related to the language server's initialization routine, which should now be both more robust and faster.
Bugs Fixed
Two potential nil dereferences identified and fixed
Fix a potential out of bounds panic in slice access
The bundled web server now shows a link to Regal's editor integration documentation on its index page
Finally
Extra thanks goes out to @charlieegan3 this release, who worked tirelessly to fix some really complex race conditions and concurrency issues in the language server. A thankless job, but extremely important, and he pulled it off like a true Viking!
This PR contains the following updates:
| Package | Update | Change |
|---|---|---|
| [open-policy-agent/regal](https://github.com/open-policy-agent/regal) | minor | `0.39.0` → `0.41.1` |
---
### Release Notes
<details>
<summary>open-policy-agent/regal (open-policy-agent/regal)</summary>
### [`v0.41.1`](https://github.com/open-policy-agent/regal/releases/tag/v0.41.1)
[Compare Source](https://github.com/open-policy-agent/regal/compare/v0.41.0...v0.41.1)
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** this is the same code as that of v0.41.0 — just that the combination of a release deployment issue and immutable releases just had that one end up without any downloadable artifacts. That is now corrected!
#### New Feature: Automatic Test Generation
A first pass at automatic test generation has landed in the language server ([#​1982](https://github.com/open-policy-agent/regal/issues/1982)), thanks to [@​SeanLedford](https://github.com/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](https://github.com/open-policy-agent/regal/issues/1992)).
The folding range provider has been rewritten in Rego ([#​1979](https://github.com/open-policy-agent/regal/issues/1979)), and now additionally honours client capabilities like `lineFoldingOnly` and `rangeLimit`.
The handling of `input.json` and `input.yaml` files has been overhauled ([#​2002](https://github.com/open-policy-agent/regal/issues/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](https://github.com/open-policy-agent/regal/issues/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](https://github.com/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](https://github.com/open-policy-agent/regal/issues/1985)).
#### RoAST `module.comments` Representation
The RoAST representation of `module.comments` has changed ([#​1987](https://github.com/open-policy-agent/regal/issues/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 fix` caused by fixes being applied in non-deterministic order; `opa-fmt` could reduce line count such that `use-assignment-operator` would then access out-of-bounds row numbers ([#​2003](https://github.com/open-policy-agent/regal/issues/2003)) as reported by [@​erazemk](https://github.com/erazemk)
- The `unassigned-return-value` rule now correctly flags namespaced builtins like `json.match_schema(...)` in addition to flat builtins like `lower(...)` ([#​2005](https://github.com/open-policy-agent/regal/issues/2005)) — thanks [@​mvanhorn](https://github.com/mvanhorn) for the fix and [@​anderseknert](https://github.com/anderseknert) for the report
- Nicer formatting of `with` sequences ([#​1969](https://github.com/open-policy-agent/regal/issues/1969))
- `regal/ast`: metadata `labels` field is now recognized as a valid metadata key, aligned with OPA v1.17.0 ([#​1983](https://github.com/open-policy-agent/regal/issues/1983), [#​1988](https://github.com/open-policy-agent/regal/issues/1988)) — thanks [@​srenatus](https://github.com/srenatus)
- Regal fix now works regardless of local git state ([#​2011](https://github.com/open-policy-agent/regal/issues/2011)). Thanks [@​seiyab](https://github.com/seiyab) for the report in [#​2006](https://github.com/open-policy-agent/regal/issues/2006)
#### New Contributors
- [@​mvanhorn](https://github.com/mvanhorn) added pre-commit hooks for `regal fix` in [#​1976](https://github.com/open-policy-agent/regal/issues/1976)
- [@​sspaink](https://github.com/sspaink) added support for recursive JSON schemas in OPA, and later applied that fix in our schemas [#​1967](https://github.com/open-policy-agent/regal/issues/1967)
#### All changes
- Use OPA main until next OPA release by [@​anderseknert](https://github.com/anderseknert) in [#​1968](https://github.com/open-policy-agent/regal/pull/1968)
- Update ast.json else to use "#/$defs/rule" by [@​sspaink](https://github.com/sspaink) in [#​1967](https://github.com/open-policy-agent/regal/pull/1967)
- Nicer formatting of `with` test sequences by [@​anderseknert](https://github.com/anderseknert) in [#​1969](https://github.com/open-policy-agent/regal/pull/1969)
- Various code quality improvements by [@​anderseknert](https://github.com/anderseknert) in [#​1970](https://github.com/open-policy-agent/regal/pull/1970)
- Move initialize handler to Rego router by [@​anderseknert](https://github.com/anderseknert) in [#​1977](https://github.com/open-policy-agent/regal/pull/1977)
- build(deps): bump the dependencies group with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1975](https://github.com/open-policy-agent/regal/pull/1975)
- feat(pre-commit): add regal-fix hooks for auto-fixing rules by [@​mvanhorn](https://github.com/mvanhorn) in [#​1976](https://github.com/open-policy-agent/regal/pull/1976)
- Cleanup by [@​anderseknert](https://github.com/anderseknert) in [#​1978](https://github.com/open-policy-agent/regal/pull/1978)
- Move folding range provider to Rego handlers by [@​anderseknert](https://github.com/anderseknert) in [#​1979](https://github.com/open-policy-agent/regal/pull/1979)
- build(deps): bump github/codeql-action from 4.35.2 to 4.35.3 in the dependencies group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1981](https://github.com/open-policy-agent/regal/pull/1981)
- regal/ast: add 'id' to valid metadata keys by [@​srenatus](https://github.com/srenatus) in [#​1983](https://github.com/open-policy-agent/regal/pull/1983)
- Introduce passthrough handler type by [@​anderseknert](https://github.com/anderseknert) in [#​1984](https://github.com/open-policy-agent/regal/pull/1984)
- roast: Add support for `ast.Not` by [@​johanfylling](https://github.com/johanfylling) in [#​1985](https://github.com/open-policy-agent/regal/pull/1985)
- regal/ast: update metadata fields by [@​srenatus](https://github.com/srenatus) in [#​1988](https://github.com/open-policy-agent/regal/pull/1988)
- Breaking: new RoAST representation of module.comments by [@​anderseknert](https://github.com/anderseknert) in [#​1987](https://github.com/open-policy-agent/regal/pull/1987)
- New framework for testing language server handlers by [@​anderseknert](https://github.com/anderseknert) in [#​1992](https://github.com/open-policy-agent/regal/pull/1992)
- Move location of LSP storage helpers by [@​anderseknert](https://github.com/anderseknert) in [#​1993](https://github.com/open-policy-agent/regal/pull/1993)
- build(deps): bump github.com/go-git/go-git/v5 from 5.18.0 to 5.19.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2001](https://github.com/open-policy-agent/regal/pull/2001)
- build(deps): bump github.com/go-git/go-git/v5 from 5.18.0 to 5.19.1 in /e2e/testbuild by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2000](https://github.com/open-policy-agent/regal/pull/2000)
- Improved handling of input.(json|yaml) files by [@​anderseknert](https://github.com/anderseknert) in [#​2002](https://github.com/open-policy-agent/regal/pull/2002)
- build(deps): bump brace-expansion from 5.0.5 to 5.0.6 in /build by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1997](https://github.com/open-policy-agent/regal/pull/1997)
- build(deps): bump the dependencies group across 1 directory with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1998](https://github.com/open-policy-agent/regal/pull/1998)
- fixer: Apply linter fixes in deterministic order by [@​charlieegan3](https://github.com/charlieegan3) in [#​2003](https://github.com/open-policy-agent/regal/pull/2003)
- \[feature] First Pass at Automatic Test Generation in Regal by [@​SeanLedford](https://github.com/SeanLedford) in [#​1982](https://github.com/open-policy-agent/regal/pull/1982)
- fix(rules): unassigned-return-value now covers namespaced builtins by [@​mvanhorn](https://github.com/mvanhorn) in [#​2005](https://github.com/open-policy-agent/regal/pull/2005)
- \[bugfix] Remove the settings.json change that was introduced in a recent PR by [@​SeanLedford](https://github.com/SeanLedford) in [#​2010](https://github.com/open-policy-agent/regal/pull/2010)
- lsp: Introduce workspace abstraction by [@​anderseknert](https://github.com/anderseknert) in [#​2009](https://github.com/open-policy-agent/regal/pull/2009)
- cmd: Remove git validation from fix command by [@​charlieegan3](https://github.com/charlieegan3) in [#​2011](https://github.com/open-policy-agent/regal/pull/2011)
- Extract file polling into waitForFile helper by [@​charlieegan3](https://github.com/charlieegan3) in [#​2013](https://github.com/open-policy-agent/regal/pull/2013)
- deps: Update opa to 1.17.0 by [@​charlieegan3](https://github.com/charlieegan3) in [#​2014](https://github.com/open-policy-agent/regal/pull/2014)
- Use logger in Rego router by [@​anderseknert](https://github.com/anderseknert) in [#​2012](https://github.com/open-policy-agent/regal/pull/2012)
- build: Add capabilities verification to build check by [@​charlieegan3](https://github.com/charlieegan3) in [#​2015](https://github.com/open-policy-agent/regal/pull/2015)
- build(deps): bump github.com/containerd/containerd/v2 from 2.2.3 to 2.2.4 in /e2e/testbuild by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2007](https://github.com/open-policy-agent/regal/pull/2007)
- build(deps): bump the dependencies group with 3 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2008](https://github.com/open-policy-agent/regal/pull/2008)
- Unify common aggregation and aggregated data by [@​anderseknert](https://github.com/anderseknert) in [#​2016](https://github.com/open-policy-agent/regal/pull/2016)
- build(deps): bump github/codeql-action from 4.36.0 to 4.36.1 in the dependencies group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2017](https://github.com/open-policy-agent/regal/pull/2017)
- debug: Determine abs debugging path for input.json by [@​charlieegan3](https://github.com/charlieegan3) in [#​2018](https://github.com/open-policy-agent/regal/pull/2018)
- Use common aggregate data in circular-import by [@​anderseknert](https://github.com/anderseknert) in [#​2019](https://github.com/open-policy-agent/regal/pull/2019)
**Full Changelog**: <https://github.com/open-policy-agent/regal/compare/v0.40.0...v0.41.0>
### [`v0.41.0`](https://github.com/open-policy-agent/regal/releases/tag/v0.41.0)
[Compare Source](https://github.com/open-policy-agent/regal/compare/v0.40.0...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](https://github.com/open-policy-agent/regal/releases/tag/v0.41.1).
#### New Feature: Automatic Test Generation
A first pass at automatic test generation has landed in the language server ([#​1982](https://github.com/open-policy-agent/regal/issues/1982)), thanks to [@​SeanLedford](https://github.com/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](https://github.com/open-policy-agent/regal/issues/1992)).
The folding range provider has been rewritten in Rego ([#​1979](https://github.com/open-policy-agent/regal/issues/1979)), and now additionally honours client capabilities like `lineFoldingOnly` and `rangeLimit`.
The handling of `input.json` and `input.yaml` files has been overhauled ([#​2002](https://github.com/open-policy-agent/regal/issues/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](https://github.com/open-policy-agent/regal/issues/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](https://github.com/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](https://github.com/open-policy-agent/regal/issues/1985)).
#### RoAST `module.comments` Representation
The RoAST representation of `module.comments` has changed ([#​1987](https://github.com/open-policy-agent/regal/issues/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 fix` caused by fixes being applied in non-deterministic order; `opa-fmt` could reduce line count such that `use-assignment-operator` would then access out-of-bounds row numbers ([#​2003](https://github.com/open-policy-agent/regal/issues/2003)) as reported by [@​erazemk](https://github.com/erazemk)
- The `unassigned-return-value` rule now correctly flags namespaced builtins like `json.match_schema(...)` in addition to flat builtins like `lower(...)` ([#​2005](https://github.com/open-policy-agent/regal/issues/2005)) — thanks [@​mvanhorn](https://github.com/mvanhorn) for the fix and [@​anderseknert](https://github.com/anderseknert) for the report
- Nicer formatting of `with` sequences ([#​1969](https://github.com/open-policy-agent/regal/issues/1969))
- `regal/ast`: metadata `labels` field is now recognized as a valid metadata key, aligned with OPA v1.17.0 ([#​1983](https://github.com/open-policy-agent/regal/issues/1983), [#​1988](https://github.com/open-policy-agent/regal/issues/1988)) — thanks [@​srenatus](https://github.com/srenatus)
- Regal fix now works regardless of local git state ([#​2011](https://github.com/open-policy-agent/regal/issues/2011)). Thanks [@​seiyab](https://github.com/seiyab) for the report in [#​2006](https://github.com/open-policy-agent/regal/issues/2006)
#### New Contributors
- [@​mvanhorn](https://github.com/mvanhorn) added pre-commit hooks for `regal fix` in [#​1976](https://github.com/open-policy-agent/regal/issues/1976)
- [@​sspaink](https://github.com/sspaink) added support for recursive JSON schemas in OPA, and later applied that fix in our schemas [#​1967](https://github.com/open-policy-agent/regal/issues/1967)
#### All changes
- Use OPA main until next OPA release by [@​anderseknert](https://github.com/anderseknert) in [#​1968](https://github.com/open-policy-agent/regal/pull/1968)
- Update ast.json else to use "#/$defs/rule" by [@​sspaink](https://github.com/sspaink) in [#​1967](https://github.com/open-policy-agent/regal/pull/1967)
- Nicer formatting of `with` test sequences by [@​anderseknert](https://github.com/anderseknert) in [#​1969](https://github.com/open-policy-agent/regal/pull/1969)
- Various code quality improvements by [@​anderseknert](https://github.com/anderseknert) in [#​1970](https://github.com/open-policy-agent/regal/pull/1970)
- Move initialize handler to Rego router by [@​anderseknert](https://github.com/anderseknert) in [#​1977](https://github.com/open-policy-agent/regal/pull/1977)
- build(deps): bump the dependencies group with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1975](https://github.com/open-policy-agent/regal/pull/1975)
- feat(pre-commit): add regal-fix hooks for auto-fixing rules by [@​mvanhorn](https://github.com/mvanhorn) in [#​1976](https://github.com/open-policy-agent/regal/pull/1976)
- Cleanup by [@​anderseknert](https://github.com/anderseknert) in [#​1978](https://github.com/open-policy-agent/regal/pull/1978)
- Move folding range provider to Rego handlers by [@​anderseknert](https://github.com/anderseknert) in [#​1979](https://github.com/open-policy-agent/regal/pull/1979)
- build(deps): bump github/codeql-action from 4.35.2 to 4.35.3 in the dependencies group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1981](https://github.com/open-policy-agent/regal/pull/1981)
- regal/ast: add 'id' to valid metadata keys by [@​srenatus](https://github.com/srenatus) in [#​1983](https://github.com/open-policy-agent/regal/pull/1983)
- Introduce passthrough handler type by [@​anderseknert](https://github.com/anderseknert) in [#​1984](https://github.com/open-policy-agent/regal/pull/1984)
- roast: Add support for `ast.Not` by [@​johanfylling](https://github.com/johanfylling) in [#​1985](https://github.com/open-policy-agent/regal/pull/1985)
- regal/ast: update metadata fields by [@​srenatus](https://github.com/srenatus) in [#​1988](https://github.com/open-policy-agent/regal/pull/1988)
- Breaking: new RoAST representation of module.comments by [@​anderseknert](https://github.com/anderseknert) in [#​1987](https://github.com/open-policy-agent/regal/pull/1987)
- New framework for testing language server handlers by [@​anderseknert](https://github.com/anderseknert) in [#​1992](https://github.com/open-policy-agent/regal/pull/1992)
- Move location of LSP storage helpers by [@​anderseknert](https://github.com/anderseknert) in [#​1993](https://github.com/open-policy-agent/regal/pull/1993)
- build(deps): bump github.com/go-git/go-git/v5 from 5.18.0 to 5.19.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2001](https://github.com/open-policy-agent/regal/pull/2001)
- build(deps): bump github.com/go-git/go-git/v5 from 5.18.0 to 5.19.1 in /e2e/testbuild by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2000](https://github.com/open-policy-agent/regal/pull/2000)
- Improved handling of input.(json|yaml) files by [@​anderseknert](https://github.com/anderseknert) in [#​2002](https://github.com/open-policy-agent/regal/pull/2002)
- build(deps): bump brace-expansion from 5.0.5 to 5.0.6 in /build by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1997](https://github.com/open-policy-agent/regal/pull/1997)
- build(deps): bump the dependencies group across 1 directory with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1998](https://github.com/open-policy-agent/regal/pull/1998)
- fixer: Apply linter fixes in deterministic order by [@​charlieegan3](https://github.com/charlieegan3) in [#​2003](https://github.com/open-policy-agent/regal/pull/2003)
- \[feature] First Pass at Automatic Test Generation in Regal by [@​SeanLedford](https://github.com/SeanLedford) in [#​1982](https://github.com/open-policy-agent/regal/pull/1982)
- fix(rules): unassigned-return-value now covers namespaced builtins by [@​mvanhorn](https://github.com/mvanhorn) in [#​2005](https://github.com/open-policy-agent/regal/pull/2005)
- \[bugfix] Remove the settings.json change that was introduced in a recent PR by [@​SeanLedford](https://github.com/SeanLedford) in [#​2010](https://github.com/open-policy-agent/regal/pull/2010)
- lsp: Introduce workspace abstraction by [@​anderseknert](https://github.com/anderseknert) in [#​2009](https://github.com/open-policy-agent/regal/pull/2009)
- cmd: Remove git validation from fix command by [@​charlieegan3](https://github.com/charlieegan3) in [#​2011](https://github.com/open-policy-agent/regal/pull/2011)
- Extract file polling into waitForFile helper by [@​charlieegan3](https://github.com/charlieegan3) in [#​2013](https://github.com/open-policy-agent/regal/pull/2013)
- deps: Update opa to 1.17.0 by [@​charlieegan3](https://github.com/charlieegan3) in [#​2014](https://github.com/open-policy-agent/regal/pull/2014)
- Use logger in Rego router by [@​anderseknert](https://github.com/anderseknert) in [#​2012](https://github.com/open-policy-agent/regal/pull/2012)
- build: Add capabilities verification to build check by [@​charlieegan3](https://github.com/charlieegan3) in [#​2015](https://github.com/open-policy-agent/regal/pull/2015)
- build(deps): bump github.com/containerd/containerd/v2 from 2.2.3 to 2.2.4 in /e2e/testbuild by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2007](https://github.com/open-policy-agent/regal/pull/2007)
- build(deps): bump the dependencies group with 3 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2008](https://github.com/open-policy-agent/regal/pull/2008)
- Unify common aggregation and aggregated data by [@​anderseknert](https://github.com/anderseknert) in [#​2016](https://github.com/open-policy-agent/regal/pull/2016)
- build(deps): bump github/codeql-action from 4.36.0 to 4.36.1 in the dependencies group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2017](https://github.com/open-policy-agent/regal/pull/2017)
- debug: Determine abs debugging path for input.json by [@​charlieegan3](https://github.com/charlieegan3) in [#​2018](https://github.com/open-policy-agent/regal/pull/2018)
- Use common aggregate data in circular-import by [@​anderseknert](https://github.com/anderseknert) in [#​2019](https://github.com/open-policy-agent/regal/pull/2019)
**Full Changelog**: <https://github.com/open-policy-agent/regal/compare/v0.40.0...v0.41.0>
### [`v0.40.0`](https://github.com/open-policy-agent/regal/releases/tag/v0.40.0)
[Compare Source](https://github.com/open-policy-agent/regal/compare/v0.39.0...v0.40.0)
Today we celebrate Regal who turns v0.40.0 just in time for the GitHub download tracker to report 1 million total downloads. Quite the milestone! Thank you all for the encouragement, support and contributions during these past 3 years. Together we're redefining the policy development experience, and we have a lot more of that planned for the future. Stay tuned!
This release includes 2 new linter rules, and many new features and improvements to both the linter and language server.
#### Linter
##### New Rule: `invalid-regexp`
**Category:** bugs
The new [invalid-regexp](https://www.openpolicyagent.org/projects/regal/rules/bugs/invalid-regexp) rule scans regular expressions found in policies and reports invalid patterns that would otherwise fail at runtime.
**Avoid**
```rego
package policy
invalid if regexp.match("[a-z", "test")
```
**Prefer**
```rego
package policy
valid if regexp.match("[a-z]", "test")
```
##### New Rule: `superfluous-object-get`
**Category:** idiomatic
The [superfluous-object-get](https://www.openpolicyagent.org/projects/regal/rules/idiomatic/superflous-object-get) rule flags calls to `object.get` where using the built-in function provides no benefit compared to using a reference directly, and without the call.
**Avoid**
```rego
package policy
superfluous if {
# the default value (`""`) isn't used in the expression,
# so object.get provides no benefit here
object.get(input, ["user", "department"], "") == "engineering"
}
```
**Prefer**
```rego
package policy
much_better if {
input.user.department == "engineering"
}
```
More cases of superfluous `object.get` will be added to this rule as we encounter them.
##### Improvements
- The `naming-convention` rule now accepts a list of allowed names in addition to regex patterns
- The `non-loop-expression` rule now identifies more types of expressions that could be moved out of iteration
- All rules now contain a `related_resources` item in their metadata pointing to the docs for the rule
- The `regal new rule` command now generates a `Related Resources` section in the new rule's documentation template
(thanks [@​mvanhorn](https://github.com/mvanhorn)!)
#### Bugs Fixed
- Fixed two false positives reported in the `non-loop-expression` rule
- The server now exits with an error if the `--profile` flag is used without `--format json` (thanks [@​mvanhorn](https://github.com/mvanhorn)!)
#### Language Server
##### Evaluate and Debug Actions
Any `input.json` or `input.yaml` file found in the workspace will be used for `input` during evaluation and debugging sessions, but this wasn't obvious without reading the docs. The Evaluate and Debug code lenses / commands will now present a dialog option asking to create an `input.json` file in the project workspace in case one isn't found. This file is populated with dummy JSON data based on references to `input` found in the policy, and should be edited by the user to provide more relevant data.
Many thanks to [@​SeanLedford](https://github.com/SeanLedford) for this great work!
##### Hover Provider Improvements
The hover provider showing tooltips for built-in functions and keywords has been rewritten in Rego, and additionally saw a few improvements land as part of that process:
- Links to examples for built-in functions now point to the correct location in the OPA docs
- The `print` function now shows up in hover results as well
- Hover provider now less resource intensive, and all information rendered just in time for display
##### Inlay Hints Improvements
The inlay hint provider (that provides names of function arguments to be displayed at call sites) has also been rewritten in Rego, and the server now implements also the `inlayHint/resolve` handler, which improves performance by only calculating inlay hint details when the client requests them for display.
Additionally, the inlay hint provider now properly takes the range of the active editor view into account, and will only spend resources calculating hints for code that the user can actually can see.
##### Semantic Tokens in Comprehensions and `every` Expressions
The language server's semantic token provider (providing context-based syntax highlighting) now provides semantic tokens inside of comprehensions and `every` expressions in addition to previously supported contexts. Additionally, most of the semantic token logic is now implemented entirely in Rego.
##### Improved Language Server Initialization
This release contains a number of fixes and improvements related to the language server's initialization routine, which should now be both more robust and faster.
##### Bugs Fixed
- Two potential nil dereferences identified and fixed
- Fix a potential out of bounds panic in slice access
- The bundled web server now shows a link to Regal's editor integration documentation on its index page
##### Finally
Extra thanks goes out to [@​charlieegan3](https://github.com/charlieegan3) this release, who worked tirelessly to fix some really complex race conditions and concurrency issues in the language server. A thankless job, but extremely important, and he pulled it off like a true Viking!
#### Changelog
- [`691afe1`](https://github.com/open-policy-agent/regal/commit/691afe15fb2b2b00c3a94574aff4c33662725a15): Replace some Styra references ([#​1904](https://github.com/open-policy-agent/regal/issues/1904)) ([@​anderseknert](https://github.com/anderseknert))
- [`975ae72`](https://github.com/open-policy-agent/regal/commit/975ae721f5b05ef6bd2b32073f929c2a3cc6df89): build(deps): bump github.com/go-git/go-git/v5 in the dependencies group ([#​1903](https://github.com/open-policy-agent/regal/issues/1903)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`c85d88f`](https://github.com/open-policy-agent/regal/commit/c85d88f36346db6d13d2de197aab761bfc40885a): build(deps): bump go.opentelemetry.io/otel/sdk in /build/lsp ([#​1906](https://github.com/open-policy-agent/regal/issues/1906)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`5ff449b`](https://github.com/open-policy-agent/regal/commit/5ff449b9a9e67ae1427336b3be2701ad3ad6a182): build(deps): bump the dependencies group with 3 updates ([#​1907](https://github.com/open-policy-agent/regal/issues/1907)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`9900522`](https://github.com/open-policy-agent/regal/commit/9900522ea08e31bc8fec983b04ec8e19ef054caa): lsp: Wait for client to send initialized at boot ([#​1909](https://github.com/open-policy-agent/regal/issues/1909)) ([@​charlieegan3](https://github.com/charlieegan3))
- [`d661b5a`](https://github.com/open-policy-agent/regal/commit/d661b5a98a9232bd879178ece6aa95f8a3848011): build(deps): bump github/codeql-action in the dependencies group ([#​1912](https://github.com/open-policy-agent/regal/issues/1912)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`fd85e2d`](https://github.com/open-policy-agent/regal/commit/fd85e2d8312467c17ebe5727f18eb8c3044f2bcd): Allow naming-convention rule to take list of names (not only a pattern) ([#​1911](https://github.com/open-policy-agent/regal/issues/1911)) ([@​anderseknert](https://github.com/anderseknert))
- [`299d3fc`](https://github.com/open-policy-agent/regal/commit/299d3fc4e7d8b302fd39417d39f578c0fd03f1d8): Semantic Token Support for Comprehensions and Constructs ([#​1883](https://github.com/open-policy-agent/regal/issues/1883)) ([@​SeanLedford](https://github.com/SeanLedford))
- [`422a9ef`](https://github.com/open-policy-agent/regal/commit/422a9ef218aaaaec324e4130855417fc20bc0a40): build(deps): bump github/codeql-action in the dependencies group ([#​1915](https://github.com/open-policy-agent/regal/issues/1915)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`02a9dc8`](https://github.com/open-policy-agent/regal/commit/02a9dc85e358ad6b6740af95ea7f7c0196b16243): Fail with error when --profile used without JSON format ([#​1918](https://github.com/open-policy-agent/regal/issues/1918)) ([@​mvanhorn](https://github.com/mvanhorn))
- [`1716e13`](https://github.com/open-policy-agent/regal/commit/1716e13b022a712ea69214fe0bab04911e4eaeb6): lsp/webserver: Add links to the index page ([#​1914](https://github.com/open-policy-agent/regal/issues/1914)) ([@​charlieegan3](https://github.com/charlieegan3))
- [`1ab360f`](https://github.com/open-policy-agent/regal/commit/1ab360f6dc39de8ddf372ad91a11ee77045d0b02): lsp/testing: Nested test implementation ([#​1913](https://github.com/open-policy-agent/regal/issues/1913)) ([@​charlieegan3](https://github.com/charlieegan3))
- [`53e5bf2`](https://github.com/open-policy-agent/regal/commit/53e5bf2c00b52226b84fcdd133a6d9b1e2189f20): build(deps): bump google.golang.org/grpc in /e2e/testbuild ([#​1916](https://github.com/open-policy-agent/regal/issues/1916)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`45841bf`](https://github.com/open-policy-agent/regal/commit/45841bf5dea74eb294b44f0c230b981237c55fcb): build(deps): bump smol-toml and markdownlint-cli in /build ([#​1919](https://github.com/open-policy-agent/regal/issues/1919)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`371bf1f`](https://github.com/open-policy-agent/regal/commit/371bf1f14b5c653d8c6aa61cb69a59ee22536c11): build(deps): bump picomatch from 4.0.3 to 4.0.4 in /build ([#​1920](https://github.com/open-policy-agent/regal/issues/1920)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`62852fc`](https://github.com/open-policy-agent/regal/commit/62852fcaf3dca60840ce0c61df9116f7c7393327): build(deps): bump the dependencies group across 1 directory with 4 updates ([#​1921](https://github.com/open-policy-agent/regal/issues/1921)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`d32408d`](https://github.com/open-policy-agent/regal/commit/d32408db7c6b5650c9901d63b2a60835fcb28b45): build(deps): bump github.com/go-git/go-git/v5 in /e2e/testbuild ([#​1922](https://github.com/open-policy-agent/regal/issues/1922)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`8b9bcf0`](https://github.com/open-policy-agent/regal/commit/8b9bcf0a30439cf7da1285a8220f80b8a308f18a): build(deps): bump github.com/go-git/go-git/v5 from 5.17.0 to 5.17.1 ([#​1923](https://github.com/open-policy-agent/regal/issues/1923)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`f2251f2`](https://github.com/open-policy-agent/regal/commit/f2251f29301eb6517d50789e061b414835dcccbb): \[create-pull-request] automated change ([#​1908](https://github.com/open-policy-agent/regal/issues/1908)) ([@​github-actions](https://github.com/github-actions)\[bot])
- [`820d3f0`](https://github.com/open-policy-agent/regal/commit/820d3f011828efc75f9c9f022f0d833f9fa83eb9): OPA v1.15.1 ([#​1925](https://github.com/open-policy-agent/regal/issues/1925)) ([@​anderseknert](https://github.com/anderseknert))
- [`a155b62`](https://github.com/open-policy-agent/regal/commit/a155b62ea583e3c59cf6c94ab92d3ac820488cab): Add popup prompt for creating input.json if it doesnt exist when Evaluate is run ([#​1929](https://github.com/open-policy-agent/regal/issues/1929)) ([@​SeanLedford](https://github.com/SeanLedford))
- [`27067af`](https://github.com/open-policy-agent/regal/commit/27067af437e4b4e29599cffe604792605f85e5ba): build(deps): bump the dependencies group with 2 updates ([#​1931](https://github.com/open-policy-agent/regal/issues/1931)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`2179ae4`](https://github.com/open-policy-agent/regal/commit/2179ae4f9c993e10997242676bd8aa6ff957326c): Fix non-loop-expression false positives ([#​1930](https://github.com/open-policy-agent/regal/issues/1930)) ([@​anderseknert](https://github.com/anderseknert))
- [`33282ba`](https://github.com/open-policy-agent/regal/commit/33282ba33ead69930320f12028ab87d9dbb3dcae): Rule: superflous-object-get ([#​1932](https://github.com/open-policy-agent/regal/issues/1932)) ([@​anderseknert](https://github.com/anderseknert))
- [`6fd115a`](https://github.com/open-policy-agent/regal/commit/6fd115a6ed675f07901599d86888fa44e6349c86): Include rule docs links in metadata ([#​1935](https://github.com/open-policy-agent/regal/issues/1935)) ([@​anderseknert](https://github.com/anderseknert))
- [`6a364fb`](https://github.com/open-policy-agent/regal/commit/6a364fb2b7291fa942051c4c89c03a07906b910b): Fix aggregate test loop initialization ([#​1936](https://github.com/open-policy-agent/regal/issues/1936)) ([@​charlieegan3](https://github.com/charlieegan3))
- [`61ab730`](https://github.com/open-policy-agent/regal/commit/61ab73093e97da19b43964af552feaaa7c23702f): Rule: invalid-regexp ([#​1937](https://github.com/open-policy-agent/regal/issues/1937)) ([@​anderseknert](https://github.com/anderseknert))
- [`752ca7e`](https://github.com/open-policy-agent/regal/commit/752ca7e0d6b9bf282cc6d507441414cec76d988e): Cover more `non-loop-expression`s ([#​1938](https://github.com/open-policy-agent/regal/issues/1938)) ([@​anderseknert](https://github.com/anderseknert))
- [`cb9a9c8`](https://github.com/open-policy-agent/regal/commit/cb9a9c84b563b55e696ec7412f5e7d5fe766081a): Add convenience functions for working with lines and uints ([#​1944](https://github.com/open-policy-agent/regal/issues/1944)) ([@​anderseknert](https://github.com/anderseknert))
- [`85171b8`](https://github.com/open-policy-agent/regal/commit/85171b824a63895be9ecaa5f5136a53059211aa8): build(deps): bump go.opentelemetry.io/otel/sdk in /e2e/testbuild ([#​1942](https://github.com/open-policy-agent/regal/issues/1942)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`7fd6d66`](https://github.com/open-policy-agent/regal/commit/7fd6d663f3171ced5472f403a6430dd7918b796f): \[feature] Create input.json Skeleton if User Would Like When One Doesn't Exist ([#​1934](https://github.com/open-policy-agent/regal/issues/1934)) ([@​SeanLedford](https://github.com/SeanLedford))
- [`e4e326b`](https://github.com/open-policy-agent/regal/commit/e4e326b94ab3716086a6727423efc0f3c61315c5): OPA v1.15.2 ([#​1945](https://github.com/open-policy-agent/regal/issues/1945)) ([@​anderseknert](https://github.com/anderseknert))
- [`e8f1469`](https://github.com/open-policy-agent/regal/commit/e8f146911b977a2462eb7f23c40a929e5a1409a2): build(deps): bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp ([#​1941](https://github.com/open-policy-agent/regal/issues/1941)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`7a1235c`](https://github.com/open-policy-agent/regal/commit/7a1235ceba39c2339ee2525cc5258340f32513c2): Fix potential nil deref in language server ([#​1947](https://github.com/open-policy-agent/regal/issues/1947)) ([@​anderseknert](https://github.com/anderseknert))
- [`d6d2bf0`](https://github.com/open-policy-agent/regal/commit/d6d2bf0cebdbb373abad5da5564006307ac09f5c): Fix index out of bounds in parital inlay hint ([#​1948](https://github.com/open-policy-agent/regal/issues/1948)) ([@​anderseknert](https://github.com/anderseknert))
- [`0a0f1f8`](https://github.com/open-policy-agent/regal/commit/0a0f1f8f779ed888934e77e9c804a3b63c72de80): build(deps): bump the dependencies group with 2 updates ([#​1946](https://github.com/open-policy-agent/regal/issues/1946)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`d0e99b5`](https://github.com/open-policy-agent/regal/commit/d0e99b5e9d745148b97ab01237d97d5f11e91bac): Rewrite hover provider in Rego ([#​1951](https://github.com/open-policy-agent/regal/issues/1951)) ([@​anderseknert](https://github.com/anderseknert))
- [`cc35d48`](https://github.com/open-policy-agent/regal/commit/cc35d484338ae4498008fe72b6b7844b599d9860): Fix possible nil deref in ogre ([#​1954](https://github.com/open-policy-agent/regal/issues/1954)) ([@​anderseknert](https://github.com/anderseknert))
- [`44ceabe`](https://github.com/open-policy-agent/regal/commit/44ceabeacf7ed4a06607f2d9fafbb42c2e4ebaeb): Rewrite inlay hint provider in Rego ([#​1953](https://github.com/open-policy-agent/regal/issues/1953)) ([@​anderseknert](https://github.com/anderseknert))
- [`5c62c72`](https://github.com/open-policy-agent/regal/commit/5c62c72ceb3f55add899dfd7d6809faef3958a81): testing: Improve lsp shutdown logic & address test race conditions ([#​1943](https://github.com/open-policy-agent/regal/issues/1943)) ([@​charlieegan3](https://github.com/charlieegan3))
- [`12cc776`](https://github.com/open-policy-agent/regal/commit/12cc77609cc6db08cf73afac90525895c76dbdeb): Semantic package tokens in Rego ([#​1956](https://github.com/open-policy-agent/regal/issues/1956)) ([@​anderseknert](https://github.com/anderseknert))
- [`b4ccafc`](https://github.com/open-policy-agent/regal/commit/b4ccafc72d83bd1ffdde4bcf5ee7e6b9b1bd153b): feat(new): add Related Resources source link to builtin rule doc template ([#​1957](https://github.com/open-policy-agent/regal/issues/1957)) ([@​mvanhorn](https://github.com/mvanhorn))
- [`543d3fa`](https://github.com/open-policy-agent/regal/commit/543d3fae25d1c3fa2fcabf2b9cff262159626990): linter/lsp: Tidy use of aggregates and store in ls ([#​1962](https://github.com/open-policy-agent/regal/issues/1962)) ([@​charlieegan3](https://github.com/charlieegan3))
- [`1442904`](https://github.com/open-policy-agent/regal/commit/14429044d10e18d812df35520ddd5bd908e1c957): build(deps): bump github.com/go-git/go-git/v5 from 5.17.2 to 5.18.0 ([#​1958](https://github.com/open-policy-agent/regal/issues/1958)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`293cd7f`](https://github.com/open-policy-agent/regal/commit/293cd7f22a5c34820012a99c0063ac86e94d88cf): build(deps): bump github.com/go-git/go-git/v5 in /e2e/testbuild ([#​1959](https://github.com/open-policy-agent/regal/issues/1959)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`344a389`](https://github.com/open-policy-agent/regal/commit/344a3897ae4e6ed80a33221899a538eccb3ccfb2): build(deps): bump the dependencies group with 3 updates ([#​1963](https://github.com/open-policy-agent/regal/issues/1963)) ([@​dependabot](https://github.com/dependabot)\[bot])
- [`784fa86`](https://github.com/open-policy-agent/regal/commit/784fa8629a298a1a8ff1ead261dbaf2ffee2f661): Semantic import tokens Rego rewrite ([#​1960](https://github.com/open-policy-agent/regal/issues/1960)) ([@​anderseknert](https://github.com/anderseknert))
- [`0a00617`](https://github.com/open-policy-agent/regal/commit/0a00617a26467014b299b412bc1e017e620dfba6): Refactor: Sending Variable Semantic Tokens Data from Rego ([#​1961](https://github.com/open-policy-agent/regal/issues/1961)) ([@​SeanLedford](https://github.com/SeanLedford))
- [`9016d3d`](https://github.com/open-policy-agent/regal/commit/9016d3dcdaaa776d0ee1c89d77c55fdfaa94930a): Minor fixes ([#​1965](https://github.com/open-policy-agent/regal/issues/1965)) ([@​anderseknert](https://github.com/anderseknert))
- [`0ddd70f`](https://github.com/open-policy-agent/regal/commit/0ddd70f2d7959e9124a64c35d5c4f36af68de98b): docs: Update setup-regal in docs ([#​1964](https://github.com/open-policy-agent/regal/issues/1964)) ([@​charlieegan3](https://github.com/charlieegan3))
</details>
---
### Configuration
📅 **Schedule**: (UTC)
- Branch creation
- At any time (no schedule defined)
- Automerge
- At any time (no schedule defined)
🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMzYuMyIsInVwZGF0ZWRJblZlciI6IjQzLjEzNi4zIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->
volker.raschek
was assigned by CSRBot2026-04-21 16:30:20 +02:00
CSRBot
changed title from chore(deps): update dependency open-policy-agent/regal to v0.40.0 to chore(deps): update dependency open-policy-agent/regal to v0.41.12026-06-02 20:23:25 +02:00
CSRBot
changed title from chore(deps): update dependency open-policy-agent/regal to v0.41.1 to chore(deps): update dependency open-policy-agent/regal to v0.41.1 - autoclosed2026-06-15 17:11:01 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This PR contains the following updates:
0.39.0→0.41.1Release Notes
open-policy-agent/regal (open-policy-agent/regal)
v0.41.1Compare Source
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 this is the same code as that of v0.41.0 — just that the combination of a release deployment issue and immutable releases just had that one end up without any downloadable artifacts. That is now corrected!
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.jsonto populate thewithstatements 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
lineFoldingOnlyandrangeLimit.The handling of
input.jsonandinput.yamlfiles 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 thenotkeyword 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.Notform introduced alongside this feature (#1985).RoAST
module.commentsRepresentationThe RoAST representation of
module.commentshas 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 referenceinput.commentsdirectly. Users should instead prefer to referencedata.regal.ast.comments_decoded, which provides comment locations in the usual form and which will remain stable even through future format changes.Bug Fixes
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 @erazemkunassigned-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 reportwithsequences (#1969)regal/ast: metadatalabelsfield is now recognized as a valid metadata key, aligned with OPA v1.17.0 (#1983, #1988) — thanks @srenatusNew Contributors
regal fixin #1976All changes
withtest sequences by @anderseknert in #1969ast.Notby @johanfylling in #1985Full Changelog: https://github.com/open-policy-agent/regal/compare/v0.40.0...v0.41.0
v0.41.0Compare Source
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.jsonto populate thewithstatements 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
lineFoldingOnlyandrangeLimit.The handling of
input.jsonandinput.yamlfiles 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 thenotkeyword 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.Notform introduced alongside this feature (#1985).RoAST
module.commentsRepresentationThe RoAST representation of
module.commentshas 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 referenceinput.commentsdirectly. Users should instead prefer to referencedata.regal.ast.comments_decoded, which provides comment locations in the usual form and which will remain stable even through future format changes.Bug Fixes
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 @erazemkunassigned-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 reportwithsequences (#1969)regal/ast: metadatalabelsfield is now recognized as a valid metadata key, aligned with OPA v1.17.0 (#1983, #1988) — thanks @srenatusNew Contributors
regal fixin #1976All changes
withtest sequences by @anderseknert in #1969ast.Notby @johanfylling in #1985Full Changelog: https://github.com/open-policy-agent/regal/compare/v0.40.0...v0.41.0
v0.40.0Compare Source
Today we celebrate Regal who turns v0.40.0 just in time for the GitHub download tracker to report 1 million total downloads. Quite the milestone! Thank you all for the encouragement, support and contributions during these past 3 years. Together we're redefining the policy development experience, and we have a lot more of that planned for the future. Stay tuned!
This release includes 2 new linter rules, and many new features and improvements to both the linter and language server.
Linter
New Rule:
invalid-regexpCategory: bugs
The new invalid-regexp rule scans regular expressions found in policies and reports invalid patterns that would otherwise fail at runtime.
Avoid
Prefer
New Rule:
superfluous-object-getCategory: idiomatic
The superfluous-object-get rule flags calls to
object.getwhere using the built-in function provides no benefit compared to using a reference directly, and without the call.Avoid
Prefer
More cases of superfluous
object.getwill be added to this rule as we encounter them.Improvements
naming-conventionrule now accepts a list of allowed names in addition to regex patternsnon-loop-expressionrule now identifies more types of expressions that could be moved out of iterationrelated_resourcesitem in their metadata pointing to the docs for the ruleregal new rulecommand now generates aRelated Resourcessection in the new rule's documentation template(thanks @mvanhorn!)
Bugs Fixed
non-loop-expressionrule--profileflag is used without--format json(thanks @mvanhorn!)Language Server
Evaluate and Debug Actions
Any
input.jsonorinput.yamlfile found in the workspace will be used forinputduring evaluation and debugging sessions, but this wasn't obvious without reading the docs. The Evaluate and Debug code lenses / commands will now present a dialog option asking to create aninput.jsonfile in the project workspace in case one isn't found. This file is populated with dummy JSON data based on references toinputfound in the policy, and should be edited by the user to provide more relevant data.Many thanks to @SeanLedford for this great work!
Hover Provider Improvements
The hover provider showing tooltips for built-in functions and keywords has been rewritten in Rego, and additionally saw a few improvements land as part of that process:
printfunction now shows up in hover results as wellInlay Hints Improvements
The inlay hint provider (that provides names of function arguments to be displayed at call sites) has also been rewritten in Rego, and the server now implements also the
inlayHint/resolvehandler, which improves performance by only calculating inlay hint details when the client requests them for display.Additionally, the inlay hint provider now properly takes the range of the active editor view into account, and will only spend resources calculating hints for code that the user can actually can see.
Semantic Tokens in Comprehensions and
everyExpressionsThe language server's semantic token provider (providing context-based syntax highlighting) now provides semantic tokens inside of comprehensions and
everyexpressions in addition to previously supported contexts. Additionally, most of the semantic token logic is now implemented entirely in Rego.Improved Language Server Initialization
This release contains a number of fixes and improvements related to the language server's initialization routine, which should now be both more robust and faster.
Bugs Fixed
Finally
Extra thanks goes out to @charlieegan3 this release, who worked tirelessly to fix some really complex race conditions and concurrency issues in the language server. A thankless job, but extremely important, and he pulled it off like a true Viking!
Changelog
691afe1: Replace some Styra references (#1904) (@anderseknert)975ae72: build(deps): bump github.com/go-git/go-git/v5 in the dependencies group (#1903) (@dependabot[bot])c85d88f: build(deps): bump go.opentelemetry.io/otel/sdk in /build/lsp (#1906) (@dependabot[bot])5ff449b: build(deps): bump the dependencies group with 3 updates (#1907) (@dependabot[bot])9900522: lsp: Wait for client to send initialized at boot (#1909) (@charlieegan3)d661b5a: build(deps): bump github/codeql-action in the dependencies group (#1912) (@dependabot[bot])fd85e2d: Allow naming-convention rule to take list of names (not only a pattern) (#1911) (@anderseknert)299d3fc: Semantic Token Support for Comprehensions and Constructs (#1883) (@SeanLedford)422a9ef: build(deps): bump github/codeql-action in the dependencies group (#1915) (@dependabot[bot])02a9dc8: Fail with error when --profile used without JSON format (#1918) (@mvanhorn)1716e13: lsp/webserver: Add links to the index page (#1914) (@charlieegan3)1ab360f: lsp/testing: Nested test implementation (#1913) (@charlieegan3)53e5bf2: build(deps): bump google.golang.org/grpc in /e2e/testbuild (#1916) (@dependabot[bot])45841bf: build(deps): bump smol-toml and markdownlint-cli in /build (#1919) (@dependabot[bot])371bf1f: build(deps): bump picomatch from 4.0.3 to 4.0.4 in /build (#1920) (@dependabot[bot])62852fc: build(deps): bump the dependencies group across 1 directory with 4 updates (#1921) (@dependabot[bot])d32408d: build(deps): bump github.com/go-git/go-git/v5 in /e2e/testbuild (#1922) (@dependabot[bot])8b9bcf0: build(deps): bump github.com/go-git/go-git/v5 from 5.17.0 to 5.17.1 (#1923) (@dependabot[bot])f2251f2: [create-pull-request] automated change (#1908) (@github-actions[bot])820d3f0: OPA v1.15.1 (#1925) (@anderseknert)a155b62: Add popup prompt for creating input.json if it doesnt exist when Evaluate is run (#1929) (@SeanLedford)27067af: build(deps): bump the dependencies group with 2 updates (#1931) (@dependabot[bot])2179ae4: Fix non-loop-expression false positives (#1930) (@anderseknert)33282ba: Rule: superflous-object-get (#1932) (@anderseknert)6fd115a: Include rule docs links in metadata (#1935) (@anderseknert)6a364fb: Fix aggregate test loop initialization (#1936) (@charlieegan3)61ab730: Rule: invalid-regexp (#1937) (@anderseknert)752ca7e: Cover morenon-loop-expressions (#1938) (@anderseknert)cb9a9c8: Add convenience functions for working with lines and uints (#1944) (@anderseknert)85171b8: build(deps): bump go.opentelemetry.io/otel/sdk in /e2e/testbuild (#1942) (@dependabot[bot])7fd6d66: [feature] Create input.json Skeleton if User Would Like When One Doesn't Exist (#1934) (@SeanLedford)e4e326b: OPA v1.15.2 (#1945) (@anderseknert)e8f1469: build(deps): bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp (#1941) (@dependabot[bot])7a1235c: Fix potential nil deref in language server (#1947) (@anderseknert)d6d2bf0: Fix index out of bounds in parital inlay hint (#1948) (@anderseknert)0a0f1f8: build(deps): bump the dependencies group with 2 updates (#1946) (@dependabot[bot])d0e99b5: Rewrite hover provider in Rego (#1951) (@anderseknert)cc35d48: Fix possible nil deref in ogre (#1954) (@anderseknert)44ceabe: Rewrite inlay hint provider in Rego (#1953) (@anderseknert)5c62c72: testing: Improve lsp shutdown logic & address test race conditions (#1943) (@charlieegan3)12cc776: Semantic package tokens in Rego (#1956) (@anderseknert)b4ccafc: feat(new): add Related Resources source link to builtin rule doc template (#1957) (@mvanhorn)543d3fa: linter/lsp: Tidy use of aggregates and store in ls (#1962) (@charlieegan3)1442904: build(deps): bump github.com/go-git/go-git/v5 from 5.17.2 to 5.18.0 (#1958) (@dependabot[bot])293cd7f: build(deps): bump github.com/go-git/go-git/v5 in /e2e/testbuild (#1959) (@dependabot[bot])344a389: build(deps): bump the dependencies group with 3 updates (#1963) (@dependabot[bot])784fa86: Semantic import tokens Rego rewrite (#1960) (@anderseknert)0a00617: Refactor: Sending Variable Semantic Tokens Data from Rego (#1961) (@SeanLedford)9016d3d: Minor fixes (#1965) (@anderseknert)0ddd70f: docs: Update setup-regal in docs (#1964) (@charlieegan3)Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot.
d6547d9a32to9124eef80dchore(deps): update dependency open-policy-agent/regal to v0.40.0to chore(deps): update dependency open-policy-agent/regal to v0.41.1chore(deps): update dependency open-policy-agent/regal to v0.41.1to chore(deps): update dependency open-policy-agent/regal to v0.41.1 - autoclosedPull request closed