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.addMethodInvocation((MethodInvocation node) {
final String method = node.methodName.name;
if (method != 'setVolume' && method != 'play') return;
if (!fileImportsPackage(node, PackageImports.audioplayers)) return;
final Expression? value = method == 'setVolume'
? node.argumentList.arguments.firstOrNull
: _namedArg(node, 'volume');
if (value == null) return;
final num? literal = _numericLiteral(value);
if (literal == null || literal <= 1.0) return;
reporter.atNode(value);
});
}