check method

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

Implementation

@override
void check(
  DcqRegistry registry,
) {
  registry.addMethodInvocation((node) {
    if (_isInTryCatch(node)) return;

    final methodName = node.methodName.name;
    final target = node.target;

    if (target is SimpleIdentifier) {
      final key = '${target.name}.$methodName';
      if (_throwingStaticMethods.contains(key)) {
        reportAtNode(node);
        return;
      }
    }

    if (target is Identifier) {
      final targetType = target.staticType;
      if (targetType is InterfaceType) {
        final className = targetType.element.name!;
        final key = '$className.$methodName';
        if (_throwingStaticMethods.contains(key)) {
          reportAtNode(node);
        }
      }
    }
  });
}