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

Declarations of functions defined outside of the class should not be marked as "inline"

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Move this "inline" specifier to the definition of the function.
    • Highlighting:
      Hide

      inline specifier

      Show
      inline specifier
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way, MISRA C++ 2008 recommended
    • Covered Languages:
      C, C++
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min

      Description

      It is a best practice in the public part of a class body, to describe only information relevant for reusers of this class, without implementation details like inline specifier.
      For inline member function defined outside of the class body, this rule verifies that inline is set on the definition and not on the declaration of the function.

      Noncompliant Code Example

      class Foo {
        public:
          inline void method();  // Noncompliant
          // ...
      };
      void Foo::method() {
        // ...
      }
      

      Compliant Solution

      class Foo {
        public:
          void method();
          // ...
      };
      inline void Foo::method() {
        // ...
      }
      

      See

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              alban.auzeill Alban Auzeill
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated: