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

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

There is a newer version: 4.23.0.17664
Show newest version

Why is this an issue?

There are several reasons to use a group in a regular expression:

  • to change the precedence (e.g. do(g|or) will match 'dog' and 'door')
  • to remember parenthesised part of the match in the case of capturing group
  • to improve readability

In any case, having an empty group is most probably a mistake. Either it is a leftover after refactoring and should be removed, or the actual parentheses were intended and were not escaped.

Noncompliant code example

r"foo()" # Noncompliant, will match only 'foo'

Compliant solution

r"foo\(\)" # Matches 'foo()'




© 2015 - 2024 Weber Informatics LLC | Privacy Policy