Skip to content

Commit c75329d

Browse files
committed
Python: Move metrics-related API to LegacyPointsTo module
Gets rid of the `getMetrics` methods on the `Function`, `Class`, and `Module` classes. To access the metrics, one must first import the `LegacyPointsTo` module, and then either change the type to `{Function,Class,Module}Metrics` or cast to the appropriate type.
1 parent cd1619b commit c75329d

File tree

5 files changed

+2
-10
lines changed

5 files changed

+2
-10
lines changed

python/ql/lib/LegacyPointsTo.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import semmle.python.types.Exceptions
3434
import semmle.python.types.Properties
3535
import semmle.python.types.Descriptors
3636
import semmle.python.SelfAttribute
37+
import semmle.python.Metrics
3738

3839
/**
3940
* An extension of `ControlFlowNode` that provides points-to predicates.

python/ql/lib/python.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import semmle.python.Patterns
1414
import semmle.python.Keywords
1515
import semmle.python.Comprehensions
1616
import semmle.python.Flow
17-
import semmle.python.Metrics
17+
private import semmle.python.Metrics
1818
import semmle.python.Constants
1919
import semmle.python.Scope
2020
import semmle.python.Comment

python/ql/lib/semmle/python/Class.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,6 @@ class Class extends Class_, Scope, AstNode {
147147
/** Gets a base of this class definition. */
148148
Expr getABase() { result = this.getParent().getABase() }
149149

150-
/** Gets the metrics for this class */
151-
ClassMetrics getMetrics() { result = this }
152-
153150
/**
154151
* Gets the qualified name for this class.
155152
* Should return the same name as the `__qualname__` attribute on classes in Python 3.

python/ql/lib/semmle/python/Function.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ class Function extends Function_, Scope, AstNode {
8484
/** Gets the name used to define this function */
8585
override string getName() { result = Function_.super.getName() }
8686

87-
/** Gets the metrics for this function */
88-
FunctionMetrics getMetrics() { result = this }
89-
9087
/**
9188
* Whether this function is a procedure, that is, it has no explicit return statement and always returns None.
9289
* Note that generator and async functions are not procedures as they return generators and coroutines respectively.

python/ql/lib/semmle/python/Module.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ class Module extends Module_, Scope, AstNode {
8686
result = this.getName().regexpReplaceAll("\\.[^.]*$", "")
8787
}
8888

89-
/** Gets the metrics for this module */
90-
ModuleMetrics getMetrics() { result = this }
91-
9289
string getAnImportedModuleName() {
9390
exists(Import i | i.getEnclosingModule() = this | result = i.getAnImportedModuleName())
9491
or

0 commit comments

Comments
 (0)