From e8de8433f4a8493ffb50292f2d7f4ffd0cb7e258 Mon Sep 17 00:00:00 2001 From: Taus Date: Wed, 18 Feb 2026 16:41:57 +0000 Subject: [PATCH] Python: Update all metrics-dependant queries The ones that no longer require points-to no longer import `LegacyPointsTo`. The ones that do use the specific `...MetricsWithPointsTo` classes that are applicable. --- python/ql/src/Functions/OverlyComplexDelMethod.ql | 2 +- python/ql/src/Metrics/CLinesOfCode.ql | 1 - python/ql/src/Metrics/ClassAfferentCoupling.ql | 2 +- python/ql/src/Metrics/ClassEfferentCoupling.ql | 2 +- python/ql/src/Metrics/CommentRatio.ql | 1 - python/ql/src/Metrics/CyclomaticComplexity.ql | 2 +- python/ql/src/Metrics/DocStringRatio.ql | 1 - python/ql/src/Metrics/FLines.ql | 1 - python/ql/src/Metrics/FLinesOfCode.ql | 1 - python/ql/src/Metrics/FLinesOfComments.ql | 1 - python/ql/src/Metrics/FunctionNumberOfCalls.ql | 1 - python/ql/src/Metrics/FunctionStatementNestingDepth.ql | 1 - python/ql/src/Metrics/History/HChurn.ql | 1 - python/ql/src/Metrics/History/HLinesAdded.ql | 1 - python/ql/src/Metrics/History/HLinesDeleted.ql | 1 - python/ql/src/Metrics/History/HNumberOfAuthors.ql | 1 - python/ql/src/Metrics/History/HNumberOfCoCommits.ql | 1 - python/ql/src/Metrics/History/HNumberOfReCommits.ql | 1 - python/ql/src/Metrics/History/HNumberOfRecentAuthors.ql | 1 - python/ql/src/Metrics/History/HNumberOfRecentChangedFiles.ql | 1 - python/ql/src/Metrics/LackofCohesionInMethodsCK.ql | 1 - python/ql/src/Metrics/LackofCohesionInMethodsHM.ql | 1 - python/ql/src/Metrics/ModuleAfferentCoupling.ql | 2 +- python/ql/src/Metrics/ModuleEfferentCoupling.ql | 2 +- python/ql/src/Metrics/NumberOfParametersWithoutDefault.ql | 1 - python/ql/src/Summary/LinesOfCode.ql | 1 - python/ql/src/Summary/LinesOfUserCode.ql | 1 - python/ql/test/library-tests/ControlFlow/general/Cyclo.ql | 2 +- 28 files changed, 7 insertions(+), 28 deletions(-) diff --git a/python/ql/src/Functions/OverlyComplexDelMethod.ql b/python/ql/src/Functions/OverlyComplexDelMethod.ql index 12776db1b60..6b08a40fa29 100644 --- a/python/ql/src/Functions/OverlyComplexDelMethod.ql +++ b/python/ql/src/Functions/OverlyComplexDelMethod.ql @@ -18,6 +18,6 @@ from FunctionValue method where exists(ClassValue c | c.declaredAttribute("__del__") = method and - method.getScope().(FunctionMetrics).getCyclomaticComplexity() > 3 + method.getScope().(FunctionMetricsWithPointsTo).getCyclomaticComplexity() > 3 ) select method, "Overly complex '__del__' method." diff --git a/python/ql/src/Metrics/CLinesOfCode.ql b/python/ql/src/Metrics/CLinesOfCode.ql index 66a107a521f..274d45e8415 100644 --- a/python/ql/src/Metrics/CLinesOfCode.ql +++ b/python/ql/src/Metrics/CLinesOfCode.ql @@ -10,7 +10,6 @@ */ import python -private import LegacyPointsTo from FunctionMetrics f select f, f.getNumberOfLinesOfCode() as n order by n desc diff --git a/python/ql/src/Metrics/ClassAfferentCoupling.ql b/python/ql/src/Metrics/ClassAfferentCoupling.ql index 3faf714d09c..69983f564ec 100644 --- a/python/ql/src/Metrics/ClassAfferentCoupling.ql +++ b/python/ql/src/Metrics/ClassAfferentCoupling.ql @@ -13,5 +13,5 @@ import python private import LegacyPointsTo -from ClassMetrics cls +from ClassMetricsWithPointsTo cls select cls, cls.getAfferentCoupling() as n order by n desc diff --git a/python/ql/src/Metrics/ClassEfferentCoupling.ql b/python/ql/src/Metrics/ClassEfferentCoupling.ql index b4c5a29696b..08016a83889 100644 --- a/python/ql/src/Metrics/ClassEfferentCoupling.ql +++ b/python/ql/src/Metrics/ClassEfferentCoupling.ql @@ -13,5 +13,5 @@ import python private import LegacyPointsTo -from ClassMetrics cls +from ClassMetricsWithPointsTo cls select cls, cls.getEfferentCoupling() as n order by n desc diff --git a/python/ql/src/Metrics/CommentRatio.ql b/python/ql/src/Metrics/CommentRatio.ql index 38394c1bf4f..5886c9d09e7 100644 --- a/python/ql/src/Metrics/CommentRatio.ql +++ b/python/ql/src/Metrics/CommentRatio.ql @@ -12,7 +12,6 @@ */ import python -private import LegacyPointsTo from ModuleMetrics mm where mm.getNumberOfLines() > 0 diff --git a/python/ql/src/Metrics/CyclomaticComplexity.ql b/python/ql/src/Metrics/CyclomaticComplexity.ql index 3d9ca10dd99..1d9874ac12c 100644 --- a/python/ql/src/Metrics/CyclomaticComplexity.ql +++ b/python/ql/src/Metrics/CyclomaticComplexity.ql @@ -15,6 +15,6 @@ import python private import LegacyPointsTo -from FunctionMetrics func, int complexity +from FunctionMetricsWithPointsTo func, int complexity where complexity = func.getCyclomaticComplexity() select func, complexity order by complexity desc diff --git a/python/ql/src/Metrics/DocStringRatio.ql b/python/ql/src/Metrics/DocStringRatio.ql index 824ff5a3509..3c763c7742b 100644 --- a/python/ql/src/Metrics/DocStringRatio.ql +++ b/python/ql/src/Metrics/DocStringRatio.ql @@ -11,7 +11,6 @@ */ import python -private import LegacyPointsTo from ModuleMetrics mm where mm.getNumberOfLines() > 0 diff --git a/python/ql/src/Metrics/FLines.ql b/python/ql/src/Metrics/FLines.ql index dc5418711c9..01ea5a04f77 100644 --- a/python/ql/src/Metrics/FLines.ql +++ b/python/ql/src/Metrics/FLines.ql @@ -9,7 +9,6 @@ */ import python -private import LegacyPointsTo from ModuleMetrics m, int n where n = m.getNumberOfLines() diff --git a/python/ql/src/Metrics/FLinesOfCode.ql b/python/ql/src/Metrics/FLinesOfCode.ql index 8159eb86c57..72131d3b74f 100644 --- a/python/ql/src/Metrics/FLinesOfCode.ql +++ b/python/ql/src/Metrics/FLinesOfCode.ql @@ -11,7 +11,6 @@ */ import python -private import LegacyPointsTo from ModuleMetrics m, int n where n = m.getNumberOfLinesOfCode() diff --git a/python/ql/src/Metrics/FLinesOfComments.ql b/python/ql/src/Metrics/FLinesOfComments.ql index ac4b295003a..33523054f0c 100644 --- a/python/ql/src/Metrics/FLinesOfComments.ql +++ b/python/ql/src/Metrics/FLinesOfComments.ql @@ -10,7 +10,6 @@ */ import python -private import LegacyPointsTo from ModuleMetrics m, int n where n = m.getNumberOfLinesOfComments() + m.getNumberOfLinesOfDocStrings() diff --git a/python/ql/src/Metrics/FunctionNumberOfCalls.ql b/python/ql/src/Metrics/FunctionNumberOfCalls.ql index 60171c790bf..fb4dfe5a9d2 100644 --- a/python/ql/src/Metrics/FunctionNumberOfCalls.ql +++ b/python/ql/src/Metrics/FunctionNumberOfCalls.ql @@ -9,7 +9,6 @@ */ import python -private import LegacyPointsTo from FunctionMetrics func select func, func.getNumberOfCalls() as n order by n desc diff --git a/python/ql/src/Metrics/FunctionStatementNestingDepth.ql b/python/ql/src/Metrics/FunctionStatementNestingDepth.ql index 94f7e355750..ab40cc6068d 100644 --- a/python/ql/src/Metrics/FunctionStatementNestingDepth.ql +++ b/python/ql/src/Metrics/FunctionStatementNestingDepth.ql @@ -11,7 +11,6 @@ */ import python -private import LegacyPointsTo from FunctionMetrics func select func, func.getStatementNestingDepth() as n order by n desc diff --git a/python/ql/src/Metrics/History/HChurn.ql b/python/ql/src/Metrics/History/HChurn.ql index dba28843670..f9d90d5eb19 100644 --- a/python/ql/src/Metrics/History/HChurn.ql +++ b/python/ql/src/Metrics/History/HChurn.ql @@ -10,7 +10,6 @@ import python import external.VCS -private import LegacyPointsTo from ModuleMetrics m, int n where diff --git a/python/ql/src/Metrics/History/HLinesAdded.ql b/python/ql/src/Metrics/History/HLinesAdded.ql index 51a0af62460..8d13986988d 100644 --- a/python/ql/src/Metrics/History/HLinesAdded.ql +++ b/python/ql/src/Metrics/History/HLinesAdded.ql @@ -10,7 +10,6 @@ import python import external.VCS -private import LegacyPointsTo from ModuleMetrics m, int n where diff --git a/python/ql/src/Metrics/History/HLinesDeleted.ql b/python/ql/src/Metrics/History/HLinesDeleted.ql index 3016c9f128b..a1e3ac0275c 100644 --- a/python/ql/src/Metrics/History/HLinesDeleted.ql +++ b/python/ql/src/Metrics/History/HLinesDeleted.ql @@ -10,7 +10,6 @@ import python import external.VCS -private import LegacyPointsTo from ModuleMetrics m, int n where diff --git a/python/ql/src/Metrics/History/HNumberOfAuthors.ql b/python/ql/src/Metrics/History/HNumberOfAuthors.ql index ff00773d98c..1bc1dbb70b0 100644 --- a/python/ql/src/Metrics/History/HNumberOfAuthors.ql +++ b/python/ql/src/Metrics/History/HNumberOfAuthors.ql @@ -10,7 +10,6 @@ import python import external.VCS -private import LegacyPointsTo from ModuleMetrics m where exists(m.getNumberOfLinesOfCode()) diff --git a/python/ql/src/Metrics/History/HNumberOfCoCommits.ql b/python/ql/src/Metrics/History/HNumberOfCoCommits.ql index 4192ecf57ac..e998aaa66d4 100644 --- a/python/ql/src/Metrics/History/HNumberOfCoCommits.ql +++ b/python/ql/src/Metrics/History/HNumberOfCoCommits.ql @@ -10,7 +10,6 @@ import python import external.VCS -private import LegacyPointsTo int committedFiles(Commit commit) { result = count(commit.getAnAffectedFile()) } diff --git a/python/ql/src/Metrics/History/HNumberOfReCommits.ql b/python/ql/src/Metrics/History/HNumberOfReCommits.ql index f12c51840dc..14330692ff9 100644 --- a/python/ql/src/Metrics/History/HNumberOfReCommits.ql +++ b/python/ql/src/Metrics/History/HNumberOfReCommits.ql @@ -10,7 +10,6 @@ import python import external.VCS -private import LegacyPointsTo predicate inRange(Commit first, Commit second) { first.getAnAffectedFile() = second.getAnAffectedFile() and diff --git a/python/ql/src/Metrics/History/HNumberOfRecentAuthors.ql b/python/ql/src/Metrics/History/HNumberOfRecentAuthors.ql index 9b787f52957..6469b393dce 100644 --- a/python/ql/src/Metrics/History/HNumberOfRecentAuthors.ql +++ b/python/ql/src/Metrics/History/HNumberOfRecentAuthors.ql @@ -10,7 +10,6 @@ import python import external.VCS -private import LegacyPointsTo from ModuleMetrics m where exists(m.getNumberOfLinesOfCode()) diff --git a/python/ql/src/Metrics/History/HNumberOfRecentChangedFiles.ql b/python/ql/src/Metrics/History/HNumberOfRecentChangedFiles.ql index 501094907af..9ec94df7e76 100644 --- a/python/ql/src/Metrics/History/HNumberOfRecentChangedFiles.ql +++ b/python/ql/src/Metrics/History/HNumberOfRecentChangedFiles.ql @@ -10,7 +10,6 @@ import python import external.VCS -private import LegacyPointsTo from ModuleMetrics m where diff --git a/python/ql/src/Metrics/LackofCohesionInMethodsCK.ql b/python/ql/src/Metrics/LackofCohesionInMethodsCK.ql index f06b050827c..c0ef582c32b 100644 --- a/python/ql/src/Metrics/LackofCohesionInMethodsCK.ql +++ b/python/ql/src/Metrics/LackofCohesionInMethodsCK.ql @@ -9,7 +9,6 @@ */ import python -private import LegacyPointsTo from ClassMetrics cls select cls, cls.getLackOfCohesionCK() as n order by n desc diff --git a/python/ql/src/Metrics/LackofCohesionInMethodsHM.ql b/python/ql/src/Metrics/LackofCohesionInMethodsHM.ql index 1456b76b286..5cc77ecfb4f 100644 --- a/python/ql/src/Metrics/LackofCohesionInMethodsHM.ql +++ b/python/ql/src/Metrics/LackofCohesionInMethodsHM.ql @@ -9,7 +9,6 @@ */ import python -private import LegacyPointsTo from ClassMetrics cls select cls, cls.getLackOfCohesionHM() as n order by n desc diff --git a/python/ql/src/Metrics/ModuleAfferentCoupling.ql b/python/ql/src/Metrics/ModuleAfferentCoupling.ql index d61cc61e4da..7203d12ae84 100644 --- a/python/ql/src/Metrics/ModuleAfferentCoupling.ql +++ b/python/ql/src/Metrics/ModuleAfferentCoupling.ql @@ -13,5 +13,5 @@ import python private import LegacyPointsTo -from ModuleMetrics m +from ModuleMetricsWithPointsTo m select m, m.getAfferentCoupling() as n order by n desc diff --git a/python/ql/src/Metrics/ModuleEfferentCoupling.ql b/python/ql/src/Metrics/ModuleEfferentCoupling.ql index bfabf4b6012..a392a44e751 100644 --- a/python/ql/src/Metrics/ModuleEfferentCoupling.ql +++ b/python/ql/src/Metrics/ModuleEfferentCoupling.ql @@ -13,5 +13,5 @@ import python private import LegacyPointsTo -from ModuleMetrics m +from ModuleMetricsWithPointsTo m select m, m.getEfferentCoupling() as n order by n desc diff --git a/python/ql/src/Metrics/NumberOfParametersWithoutDefault.ql b/python/ql/src/Metrics/NumberOfParametersWithoutDefault.ql index e5164499331..00a4c1bf0db 100644 --- a/python/ql/src/Metrics/NumberOfParametersWithoutDefault.ql +++ b/python/ql/src/Metrics/NumberOfParametersWithoutDefault.ql @@ -11,7 +11,6 @@ */ import python -private import LegacyPointsTo from FunctionMetrics func select func, func.getNumberOfParametersWithoutDefault() as n order by n desc diff --git a/python/ql/src/Summary/LinesOfCode.ql b/python/ql/src/Summary/LinesOfCode.ql index 04cb33a3451..24f1f38fbd7 100644 --- a/python/ql/src/Summary/LinesOfCode.ql +++ b/python/ql/src/Summary/LinesOfCode.ql @@ -10,6 +10,5 @@ */ import python -private import LegacyPointsTo select sum(ModuleMetrics m | | m.getNumberOfLinesOfCode()) diff --git a/python/ql/src/Summary/LinesOfUserCode.ql b/python/ql/src/Summary/LinesOfUserCode.ql index f920ebb51f4..331350dae4e 100644 --- a/python/ql/src/Summary/LinesOfUserCode.ql +++ b/python/ql/src/Summary/LinesOfUserCode.ql @@ -14,7 +14,6 @@ import python import semmle.python.filters.GeneratedCode -private import LegacyPointsTo select sum(ModuleMetrics m | exists(m.getFile().getRelativePath()) and diff --git a/python/ql/test/library-tests/ControlFlow/general/Cyclo.ql b/python/ql/test/library-tests/ControlFlow/general/Cyclo.ql index a36375b7f3d..5a35a35922c 100644 --- a/python/ql/test/library-tests/ControlFlow/general/Cyclo.ql +++ b/python/ql/test/library-tests/ControlFlow/general/Cyclo.ql @@ -1,5 +1,5 @@ import python private import LegacyPointsTo -from FunctionMetrics func +from FunctionMetricsWithPointsTo func select func.toString(), func.getCyclomaticComplexity()