I’ve noticed when a behavior is checked “inside loops”, a Sonar rule checks for “for” loops, “foreach” loops and “while” loops : " Kind.FOR_STATEMENT
, Kind.FOR_EACH_STATEMENT
and Kind.WHILE_STATEMENT
" (see rule ‘java:S3012’ for example)
I can see why Kind.DO_STATEMENT
(do… while) is not listed because it’s rarely used (even if it could be added at no cost) but why stream().forEach(...)
is not taken into account ?
Is it something possible with Sonar and static analysis ? Or is it considered out of static analysis scope ? More generally, I would have same question for code called by a function into a loop, is there a way to “navigate” to the function source code, and consider it’s inside the loop ?