check method
void
check(
- DcqRegistry registry
)
Implementation
@override
void check(DcqRegistry registry) {
registry.addMethodInvocation((node) {
if (!isHookCall(node.methodName.name)) return;
// Walk up to find if we're inside a conditional.
var current = node.parent;
while (current != null) {
if (current is IfStatement ||
current is ConditionalExpression ||
current is SwitchStatement ||
current is SwitchExpression ||
current is ForStatement ||
current is WhileStatement ||
current is DoStatement) {
// Verify we're inside a hook context (build method or use* function).
if (_isInsideHookContext(current)) {
reportAtNode(node);
return;
}
}
current = current.parent;
}
});
}