Class FunctionMetrics
The metrics for a function
Import path
import python
Direct supertypes
Indirect supertypes
Predicates
getADependency | Dependency of Callables One callable “this” depends on another callable “result” if “this” makes some call to a method that may end up being “result”. |
getAfferentCoupling | Afferent Coupling the number of callables that depend on this method. This is sometimes called the “fan-in” of a method. |
getCyclomaticComplexity | Gets the cyclomatic complexity of the function: The number of linearly independent paths through the source code. Computed as E - N + 2P, where E = the number of edges of the graph. N = the number of nodes of the graph. P = the number of connected components, which for a single function is 1. |
getEfferentCoupling | Efferent Coupling the number of methods that this method depends on This is sometimes called the “fan-out” of a method. |
getNumberOfCalls | |
getNumberOfLines | Gets the total number of lines (including blank lines) from the definition to the end of the function |
getNumberOfLinesOfCode | Gets the number of lines of code in the function |
getNumberOfLinesOfComments | Gets the number of lines of comments in the function |
getNumberOfLinesOfDocStrings | Gets the number of lines of docstring in the function |
getNumberOfParametersWithoutDefault | |
getStatementNestingDepth |
Inherited predicates
contains | Whether this contains | from Function |
containsInScope | from Function | |
getAChildNode | Gets a child node of this node in the AST. This predicate exists to aid exploration of the AST and other experiments. The child-parent relation may not be meaningful. For a more meaningful relation in terms of dependency use Expr.getASubExpression(), Stmt.getASubStatement(), Stmt.getASubExpression() or Scope.getAStmt(). | from Function |
getADecorator | Gets a decorator of this function | from Function |
getAFlowNode | Gets a flow node corresponding directly to this node. NOTE: For some statements and other purely syntactic elements, there may not be a | from AstNode |
getAKeywordOnlyArg | Gets a keyword-only parameter of this function. | from Function |
getAKwonlyarg | Gets a keyword-only parameter of this function. | from Function_ |
getANormalExit | Gets an exit from this Scope’s control flow graph, that does not result from an exception | from Scope |
getAReturnValueFlowNode | Gets a control flow node for a return value of this function | from Function |
getAStmt | Gets a statement in the function | from Function |
getATypeParameter | Gets a type parameter of this function. | from Function_ |
getAnArg | Gets a positional parameter of this function. | from Function_ |
getAnExitNode | Gets an exit from this Scope’s control flow graph | from Scope |
getArg | Gets the nth positional parameter of this function. | from Function_ |
getArgByName | Gets the parameter of this function with the name | from Function |
getArgName | Gets the name of the nth argument (for simple arguments) | from Function |
getArgs | Gets the positional parameter list of this function. | from Function_ |
getBody | Gets the statements forming the body of this function | from Function |
getDefinition | Gets the expression defining this function | from Function |
getDocString | Gets the docstring for this scope | from Scope |
getEnclosingModule | from Scope | |
getEnclosingScope | Gets the scope in which this function occurs. This will be a class for a method, another function for nested functions, generator expressions or comprehensions, or a module for a plain function. | from Function |
getEntryNode | Gets the entry point into this Scope’s control flow graph | from Scope |
getEvaluatingScope | Gets the evaluation scope for code in this (lexical) scope. This is usually the scope itself, but may be an enclosing scope. Notably, for list comprehensions in Python 2. | from Function |
getFallthroughNode | Gets the non-explicit exit from this Scope’s control flow graph | from Scope |
getFunctionObject | Gets the FunctionObject corresponding to this function | from Function |
getKeywordOnlyArg | Gets the nth keyword-only parameter of this function. | from Function |
getKeywordOnlyParameterCount | Gets the number of keyword-only parameters | from Function |
getKwarg | Gets the dictionary (**) parameter of this function. | from Function_ |
getKwonlyarg | Gets the nth keyword-only parameter of this function. | from Function_ |
getKwonlyargs | Gets the keyword-only parameter list of this function. | from Function_ |
getLastStatement | from Scope | |
getLocation | Gets the location for this AST node | from Function |
getMetrics | Gets the metrics for this function | from Function |
getName | Gets the name used to define this function | from Function |
getParent | Gets a parent of this function | from Function_ |
getParentNode | Gets the parent node of this node in the AST. This predicate exists to aid exploration of the AST and other experiments. The child-parent relation may not be meaningful. For a more meaningful relation in terms of dependency use Expr.getASubExpression(), Stmt.getASubStatement(), Stmt.getASubExpression() or Scope.getAStmt() applied to the parent. | from AstNode |
getPositionalParameterCount | Gets the number of positional parameters | from Function |
getQualifiedName | Gets the qualified name for this function. Should return the same name as the | from Function |
getReturnNode | Gets the exit of this scope following from a return statement | from Scope |
getScope | from Function | |
getStmt | Gets the nth statement in the function | from Function |
getTypeParameter | Gets the nth type parameter of this function. | from Function_ |
getTypeParameters | Gets the type parameters of this function. | from Function_ |
getVararg | Gets the tuple (*) parameter of this function. | from Function_ |
hasKwArg | Whether this function accepts arbitrary keyword arguments. That is, whether it has a double-starred (**kwarg) parameter. | from Function |
hasVarArg | Whether this function accepts a variable number of arguments. That is, whether it has a starred (*arg) parameter. | from Function |
inSource | Holds if this scope is in the source archive, that is it is part of the code specified, not library code | from Scope |
isArtificial | Whether this syntactic element is artificial, that is it is generated by the compiler and is not present in the source | from AstNode |
isAsync | Whether the async property of this function is true. | from Function_ |
isGenerator | Whether this function is a generator function, that is whether it contains a yield or yield-from expression | from Function |
isInitMethod | Whether this function is declared in a class and is named | from Function |
isLambda | Holds if this function represents a lambda. | from Function |
isMethod | Whether this function is declared in a class | from Function |
isProcedure | Whether this function is a procedure, that is, it has no explicit return statement and always returns None. Note that generator and async functions are not procedures as they return generators and coroutines respectively. | from Function |
isPublic | Holds if this scope is deemed to be public | from Scope |
isSpecialMethod | Whether this is a special method, that is does its name have the form | from Function |
isTopLevel | Holds if this a top-level (non-nested) class or function | from Scope |
precedes | Holds if this scope can be expected to execute before | from Scope |
toString | from Function |