runWithReporter method
Override this method to implement your lint rule.
Use context to register callbacks for AST node types:
context.addMethodInvocation((node) {
if (condition) {
reporter.atNode(node);
}
});
Implementation
@override
void runWithReporter(
SaropaDiagnosticReporter reporter,
SaropaContext context,
) {
context.addConstructorDeclaration((ConstructorDeclaration node) {
// Skip factory constructors and named constructors
if (node.factoryKeyword != null) return;
if (node.name != null) return; // Named constructor
final FormalParameterList params = node.parameters;
int dependencyCount = 0;
for (final FormalParameter param in params.parameters) {
// Count parameters that are likely dependencies (not primitives)
final String? typeName = _getParameterTypeName(param);
if (typeName != null && _isDependencyType(typeName)) {
dependencyCount++;
}
}
if (dependencyCount > _maxDependencies) {
reporter.atNode(node);
}
});
}