1+ /** Provides a class for working with metric query results stored in dashboard databases. */
2+
13import cpp
24
5+ /**
6+ * Holds if `id` in the opaque identifier of a result reported by query `queryPath`,
7+ * such that `value` is the reported metric value and the location of the result spans
8+ * column `startcolumn` of line `startline` to column `endcolumn` of line `endline`
9+ * in file `filepath`.
10+ *
11+ * For more information, see [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
12+ */
313external predicate metricResults (
414 int id , string queryPath , string file , int startline , int startcol , int endline , int endcol ,
515 float value
616) ;
717
18+ /**
19+ * A metric query result stored in a dashboard database.
20+ */
821class MetricResult extends int {
922 MetricResult ( ) { metricResults ( this , _, _, _, _, _, _, _) }
1023
24+ /** Gets the path of the query that reported the result. */
1125 string getQueryPath ( ) { metricResults ( this , result , _, _, _, _, _, _) }
1226
27+ /** Gets the file in which this query result was reported. */
1328 File getFile ( ) {
1429 exists ( string path |
1530 metricResults ( this , _, path , _, _, _, _, _) and result .getAbsolutePath ( ) = path
1631 )
1732 }
1833
34+ /** Gets the line on which the location of this query result starts. */
1935 int getStartLine ( ) { metricResults ( this , _, _, result , _, _, _, _) }
2036
37+ /** Gets the column on which the location of this query result starts. */
2138 int getStartColumn ( ) { metricResults ( this , _, _, _, result , _, _, _) }
2239
40+ /** Gets the line on which the location of this query result ends. */
2341 int getEndLine ( ) { metricResults ( this , _, _, _, _, result , _, _) }
2442
43+ /** Gets the column on which the location of this query result ends. */
2544 int getEndColumn ( ) { metricResults ( this , _, _, _, _, _, result , _) }
2645
46+ /**
47+ * Holds if there is a `Location` entity whose location is the same as
48+ * the location of this query result.
49+ */
2750 predicate hasMatchingLocation ( ) { exists ( this .getMatchingLocation ( ) ) }
2851
52+ /**
53+ * Gets the `Location` entity whose location is the same as the location
54+ * of this query result.
55+ */
2956 Location getMatchingLocation ( ) {
3057 result .getFile ( ) = this .getFile ( ) and
3158 result .getStartLine ( ) = this .getStartLine ( ) and
@@ -34,8 +61,10 @@ class MetricResult extends int {
3461 result .getEndColumn ( ) = this .getEndColumn ( )
3562 }
3663
64+ /** Gets the value associated with this query result. */
3765 float getValue ( ) { metricResults ( this , _, _, _, _, _, _, result ) }
3866
67+ /** Gets the URL corresponding to the location of this query result. */
3968 string getURL ( ) {
4069 result =
4170 "file://" + getFile ( ) .getAbsolutePath ( ) + ":" + getStartLine ( ) + ":" + getStartColumn ( ) + ":" +
0 commit comments