All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.py.rules.python.S6395.html Maven / Gradle / Ivy

The newest version!

Why is this an issue?

Sub-patterns can be wrapped by parentheses to build a group. This enables to restrict alternations, back reference the group or apply quantifier to the sub-pattern.

If this group should not be part of the match result or if no reference to this group is required, a non-capturing group can be created by adding ?: behind the opening parenthesis.

However, if this non-capturing group does not have a quantifier, or does not wrap an alternation, then imaging this group is redundant.

Noncompliant code example

r"(?:number)\d{2}"

Compliant solution

r"number\d{2}"
r"(?:number)?\d{2}"

Exceptions

This rule does not report an issue if the non-capturing group is an alternation.

r"(?:number|string)"




© 2015 - 2025 Weber Informatics LLC | Privacy Policy