How to properly access properties & getters using LintRuleNodeRegistry (context.registry.addXXX) ? #213
-
Hello, firstly, thank for this very usefull package, I try to detect dangerous usage of iterator methods which are not null safety, list Using the context.registry LintRuleNodeRegistry, what's the right listener to detect call of getters on an given object. For example, regarding the following code : final myList = <String>[];
void myTest() {
final a = myList.first; // that's what I try to detect
final b = myList[42]; // that's what I try to detect
a.replaceFirst("a", "b"); // this one is correctly detected by `addMethodInvocation`
} For example I try to detect the
Is there any better way to get an invocation of an object getter or simply access to object property ? thx |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can look for One thing you can do to help debug is use a low-level |
Beta Was this translation helpful? Give feedback.
You can look for
Identifier
& subclasses formyList.first
.I don't remember what's for
[x]
operators, but that's likely going to be anExpression
subclass.One thing you can do to help debug is use a low-level
addNode
oraddExpression
or another general interface, and logprint('$node ${node.runtimeType}')
.Then you'd know what object type you're looking for.