check method

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

Implementation

@override
void check(
  DcqRegistry registry,
) {
  registry.addPropertyAccess((node) {
    final propertyName = node.propertyName.name;
    if (!_unsafeProperties.contains(propertyName)) return;

    final target = node.target;
    if (target == null) return;

    final targetType = target.staticType;
    if (targetType is! InterfaceType) return;

    if (_isIterableType(targetType)) {
      reportAtNode(node.propertyName);
    }
  });

  registry.addMethodInvocation((node) {
    final methodName = node.methodName.name;
    if (!_unsafeMethods.contains(methodName)) return;

    final targetType = node.target?.staticType;
    if (targetType is! InterfaceType) return;

    if (_isIterableType(targetType)) {
      reportAtNode(node.methodName);
    }
  });

  registry.addPrefixedIdentifier((node) {
    final propertyName = node.identifier.name;
    if (!_unsafeProperties.contains(propertyName)) return;

    final targetType = node.prefix.staticType;
    if (targetType is! InterfaceType) return;

    if (_isIterableType(targetType)) {
      reportAtNode(node.identifier);
    }
  });
}