Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: allow separating preparation of linting from actual linting #1394

Open
anderseknert opened this issue Feb 4, 2025 · 0 comments
Open
Labels

Comments

@anderseknert
Copy link
Member

While the various WithX methods help set up a configuration for linting, the Lint method is currently where all the processing takes place (parsing, preparing the query, linting, preparing the result).

It would be great if the API offered a way to allow preparing for linting and linting in two separate steps, allowing the more flexible/performant use in some scenarios. Another benefit would be benchmarking, where it would be much easier to differentiate costs of linting if the cost of preparing to lint could be accounted for separately from the cost of linting (i.e. the Rego evaluation).

Obviously, we'll still want the current way to keep working. So I'd imagine the Lint() call would first check if there's a prepare state to start from, and if not, itself call Prepare() (or whatever we want to call it)

linter := NewLinter().
    WithInputPaths([]string{"../../bundle"}).
    WithDisableAll(true).
    WithEnabledRules("opa-fmt").
    Prepare()  // This would be new

rep, err = linter.Lint(context.Background())
if err != nil {
    panic(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant