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

Comment styles "//" and "/* ... */" should not be mixed within a file

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Use either // or /* ... */ comments, but do not mix them (see lines X and Y).
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Legacy Key:
      CommentMixedStyles
    • Covered Languages:
      C, C++, Objective-C
    • Irrelevant for Languages:
      ABAP, C#, Cobol, Flex, Go, HTML, Java, JavaScript, PHP, PL/I, PL/SQL, Python, RPG, Swift, T-SQL, TypeScript, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Level:
      Syntactic Analysis
    • Common Rule:
      Yes
    • CERT:
      MSC55-J.

      Description

      Use either the // ... or /* ... */ comment syntax, but be consistent and do not mix them within the same file.

      Noncompliant Code Example

      /* Noncompliant; both comment syntaxes are used in the same file */
      // Foo
      /* Bar */
      

      Compliant Solution

      // Compliant; uniform comment syntax
      // Foo
      // Bar
      

      See

      • CERT, MSC55-J. - Use comments consistently and in a readable fashion

        Attachments

          Issue Links

          1.
          C-Family RSPEC-4354 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ann.campbell.2 Ann Campbell
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: