CodeQL documentation

Poorly documented large function

ID: cpp/poorly-documented-function
Kind: problem
Security severity: 
Severity: warning
Precision: medium
Tags:
   - maintainability
   - documentation
   - statistical
   - non-attributable
Query suites:
   - cpp-security-and-quality.qls

Click to see the query in the CodeQL repository

This rule finds large functions that have too few comment lines. Documentation becomes more important as a function becomes more complex, and a lack of documentation makes it harder to maintain.

Recommendation

Add comments to document the purpose of the function. Large, complex functions in particular require detailed documentation, not only because they are harder to understand, but the process of documentation may reveal that the function could be split into smaller, more cohesive functions.

References

  • © GitHub, Inc.
  • Terms
  • Privacy