chore: expose schema_cache & file_context in lint rules - #449
Merged
Conversation
juleswritescode
marked this pull request as draft
July 13, 2025 08:30
juleswritescode
marked this pull request as ready for review
July 13, 2025 12:20
psteinroe
reviewed
Jul 14, 2025
psteinroe
left a comment
Collaborator
There was a problem hiding this comment.
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>, |
Collaborator
There was a problem hiding this comment.
from an API standpoint, I would put these two into the RuleContext. After all, they are "context" info.
Collaborator
Author
There was a problem hiding this comment.
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 {} | |||
Collaborator
Author
There was a problem hiding this comment.
That's just a scaffold for the file context.
We can add properties in future linting PRs.
eugene works the same way: link
psteinroe
approved these changes
Jul 15, 2025
juleswritescode
enabled auto-merge (squash)
July 15, 2025 10:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Analyser::runnow takesVec<AnalysableStatement>and anOption<&SchemaCache>AnalysedFileContextSchemaCacheand theAnalysedFileContextare 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.