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.addSimpleStringLiteral((SimpleStringLiteral node) {
// Skip allowed common strings
if (_allowedStrings.contains(node.value)) return;
// Skip very short strings (1-3 chars) - more lenient for tests
if (node.value.length <= 3) return;
// Skip if in const context
if (isLiteralInConstContext(node)) return;
// Skip if in annotation
if (isInAnnotation(node)) return;
// Skip if in import/export
if (isInImportOrExport(node)) return;
// Skip interpolated strings
if (node.parent is StringInterpolation) return;
// Skip test descriptions (first argument to test(), group(), etc.)
if (isTestDescription(node)) return;
// Skip regex patterns
if (isStringUsedAsRegexPattern(node)) return;
// Skip strings in expect() calls (assertion values)
if (isInExpectCall(node)) return;
// Skip strings passed as arguments to non-test-framework functions
// (these are test fixture data — the input being tested)
if (_isTestFixtureArgument(node)) return;
reporter.atNode(node);
});
}