G-1910
🆓Avoid using the NOSONAR marker.
Reason
SonarQube uses the NOSONAR marker to quickly exclude false positives. But when used often and increasingly this is a potential sign of hidden quality issues.
Furthermore, a NOSONAR marker hides all issues on a line. Without a comment, the reader does not know why it was introduced. A more powerful alternative is to use the dbLinter marker, which can be set for various scopes (file, statement, function or procedure). The syntax is @DBLINTER IGNORE(rule1 [, rule2]...) [comment].
Examples
Non-Compliant Example
declare l_value pls_integer := null; -- NOSONAR G-2140: False positive begin sys.dbms_output.put_line(l_value); end; /
Issues
| Line | Column | Message |
|---|---|---|
| 2 | 36 |
Hides the G-2140 violation (Never initialize variables with NULL).
Compliant Solution - ★☆☆☆☆
declare l_value pls_integer := null; -- @dbLinter ignore(G-2140) False positive begin sys.dbms_output.put_line(l_value); end; /
The NOSONAR marker has been replaced with a @dbLinter ignore marker. This indicates that a G-2140 violation has been ignored. However, this is not a false positive.
Compliant Solution - ★★★☆☆
declare l_value pls_integer := null; begin sys.dbms_output.put_line(l_value); end; /
The NOSONAR marker is removed. The G-2140 violation is not hidden anymore.
Compliant Solution - ★★★★★
declare l_value pls_integer; begin sys.dbms_output.put_line(l_value); end; /
The G-2140 violation is resolved. Code is not unnecessarily initialized with null anymore.
Parameters
Use parameters to customize the rule to your needs.
| Parameter | Description | Default Value |
|---|---|---|
| AllowNosonarMarkers | Comma-separated list of rules for which a NOSONAR marker is allowed. | Core G-1910 |
References
- same as Trivadis G-0000
G-0000 is not explicitly documented as a guideline. However, it is used within the db* CODECOP product suite.
- same as plsql:NoSonarCheck