clang-tools 22.0.0git
clang::tidy::readability::FunctionCognitiveComplexityCheck Class Reference

Checks function Cognitive Complexity metric. More...

#include <FunctionCognitiveComplexityCheck.h>

Inheritance diagram for clang::tidy::readability::FunctionCognitiveComplexityCheck:
[legend]

Public Member Functions

 FunctionCognitiveComplexityCheck (StringRef Name, ClangTidyContext *Context)
void storeOptions (ClangTidyOptions::OptionMap &Opts) override
void registerMatchers (ast_matchers::MatchFinder *Finder) override
void check (const ast_matchers::MatchFinder::MatchResult &Result) override
std::optional< TraversalKind > getCheckTraversalKind () const override

Detailed Description

Checks function Cognitive Complexity metric.

There are the following configuration option:

  • Threshold - flag functions with Cognitive Complexity exceeding this number. The default is 25.
  • DescribeBasicIncrements- if set to true, then for each function exceeding the complexity threshold the check will issue additional diagnostics on every piece of code (loop, if statement, etc.) which contributes to that complexity.

IgnoreMacros - if set to true, the check will ignore code inside macros. Default is false.

For the user-facing documentation see: https://clang.llvm.org/extra/clang-tidy/checks/readability/function-cognitive-complexity.html

Definition at line 32 of file FunctionCognitiveComplexityCheck.h.

Constructor & Destructor Documentation

◆ FunctionCognitiveComplexityCheck()

clang::tidy::readability::FunctionCognitiveComplexityCheck::FunctionCognitiveComplexityCheck ( StringRef Name,
ClangTidyContext * Context )

Definition at line 497 of file FunctionCognitiveComplexityCheck.cpp.

Member Function Documentation

◆ check()

void clang::tidy::readability::FunctionCognitiveComplexityCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

◆ getCheckTraversalKind()

std::optional< TraversalKind > clang::tidy::readability::FunctionCognitiveComplexityCheck::getCheckTraversalKind ( ) const
inlineoverride

Definition at line 39 of file FunctionCognitiveComplexityCheck.h.

◆ registerMatchers()

void clang::tidy::readability::FunctionCognitiveComplexityCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

Definition at line 511 of file FunctionCognitiveComplexityCheck.cpp.

◆ storeOptions()

void clang::tidy::readability::FunctionCognitiveComplexityCheck::storeOptions ( ClangTidyOptions::OptionMap & Opts)
override

Definition at line 504 of file FunctionCognitiveComplexityCheck.cpp.


The documentation for this class was generated from the following files: