Why do you believe it’s a false-positive/false-negative? Pretty much any “declarative pipeline” Jenkinsfile has four levels of nesting before reaching the actual executable code, which is already more than the three allowed by the rule’s default configuration, and it is desirable to allow one or two levels within the executable code. A “scripted pipeline” Jenkinsfile starts out with two levels, but likely has more nested structures inside that.
Are you using
SonarQube Cloud
How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
Sample declarative pipeline from the Jenkins documentation at Creating your first Pipeline :
I’m not sure about the best solution, but I’d like to write Jenkinsfiles without receiving warnings from S134, without modifying any Sonar configuration.
The rule is talking about Control flow statements “if”, “for”, “while”, “switch” and “try” but it counts “pipeline”, “stages”, “stage”, “steps”.. as well as “node”, “timeout”, “stage”, … and none of these is really increasing complexity.
The behavior leads to having this issue in every pipeline.
Will the solution be that the rule will ignore a fixed hardcoded set of expected blocks? Or will it be possible to at least add individual blocks for exclusion in some configuration field?
I just thought that it might be a bit more comfortable if we could adapt the exception list to our needs. E.g. if new expected blocks are introduced by a jenkins update and the installed sonar version does not support it yet.
There might also be examples/reasons that we want to exclude additional statements from the complexity check which are not keywords from Jenkins.