runWithReporter method

  1. @override
void runWithReporter(
  1. SaropaDiagnosticReporter reporter,
  2. SaropaContext context
)
override

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) {
    final value = node.value;
    if (value.startsWith('http://') &&
        !value.startsWith('http://localhost') &&
        !value.startsWith('http://127.0.0.1') &&
        !value.startsWith('http://10.') &&
        !value.startsWith('http://192.168.')) {
      reporter.atNode(node);
    }
  });
}