Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3566

Rule S5855: Regex alternatives should not be redundant

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.10
    • Component/s: Rules
    • Labels:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              alban.auzeill Alban Auzeill
              Reporter:
              sebastian.hungerecker Sebastian Hungerecker
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: