plsql:DecodeFunctionUsageCheck wrong behaviour in group by

With Sonar version : Developer Edition Version 8.9.1 (build 44547)
We detected that rule suggesting to use case instead of decode that was improved following my previous request (see SONARPLSQL-726) does not have the same behavior in SELECT section than in GROUP BY section of a query.

In SELECT section last version of the rule (after SONARPLSQL-726) is working well and considers acceptable the usage of a “simple” decode.
But the same decode in the GROUP BY section of the same query is hit by the rule.

I guess this is something missing in the implementation of the SONARPLSQL-726.

Code to reproduce:

    count(emp.first_name)                          as number_of_emp,
    DECODE(active_flag, 'Y', 'Active', 'Inactive') as status
FROM employee
    DECODE(active_flag, 'Y', 'Active', 'Inactive');


Hello @SebG!

Unfortunately, I could not reproduce it. I analyzed the snippet that you provided with SonarQube Developer Edition 8.9.1 (build 44547) but no issue was raised.
The rule worked as expected, and an issue was raised only when I added to DECODE more than 1 case.

In case you still get a false positive issue, would it be possible to run an analysis with verbose logs and attach the result here?

You can do this like so:
sonar-scanner.bat -D"sonar.login"="token" -D"sonar.projectKey"="projectKey" -X -D"sonar.verbose"="true" > result.log

Best Regards

Hello @Mary_Georgiou
with version 8.9.8 the problem does not occur anymore.
I did not reproduce it
I don’t remember in which source code we had it.

Let’s close this case and if I see it again I will tell you.

1 Like