mirror of
https://github.com/github/codeql.git
synced 2026-06-28 16:17:03 +02:00
28 lines
819 B
Plaintext
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)
|
|
}
|
|
}
|