plsql:DecodeFunctionUsageCheck rule too strict

(My config : SonarQube: 6.7.6 , PL/SQL plugin 3.4.1 (build 2576))
Hi,
I had a doubt to open this here or in suggest new feature category.
As it concerns an enhancement (a kind of false-positive) of an existing rule and not a new rule, I open it here. Feel free to move if it is not the right place.

My remark concerns the detection of Decode usages.
I agree with the rule and prefer to use Case is most of the cases.

But when the decode has only one matching value and the default, for readability it is better to keep decode.

See below example:

SELECT
    emp.first_name                                    as first_name,
    emp.last_name                                     as last_name,
    DECODE(show_data_flag, 'Y', emp.salary, 'Hidden') as salary,
    DECODE(show_data_flag, 'Y', emp.bonus,  'Hidden') as bonus,
    ...
FROM employee
    ...

VS

SELECT
    emp.first_name                                  as first_name,
    emp.last_name                                   as last_name,
    CASE
        WHEN show_data_flag = 'Y' THEN emp.salary 
        ELSE 'Hidden' 
    END                                             as salary,
    CASE
        WHEN show_data_flag = 'Y' THEN emp.bonus
        ELSE 'Hidden' 
    END                                             as bonus,
    ...
FROM employee
    ...

Thanks in advance to take the time to evaluate this.
S.G.

No interest for my question ? :wink:

Hi,

Sorry for such delay. Indeed we agree that your case can be considered as false positive. The ticket is created to fix that.

Thank you to have took it into account.
I will spent less time to explain to PL/SQL developers why Sonar hit their decodes when they are (very) simple.

:+1:

Any news about this request?
Thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.