green-code-initiative / ecoCode

Reduce the environmental footprint of your software programs with SonarQube
https://ecocode.io
GNU General Public License v3.0
139 stars 76 forks source link

[EC2] too binding detection #346

Closed TristanL06 closed 1 month ago

TristanL06 commented 1 month ago

Describe the bug The EC2 rule detect multiple if-else and ask to replace them by a single switch-case. This rule should detect only more than 4 variable access if-else since #222 and issue #216 but still detecting 2-variable-access code.

To Reproduce on code :

if (a == null || b == null) {
    if (a == null) {
        ...
    } else {
        ...
    }
}

This code should be compliant but it is rased as non compliant for rule EC2.

Software Versions

dedece35 commented 1 month ago

Hi @TristanL06, thank you for the issue. As seen together, here is an exaplanation :

if (a == null) { ... } else { ... } ...

dedece35 commented 1 month ago

if we are ok, I will close this issue. ok for you @TristanL06 ?

TristanL06 commented 1 month ago

it seems clear for me