Skip to content

chore: expose schema_cache & file_context in lint rules #449

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

juleswritescode
Copy link
Collaborator

@juleswritescode juleswritescode commented Jul 13, 2025

  • The Analyser::run now takes Vec<AnalysableStatement> and an Option<&SchemaCache>
  • it also initializes an AnalysedFileContext
  • the SchemaCache and the AnalysedFileContext are passed into each linting rule.

This should roughly match how the eugene code base does it.

The rest of the changes are adaptions to those changes or minor things, e.g. a new document-mapper or some renamings.

  • there's a bug with the lint spans, I'll fix it and write a test for it

@juleswritescode juleswritescode marked this pull request as draft July 13, 2025 08:30
@juleswritescode juleswritescode marked this pull request as ready for review July 13, 2025 12:20
Copy link
Collaborator

@psteinroe psteinroe left a comment

Choose a reason for hiding this comment

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

any reason why we do not simply put these into the rule context? from an API standpoint, I feel like they should?

Comment on lines 34 to 36
ctx: &RuleContext<Self>,
_file_context: &AnalysedFileContext,
_schema_cache: Option<&SchemaCache>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

from an API standpoint, I would put these two into the RuleContext. After all, they are "context" info.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I felt the RuleContext held static metadata about the rule, while the other stuff is related to the db/data model and the parsed sql file.

But I don't have a hard opinion

@@ -0,0 +1,7 @@
#[derive(Default)]
pub struct AnalysedFileContext {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is this for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's just a scaffold for the file context.
We can add properties in future linting PRs.
eugene works the same way: link

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.

2 participants