Python S1110: Double Parenthesis false positive for generators and default options

Template for a good false-positive report, formatted with Markdown:

  • versions used (SonarQube, Scanner, language analyzer)
  • minimal code sample to reproduce (with analysis parameter, and potential instructions to compile).

Wrap code around triple quote ``` for proper formatting

SonarQube version used: 6.2
code sample:

a_list = [1, 2, 3, 4]

next((val for val in a_list if a%5==0), None)

For the above code sample, you need the generator to be inside parentheses since we are also adding a default value (None).

a = [1, 2, 3]
def a_func():
     return (list(val) for val in a)

Trying to generate a genexpr for a list with some criteria.

I can’t reproduce that false positive with the latest version of the python analyzer.
The behavior of that rule was changed 2 years ago: see SONARPY-200.
Please consider upgrading your SonarQube server.