Skip to content

Add use-array-flatten and use-object-union-n rules#1873

Merged
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:use-array-flatten
Feb 16, 2026
Merged

Add use-array-flatten and use-object-union-n rules#1873
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:use-array-flatten

Conversation

@anderseknert
Copy link
Member

With a few config knobs for the config inclined.

Fixes #1855

Copy link
Contributor

@charlieegan3 charlieegan3 left a comment

Choose a reason for hiding this comment

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

Nice work here!


location := util.to_location_object(value.terms.location)
keywords := array.concat([{"name": "some", "location": location}], _in_on_row(location.row))
keywords := array.flatten([{"name": "some", "location": location}, _in_on_row(location.row)])
Copy link
Contributor

Choose a reason for hiding this comment

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

Very good!


some call in wrapped_concat_calls

violation := json.patch(result.fail(rego.metadata.chain(), result.location(call)), [{
Copy link
Contributor

Choose a reason for hiding this comment

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

We do this in naming_convention.rego too with a hhelper _with_description(violation, description). Which these, that makes three rules now. Might it be useful in other rules, or in new rules that need to have the desc configured.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I didn't realize. That's a good call, yes! Will update in the next PR (have code lined up already :))

With a few config knobs for the config inclined.

Fixes open-policy-agent#1855

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
@anderseknert anderseknert enabled auto-merge (squash) February 16, 2026 16:30
@anderseknert anderseknert merged commit 580cb7d into open-policy-agent:main Feb 16, 2026
8 checks passed
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.

Rule: use-array-flatten

2 participants