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

"/*" and "//" should not be used within comments

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove the misleading "[//|/*]" characters.
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Legacy Key:
      NestedCommentsCheck
    • Targeted languages:
      C#, Flex, Java, JavaScript, Swift
    • Covered Languages:
      C, C++, Objective-C, PL/I, PL/SQL
    • Irrelevant for Languages:
      PHP, Python, T-SQL
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • CERT:
      MSC04-C.
    • PC-Lint:
      602, 1602, 9059, 9066

      Description

      Defining a nested single-line comment within a multi-line comment invites errors. It may lead a developer to wrongly think that the lines located after the single-line comment are not part of the comment.

      If a comment starting sequence, / or //, occurs within a / comment, is it quite likely to be caused by a missing */ comment ending sequence.
      If a comment starting sequence occurs within a // comment, it is probably because a region of code has been commented-out using //.

      Noncompliant Code Example

      /* some comment, end comment marker accidentally omitted
      // Make sure this function is called in a thread safe context
      Perform_Critical_Safety_Function(X);
      ...
      /* this comment is non-compliant */
      

      See

      • CERT, MSC04-C. - Use comments consistently and in a readable fashion

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                freddy.mallet Freddy Mallet (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: