Implement rule S5855 by visiting all alternations (DisjunctionTrees) and checking whether any of its alternatives is a superset of another.
Some times something like "(a)|(.)" can be intentional because the capturing groups tell you which alternative was matched, so if one of the alternatives contains a capturing group, an issue should only be raised if the alternative that's a superset comes first.
So "a|.", ".|a" and "(.)|(a)" should all raise issues, but "(a)|(.)" should not.
- contributes to
-
MMF-2182 Help Java developers writing regexp running fast, with the correct amount of resources and really doing what developers intended
-
- Resolved
-
- depends upon
-
SONARJAVA-3549 Add support for automata-based analyses for regular expressions
-
- Closed
-
-
SONARJAVA-3564 Implement intersects and supersetOf helper for regex automata
-
- Closed
-
- implements
-
RSPEC-5855 Regex alternatives should not be redundant
- Active
- supercedes
-
SONARJAVA-3475 Expand the scope of S5840
-
- Closed
-