File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -239,7 +239,15 @@ class _DoubleClampVisitor extends RecursiveAstVisitor<CompilationUnit> {
239
239
240
240
@override
241
241
CompilationUnit ? visitMethodInvocation (MethodInvocation node) {
242
- if (node.methodName.name == 'clamp' ) {
242
+ final NodeList <Expression > arguments = node.argumentList.arguments;
243
+ // This may produce false positives when `node.target` is not a subtype of
244
+ // num. The static type of `node.target` isn't guaranteed to be resolved at
245
+ // this time. Check whether the argument list consists of 2 positional args
246
+ // to reduce false positives.
247
+ final bool isNumClampInvocation = node.methodName.name == 'clamp'
248
+ && arguments.length == 2
249
+ && ! arguments.any ((Expression exp) => exp is NamedExpression );
250
+ if (isNumClampInvocation) {
243
251
final _Line line = _getLine (parseResult, node.function.offset);
244
252
if (! line.content.contains ('// ignore_clamp_double_lint' )) {
245
253
clamps.add (line);
You can’t perform that action at this time.
0 commit comments