Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-4632

"NOSONAR" comments should be relevant

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove the NOSONAR comment, no issue is raised in the related block
    • Highlighting:
      Hide

      the NOSONAR comment

      Show
      the NOSONAR comment
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Targeted languages:
      ABAP, C#, C, C++, Cobol, CSS, Flex, Go, HTML, Java, JavaScript, Objective-C, PHP, PL/I, PL/SQL, Python, RPG, Swift, T-SQL, TypeScript, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      1min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      It can be useful to use the in-code comment NOSONAR to suppress issues on given lines, but when those suppressions are no longer relevant they become a potential source of confusion and should be removed.

      This rule raises an issue when NOSONAR is used on a line for which no issues would be raised during analysis.

      Noncompliant Code Example

      public class A {
        // This constant definition is valid and not raising any issue
        static final int LOCAL = 42;  // NOSONAR - Noncompliant 
      

      Compliant Solution

      public class A {
        // This constant definition is valid and not raising any issue
        static final int LOCAL = 42;
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              michael.gumowski Michael Gumowski
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: