Files
codeql/java/ql/lib/semmle/code/java/metrics/MetricStmt.qll
2025-06-24 10:25:06 +02:00

28 lines
819 B
Plaintext

/**
* Provides classes and predicates for computing metrics on Java statements.
*/
overlay[local?]
module;
import semmle.code.java.Statement
/** This class provides access to metrics information for statements. */
class MetricStmt extends Stmt {
/** Gets a nesting depth of this statement. */
int getANestingDepth() {
not exists(Stmt s | s.getParent() = this) and result = 0
or
result = this.getAChild().(MetricStmt).getANestingDepth() + 1
}
/** Gets the maximum nesting depth of this statement. */
int getNestingDepth() { result = max(this.getANestingDepth()) }
/** Gets the nested depth of this statement. */
int getNestedDepth() {
not this.getParent() instanceof Stmt and result = 0
or
exists(MetricStmt s | s = this.getParent() and result = s.getNestedDepth() + 1)
}
}