Skip to content

Conversation

@psteinroe
Copy link
Collaborator

@psteinroe psteinroe commented Dec 14, 2025

Refactors pgls_analyse and pgls_analyser so that "source code linter"-concerns only live in analyser. analyse only contains shared concerns such as RuleMeta and a generic RuleVisitor.

This is in preparation for the integration of other type of linters (e.g. splinter), which will use the same infrastructure as much as possible. Every execution concern was moved to pgls_analyser, since other linters will not run on the AST and have a different execution model.

@psteinroe psteinroe changed the title refactor: analyser refactor(analyser): separate concerns Dec 15, 2025
psteinroe and others added 3 commits December 15, 2025 12:06
Changed pgls_analyse::AnalyserRules to pgls_analyser::LinterRules
and fixed import statements to use the correct crate for RuleOptions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Updated test files to use the new type names after the refactor:
- Changed AnalyserOptions to LinterOptions
- Changed RuleDiagnostic to LinterDiagnostic
- Fixed import paths to import from pgls_analyser instead of pgls_analyse

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixed import ordering and line length formatting issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@psteinroe psteinroe marked this pull request as ready for review December 15, 2025 12:22
Comment on lines +23 to +26
pub use LinterDiagnostic as RuleDiagnostic;
pub use LinterRule as Rule;
pub use LinterRuleContext as RuleContext;

Copy link
Collaborator

@juleswritescode juleswritescode Dec 16, 2025

Choose a reason for hiding this comment

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

sind die Linter-spezifisch? wenn ja, kann das hier IMHo zu verwirrung führen

pub mod options;
mod registry;

// Re-export linter-specific types
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Re-export linter-specific types

metadata
});

// Separate function for visiting metadata registry (uses pgls_analyse::RegistryVisitor)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Separate function for visiting metadata registry (uses pgls_analyse::RegistryVisitor)

pub static METADATA: LazyLock<MetadataRegistry> = LazyLock::new(|| {
let mut metadata = MetadataRegistry::default();
visit_registry(&mut metadata);
// Use a separate visitor for metadata that implements pgls_analyse::RegistryVisitor
Copy link
Collaborator

Choose a reason for hiding this comment

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

inwiefern separate? ist das nicht einfach der default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

vorher hatten wir einen Visitor auf Rule, wo Rule metadaten (RuleMeta) und ein run Methode verlangt hat. dh wir hatten ein tight coupling zwischen metadata declaration und execution von rules. jetzt haben wir zwei visitors: einer der nur über RuleMeta läuft, und einer der auch die execution verlange. letzterer existiert nur noch innerhalb der source code linter crate. deshalb "separate visitor" - es gibt jetzt zwei.

@psteinroe psteinroe merged commit a75eff4 into main Dec 16, 2025
15 of 16 checks passed
@psteinroe psteinroe deleted the refactor/rules branch December 16, 2025 17:04
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.

3 participants