check method

  1. @override
void check(
  1. DcqRegistry registry
)

Implementation

@override
void check(
  DcqRegistry registry,
) {
  registry.addBlock((node) {
    if (node.statements.isNotEmpty) return;

    // Skip if the block contains comments.
    if (node.rightBracket.precedingComments != null) return;

    final parent = node.parent;

    // Skip empty constructors.
    if (parent is BlockFunctionBody) {
      final grandparent = parent.parent;
      if (grandparent is ConstructorDeclaration) return;
    }

    // Skip empty catch blocks — these are intentional per convention.
    if ((configBool(ruleConfig, 'skip-catch-clause') ?? true) &&
        parent is CatchClause) {
      return;
    }

    reportAtNode(node);
  });
}