run method

  1. @override
void run(
  1. CustomLintResolver resolver,
  2. DiagnosticReporter 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,
  DiagnosticReporter reporter,
  CustomLintContext context,
) {
  context.registry.addInstanceCreationExpression((node) {
    if (isExpressionExactlyType(node, 'Container', 'flutter') &&
        isInstanceCreationExpressionOnlyUsingParameter(
          node,
          parameter: 'margin',
          // Ignores key and child parameters because both Container and Padding have them
          ignoredParameters: const {'key', 'child'},
        )) {
      reporter.atNode(
        node.constructorName,
        code,
        data: _findMarginParameterLabel(node),
      );
    }
  });
}