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

Forward declarations should not be redundant

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove this redundant forward declaration; the declaration was already made.
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way, MISRA C++ 2008 recommended
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • CPPCheck:
      unnecessaryForwardDeclaration

      Description

      Redundant forward declarations simply clutter the code, and like any duplications, should be removed.

      Noncompliant Code Example

      struct S {
        // ...
      };
      // ...
      struct S;  // Noncompliant
      

      Compliant Solution

      struct S {
        // ...
      };
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated: