Home > database >  SonarQube considering SQL DML entries to have duplicate values
SonarQube considering SQL DML entries to have duplicate values

Time:11-02

I have the below code in my Github respository:

INSERT INTO lookup_tables.view_da_status_lookup(status_id, object_type, status_name, status_type, ui_dropdown_flag, last_updt_ts)
    VALUES 
(1,'View','Validation success','Maker Validation',true,CURRENT_TIMESTAMP),
(2,'View','Validation Failed','Maker Validation',true,CURRENT_TIMESTAMP),
(3,'View','Approved','Checker Validation',true,CURRENT_TIMESTAMP);

Maker Validation is repeated in the DML and it expects us to use a variable and have the command in a PL-SQL construct.

This is the error I get:

Define a constant instead of duplicating this literal 1 times.

However, we do not have to implement PL-SQL. Is there a way to tell it to ignore the error?

CodePudding user response:

On the following link, you can find:

Exclude specific rules from specific files

Analysis Scope > D. Issue > Exclusions > Ignore Issues on Multiple Criteria

You can prevent specific rules from being applied to specific files by combining one or more pairs of strings consisting of a** rule key pattern and a **file path pattern.

The key for this parameter is sonar.issue.ignore.multicriteria. However, because it is a multi-value property, we recommend that only be set through the UI.

For example, if you use Maven, the setting should look like this:

<properties>
        <sonar.issue.ignore.multicriteria>e1,e2</sonar.issue.ignore.multicriteria>
        <sonar.issue.ignore.multicriteria.e1.ruleKey>squid:S00100</sonar.issue.ignore.multicriteria.e1.ruleKey>
        <sonar.issue.ignore.multicriteria.e1.resourceKey>**/*Steps.java</sonar.issue.ignore.multicriteria.e1.resourceKey>
        <sonar.issue.ignore.multicriteria.e2.ruleKey>squid:S1118</sonar.issue.ignore.multicriteria.e2.ruleKey>
        <sonar.issue.ignore.multicriteria.e2.resourceKey>**/PropertyPlaceholderConfig.java</sonar.issue.ignore.multicriteria.e2.resourceKey>
</properties>

where e1 and e2 are local rule names, e1.ruleKey is sonarqube rule id and e1.resourceKey is path to file.

  • Related