Class MetricFunction
A wrapper that provides metrics for a C/C++ function.
Import path
import cpp
Direct supertypes
Indirect supertypes
Predicates
getAfferentCoupling | Gets the number of incoming dependencies: functions that call or access this function. |
getBranchingComplexity | Gets the branching complexity of this function. This is a measure derived from cyclomatic complexity, but it reflects only the branches that make the code difficult to read (as opposed to cyclomatic complexity, which attempts to evaluate how difficult the code is to test). |
getCommentRatio | Gets the ratio of lines of comments to total lines in this function (between 0.0 and 1.0). |
getCyclomaticComplexity | Gets the cyclomatic complexity of this function. This is defined as the number of branching statements ( |
getEfferentCoupling | Gets the number of outgoing dependencies: functions that are called or accessed by this function. |
getHalsteadDeliveredBugs | Gets the Halstead ‘delivered bugs’ metric for this function. This metric correlates with the complexity of the software, but is known to be an underestimate of bug counts. |
getHalsteadDifficulty | Gets the Halstead difficulty value of this function. This is proportional to the number of unique operators, and further proportional to the ratio of total operands to unique operands. |
getHalsteadEffort | Gets the Halstead implementation effort for this function. This is the product of the volume and difficulty. |
getHalsteadLength | Gets the Halstead length of this function. This is the sum of the N1 and N2 Halstead metrics. |
getHalsteadLevel | Gets the Halstead level of this function. This is the inverse of the difficulty of the function. |
getHalsteadN1 | Gets the Halstead “N1” metric: this is the total number of operators in this function. Operators are taken to be all operators in expressions ( |
getHalsteadN1Distinct | Gets the Halstead “n1” metric: this is the total number of distinct operators in this function. Operators (as in the N1 metric) are all operators in expressions as well as most statements. |
getHalsteadN2 | Gets the Halstead “N2” metric: this is the total number of operands in this function. An operand is either a variable, constant, type name, or function name. |
getHalsteadN2Distinct | Gets the Halstead “n2” metric: this is the number of distinct operands in this function. An operand is either a variable, constant, type name, or function name. |
getHalsteadVocabulary | Gets the Halstead vocabulary size of this function. This is the sum of the n1 and n2 Halstead metrics. |
getHalsteadVolume | Gets the Halstead volume of this function. This is the Halstead size multiplied by the log of the Halstead vocabulary. It represents the information content of the function. |
getNestingDepth | Gets the maximum nesting level of complex statements such as if, while in the function. A nesting depth of 2 would mean that there is, for example, an if statement nested in another if statement. |
getNumberOfCalls | Gets the number of function calls in this function. |
getNumberOfLines | Gets the number of lines in this function. |
getNumberOfLinesOfCode | Gets the number of lines of code in this function. |
getNumberOfLinesOfComments | Gets the number of lines of comments in this function. |
getNumberOfParameters | Gets the number of parameters. |
Inherited predicates
accesses | Holds if this function accesses a function or variable or enumerator | from Function |
accesses | Holds if this function accesses a function or variable or enumerator | from Function |
calls | Holds if this function calls the function | from Function |
calls | Holds if this function calls the function | from Function |
canAccessClass | Holds if a base class | from AccessHolder |
canAccessMember | Holds if a non-static member | from AccessHolder |
couldAccessMember | Holds if a hypothetical non-static member of | from AccessHolder |
findRootCause | Gets the source of this element: either itself or a macro that expanded to this element. | from Element |
fromSource | Holds if this element may be from source. This predicate holds for all elements, except for those in the dummy file, whose name is the empty string. The dummy file contains declarations that are built directly into the compiler. | from Element |
getACallToThisFunction | Gets a call to this function. | from Function |
getADeclaration | Gets a child declaration of this function. | from Function |
getADeclarationEntry | Gets a declaration entry corresponding to this declaration. The relationship between | from Function |
getADeclarationLocation | Gets the location of a | from Function |
getAFalseSuccessor | Gets a node such that the control-flow edge | from ControlFlowNode |
getAFile | Gets a file where this element occurs. | from Declaration |
getALinkTarget | Gets a link target which compiled or referenced this function. | from Function |
getAParameter | Gets a parameter of this function. There is no result for the implicit | from Function |
getAPredecessor | Gets a direct predecessor of this control-flow node, if any. | from ControlFlowNode |
getAPrimaryQlClass | Gets the name of a primary CodeQL class to which this element belongs. | from ElementBase |
getASpecifier | Gets a specifier of this function. | from Function |
getASuccessor | Gets a direct successor of this control-flow node, if any. | from ControlFlowNode |
getATemplateArgument | Gets a template argument used to instantiate this declaration from a template. When called on a template, this will return a template parameter type for both typed and non-typed parameters. | from Declaration |
getATemplateArgumentKind | Gets a template argument used to instantiate this declaration from a template. When called on a template, this will return a non-typed template parameter value. | from Declaration |
getAThrownType | Gets a type that is specified to be thrown by the function. | from Function |
getATrueSuccessor | Gets a node such that the control-flow edge | from ControlFlowNode |
getAWrittenVariable | Gets a variable that is written-to in this function. | from Function |
getAnAccess | Gets an access of this function. | from Function |
getAnAttribute | Gets an attribute of this function. | from Function |
getAnExplicitDeclarationEntry | Gets a non-implicit function declaration entry. | from Function |
getAnOverload | Gets a function that overloads this one. | from Function |
getBasicBlock | Gets the | from ControlFlowNode |
getBlock | Gets the block that is the function body. | from Function |
getClassAndName | Gets the class of which this function, called | from Function |
getControlFlowScope | Implements | from Function |
getDeclaringType | Gets the class where this member is declared, if it is a member. For templates, both the template itself and all instantiations of the template are considered to have the same declaring class. | from Declaration |
getDefinition | Gets the declaration entry corresponding to this declaration that is a definition, if any. | from Function |
getDefinitionLocation | Gets the location of the definition, if any. | from Function |
getDescription | Gets a description of this | from Declaration |
getEffectiveNumberOfParameters | Gets the number of parameters of this function, including any implicit | from Function |
getEnclosingAccessHolder | Gets the nearest enclosing AccessHolder. | from Function |
getEnclosingElement | Gets the closest | from Element |
getEnclosingStmt | Implements | from Function |
getEntryPoint | Gets the first node in this function’s control flow graph. | from Function |
getExplicitExpr | Gets the constant expression that determines whether the function is explicit. | from Function |
getFile | Gets the primary file where this element occurs. | from Element |
getLocation | Gets the preferred location of this declaration. (The location of the definition, if possible.) | from Function |
getMetrics | Gets the metric class. | from Function |
getName | Gets the name of this declaration. | from Function |
getNamespace | Gets the innermost namespace which contains this declaration. | from Declaration |
getNumberOfTemplateArguments | Gets the number of template arguments for this declaration. | from Declaration |
getParameter | Gets the nth parameter of this function. There is no result for the implicit | from Function |
getParameterString | Gets a string representing the parameters of this function. | from Function |
getParentScope | Gets the parent scope of this | from Element |
getPrimaryQlClasses | Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. | from ElementBase |
getQualifiedName | Gets the name of the declaration, fully qualified with its namespace and declaring type. | from Declaration |
getTemplateArgument | Gets the | from Declaration |
getTemplateArgumentKind | Gets the | from Declaration |
getThrownType | Gets the | from Function |
getType | Gets the return type of this function. | from Function |
getUnspecifiedType | Gets the return type of this function after specifiers have been deeply stripped and typedefs have been resolved. | from Function |
hasCLinkage | Holds if this function has C linkage, as specified by one of its declaration entries. For example: | from Function |
hasDeclaringType | Holds if this declaration is a member of a class/struct/union. | from Declaration |
hasDefinition | Holds if the declaration has a definition. | from Declaration |
hasEntryPoint | Holds if this function has an entry point. | from Function |
hasErrors | Holds if this function has extraction errors that create an | from Function |
hasExceptionSpecification | Holds if the function has an exception specification. | from Function |
hasGlobalName | Holds if this declaration has the given name in the global namespace. | from Declaration |
hasGlobalOrStdName | Holds if this declaration has the given name in the global namespace or the | from Declaration |
hasGlobalOrStdOrBslName | Holds if this declaration has the given name in the global namespace, the | from Declaration |
hasName | Holds if this declaration has the given name. | from Declaration |
hasQualifiedName | Holds if this declaration has a fully-qualified name with a name-space component of | from Declaration |
hasQualifiedName | Holds if this declaration has a fully-qualified name with a name-space component of | from Declaration |
hasSpecifier | Holds if this declaration has a specifier with the given name. | from Declaration |
hasTrailingReturnType | Holds if this function has a trailing return type. | from Function |
inMemberOrFriendOf | Holds if | from AccessHolder |
isAffectedByMacro | Holds if this element is affected in any way by a macro. All elements that are totally or partially generated by a macro are included, so this is a super-set of | from Element |
isCompilerGenerated | Holds if this function is generated by the compiler. | from Function |
isCondition | Holds if this node is the top-level expression of a conditional statement, meaning that | from ControlFlowNode |
isConsteval | Holds if this function is declared to be | from Function |
isConstexpr | Holds if this function is | from Function |
isConstructedFrom | Holds if this function is constructed from | from Function |
isDeclaredConstexpr | Holds if this function is declared to be | from Function |
isDeclaredVirtual | Holds if this function is declared with the | from Function |
isDefaulted | Holds if this function is explicitly defaulted with the | from Function |
isDeleted | Holds if this function is deleted. This may be because it was explicitly deleted with an | from Function |
isExplicit | Holds if this function is declared to be | from Function |
isFinal | Holds if this function is declared with the | from Function |
isFromTemplateInstantiation | Holds if this | from Element |
isFromUninstantiatedTemplate | Holds if this | from Element |
isInMacroExpansion | Holds if this element comes from a macro expansion. Only elements that are entirely generated by a macro are included - for elements that partially come from a macro, see | from Element |
isInline | Holds if this function is inline. | from Function |
isMember | Holds if this declaration is a member of a class/struct/union. | from Declaration |
isMultiplyDefined | Holds if this function is defined in several files. This is illegal in C (though possible in some C++ compilers), and likely indicates that several functions that are not linked together have been compiled. An example would be a project with many ‘main’ functions. | from Function |
isNaked | Holds if this function is declared with | from Function |
isNoExcept | Holds if this function has a | from Function |
isNoThrow | Holds if this function has a | from Function |
isOverride | Holds if this function is declared with the | from Function |
isPrototyped | Holds if this function has a prototyped interface. | from Function |
isSideEffectFree | Holds if this function is side-effect free (conservative approximation). | from Function |
isSpecialization | Holds if this function is a template specialization. | from Function |
isStatic | Holds if this declaration is static. | from Declaration |
isTopLevel | Holds if this declaration is a top-level declaration. | from Declaration |
isVarargs | Holds if this function is a varargs function. | from Function |
isVirtual | Holds if this function is virtual. | from Function |
mayHaveSideEffects | Holds if this function may have side-effects; if in doubt, we assume it may. | from Function |
toString | Gets a textual representation of this element. | from Declaration |