check method
void
check(
- DcqRegistry registry
)
Implementation
@override
void check(
DcqRegistry registry,
) {
registry.addConditionalExpression((node) {
final thenExpr = node.thenExpression;
final elseExpr = node.elseExpression;
if (thenExpr is MethodInvocation && elseExpr is MethodInvocation) {
if (_sameMethod(thenExpr, elseExpr)) {
reportAtNode(node);
}
}
if (thenExpr is FunctionExpressionInvocation &&
elseExpr is FunctionExpressionInvocation) {
final thenFunc = thenExpr.function;
final elseFunc = elseExpr.function;
if (thenFunc is SimpleIdentifier &&
elseFunc is SimpleIdentifier &&
thenFunc.name == elseFunc.name) {
reportAtNode(node);
}
}
if (thenExpr is InstanceCreationExpression &&
elseExpr is InstanceCreationExpression) {
if (thenExpr.constructorName.toSource() ==
elseExpr.constructorName.toSource()) {
reportAtNode(node);
}
}
});
}