Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 57180c2

Browse files
author
Max Schaefer
committed
Simplify consistency query.
Unlike the old ODASA consistency queries, new consistency queries can have expected results, so there is no need to have special handling of files with expected errors.
1 parent d7cfcf4 commit 57180c2

File tree

14 files changed

+14
-22
lines changed

14 files changed

+14
-22
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.go:7:1:7:1 | expected declaration, found This |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.go:7:1:7:1 | expected declaration, found This |
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
/**
22
* @name Unexpected frontend error
33
* @description This query produces a list of all errors produced by the Go frontend
4-
* during extraction, except for those occurring in files annotated with
5-
* "// codeql test: expect frontend errors".
4+
* during extraction.
65
* @id go/unexpected-frontend-error
76
*/
87

98
import go
109

1110
from Error e
12-
where
13-
not exists(Comment c | c.getFile() = e.getFile() |
14-
c.getText().trim() = "codeql test: expect frontend errors"
15-
)
1611
select e

ql/test/consistency/test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package main
22

33
// autoformat-ignore (gofmt chokes on invalid programs)
44

5-
// Example file with a syntax error to demonstrate use of "expect frontend errors" directive
6-
7-
// codeql test: expect frontend errors
5+
// Example file with a syntax error to demonstrate use of consistency queries
86

97
This is not a valid Go program
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| unknownFunction.go:9:7:9:7 | undeclared name: unknownFunction |

ql/test/library-tests/semmle/go/Types/SignatureType_getNumParameter.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
| pkg1/tst.go:33:1:35:1 | function declaration | 0 |
1010
| pkg1/tst.go:37:1:37:26 | function declaration | 1 |
1111
| pkg1/tst.go:39:1:57:1 | function declaration | 2 |
12-
| unknownFunction.go:10:1:14:1 | function declaration | 0 |
12+
| unknownFunction.go:8:1:12:1 | function declaration | 0 |

ql/test/library-tests/semmle/go/Types/SignatureType_getNumResult.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
| pkg1/tst.go:33:1:35:1 | function declaration | 1 |
1010
| pkg1/tst.go:37:1:37:26 | function declaration | 0 |
1111
| pkg1/tst.go:39:1:57:1 | function declaration | 0 |
12-
| unknownFunction.go:10:1:14:1 | function declaration | 0 |
12+
| unknownFunction.go:8:1:12:1 | function declaration | 0 |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| unknownFunction.go:11:7:11:21 | unknownFunction | invalid type |
2-
| unknownFunction.go:11:7:11:23 | call to unknownFunction | invalid type |
3-
| unknownFunction.go:12:7:12:15 | ...+... | invalid type |
1+
| unknownFunction.go:9:7:9:21 | unknownFunction | invalid type |
2+
| unknownFunction.go:9:7:9:23 | call to unknownFunction | invalid type |
3+
| unknownFunction.go:10:7:10:15 | ...+... | invalid type |

ql/test/library-tests/semmle/go/Types/unknownFunction.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package main
22

33
// This file tests type inference for expressions referencing undeclared entities.
4-
// It is therefore expected to expected frontend errors.
5-
6-
// codeql test: expect frontend errors
4+
// It is therefore expected to produce frontend errors.
75

86
import "fmt"
97

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| main.go:36:9:36:9 | undeclared name: unknownFunction |

0 commit comments

Comments
 (0)