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

Unused functions and methods should be removed

    Details

    • Message:
      Remove or use this unused function.
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Targeted languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Level:
      Semantic Analysis
    • MISRA C++ 2008:
      0-1-10

      Description

      Functions or methods that are not called may be symptomatic of a serious problem, such as missing paths. 

      Noncompliant Code Example

      static void unusedStaticFunction() { // Noncompliant: function is never used
      }
      
      namespace test {
        namespace { 
          class A {
            void f(); // Noncompliant: member function is never used
          }; 
        }
        
        void g(A a); // Noncompliant: function is never used
      }
      

      See

      • MISRA C++:2008, 0-1-10 - Every defined function shall be called at least once.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: