run method

  1. @override
void run(
  1. CustomLintResolver resolver,
  2. ErrorReporter reporter,
  3. CustomLintContext context
)

Emits lints for a given file.

run will only be invoked with files respecting filesToAnalyze

Implementation

@override
void run(
    CustomLintResolver resolver,
    ErrorReporter reporter,
    CustomLintContext context,
    ) {
  context.registry.addCompilationUnit((node) {
    final declaredElement = node.declaredElement;
    if (declaredElement != null) {
      final path = declaredElement.source.uri.path;
      if (path.isCorrectFileModelName() && path.isPathModel()) {
        for (final element in declaredElement.classes) {
          for (final field in element.fields) {
            if (!field.toString().isCorrectVariableNullable()) {
              reporter.reportErrorForOffset(code, field.nameOffset, field.nameLength);
            }
          }
        }
      }
    }
  });
}