Skip to content

Fix unnecessary-some rule not working after OPA 1.0+#1485

Merged
anderseknert merged 1 commit intomainfrom
fix-unnecessary-some
Apr 14, 2025
Merged

Fix unnecessary-some rule not working after OPA 1.0+#1485
anderseknert merged 1 commit intomainfrom
fix-unnecessary-some

Conversation

@anderseknert
Copy link
Copy Markdown
Member

And a few tweaks to the import checking functions.

Fixes #1483

And a few tweaks to the import checking functions.

Fixes #1483

Signed-off-by: Anders Eknert <anders@styra.com>
count(pv) == count(path)

_arr(imp) == path
every i, part in path {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this run any faster/slower than building an array and using ==?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially, as every can benefit from early exit. But it's mostly custom functions that is a win to avoid when they're not strictly needed.

See open-policy-agent/opa#7266

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(although this is not a hot path.. I just thought the change made the code nicer :)

@anderseknert anderseknert merged commit 3a61374 into main Apr 14, 2025
5 checks passed
@anderseknert anderseknert deleted the fix-unnecessary-some branch April 14, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No violation reported for unnecessary-some on OPA 1.0+

2 participants