You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While it's an optional pattern, we're already starting to reap some tooling benefits from using underscore prefixes to denote private/internal rules and functions. These include things like avoiding completion suggestions to show up for these references (as they aren't meant to be referenced), or cheaply determine if a rule or function is unused or not (as we only need to check the same file for use). The Rego Style Guide was recently updated to include this recommendation, and we've got a few ideas for how to improve our tools to better make use of it going forward. So let's do it!
One obvious way to encourage the convention would be to check all references in a project, and for any rule or function that isn't referenced outside of its own package, suggest that it's made "private". We could easily (well sort of) have the regal fix command (and a corresponding LSP Code Action) automatically rewrite rules and functions to follow the convention too.
As with any good rule, there are some notable exceptions:
Tests. These by definition can't have an underscore prefix, and should already be ignored by tooling for most purposes where an underscore prefix would be used.
Rules that are marked as entrypoints.
Possibly more?
The text was updated successfully, but these errors were encountered:
While it's an optional pattern, we're already starting to reap some tooling benefits from using underscore prefixes to denote private/internal rules and functions. These include things like avoiding completion suggestions to show up for these references (as they aren't meant to be referenced), or cheaply determine if a rule or function is unused or not (as we only need to check the same file for use). The Rego Style Guide was recently updated to include this recommendation, and we've got a few ideas for how to improve our tools to better make use of it going forward. So let's do it!
One obvious way to encourage the convention would be to check all references in a project, and for any rule or function that isn't referenced outside of its own package, suggest that it's made "private". We could easily (well sort of) have the
regal fix
command (and a corresponding LSP Code Action) automatically rewrite rules and functions to follow the convention too.As with any good rule, there are some notable exceptions:
The text was updated successfully, but these errors were encountered: