Skip to content

sonar.cxx.metric.api.file.suffixes

guwirth edited this page Mar 10, 2021 · 4 revisions

The configuration parameter sonar.cxx.metric.api.file.suffixes is used to configure the CXX Metrics Public API .... The configuration can be done in the file sonar-project.properties or in the SonarQube UI under Administartion > Configuration > CXX.

For files with the file extensions specified, 'Public API' is searched for and a metric is created. The metric is displayed in the SonarQube UI under Project > Measures > CXX.

Example:

sonar.cxx.metric.api.file.suffixes=.h,.hpp

Public API

Following items are considered as Public API:

  • classes/structures/unions
  • class/structure/union members (public and protected only)
  • template declarations
  • enumeration declarations
  • enumeration definitions
  • typedef/alias declarations
  • functions (global scope)
  • variables (global scope)

Exceptions that do not require documentation:

  • Member functions marked with identifier override. Assumption is that they are documented in the base class.
  • Member functions marked with specifier delete or default
  • Member functions defined outside of a class/struct. Assumption is that they are already documented inside of the class.

The following code illustrates a well documented class:

/**
  class documentation
 */
class DocumentedClass {
  public:

    DocumentedClass() = default;
    DocumentedClass& operator(const DocumentedClass&) = delete;

    int commentedVar; ///< documentation

    void apiFromBaseClass() = override;

    /**
      apiMethod documentation
     */
    void apiMethod();

  private:
    void notInApiMethod();
};

void DocumentedClass::apiMethod()
{
   // documentation should be within the class definition
}
Clone this wiki locally