-
Notifications
You must be signed in to change notification settings - Fork 53
Description
It's been a while since we had a new rule for recommending the use of a built-in function. But it struck me now that since my rationale for adding array.flatten to OPA was to be able to replace code like this..
flat := array.concat([a], array.concat(b, [c]))with this..
flat := array.flatten([a, b, c])..we should of course let our users know that they too can do this! Let's create a rule that recognizes nested array.concat calls and suggests using array.flatten instead — unless of course that built-in is not in the target OPA's capabilities.
Thinking about it, we can probably do this for a few more functions, like recommending object.union_n if we find nested calls to object.union. I also looked at suggesting to replace repeated replace calls -> strings.repeat_n... but AFAICS those aren't interchangeable.Oh well, that should be another issue/rule.