mirror of
https://github.com/github/codeql.git
synced 2026-01-28 22:02:57 +01:00
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.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
| test.go:7:1:7:1 | expected declaration, found This |
|
||||
@@ -0,0 +1 @@
|
||||
| test.go:7:1:7:1 | expected declaration, found This |
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
/**
|
||||
* @name Unexpected frontend error
|
||||
* @description This query produces a list of all errors produced by the Go frontend
|
||||
* during extraction, except for those occurring in files annotated with
|
||||
* "// codeql test: expect frontend errors".
|
||||
* during extraction.
|
||||
* @id go/unexpected-frontend-error
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
from Error e
|
||||
where
|
||||
not exists(Comment c | c.getFile() = e.getFile() |
|
||||
c.getText().trim() = "codeql test: expect frontend errors"
|
||||
)
|
||||
select e
|
||||
|
||||
@@ -2,8 +2,6 @@ package main
|
||||
|
||||
// autoformat-ignore (gofmt chokes on invalid programs)
|
||||
|
||||
// Example file with a syntax error to demonstrate use of "expect frontend errors" directive
|
||||
|
||||
// codeql test: expect frontend errors
|
||||
// Example file with a syntax error to demonstrate use of consistency queries
|
||||
|
||||
This is not a valid Go program
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
| unknownFunction.go:9:7:9:7 | undeclared name: unknownFunction |
|
||||
@@ -9,4 +9,4 @@
|
||||
| pkg1/tst.go:33:1:35:1 | function declaration | 0 |
|
||||
| pkg1/tst.go:37:1:37:26 | function declaration | 1 |
|
||||
| pkg1/tst.go:39:1:57:1 | function declaration | 2 |
|
||||
| unknownFunction.go:10:1:14:1 | function declaration | 0 |
|
||||
| unknownFunction.go:8:1:12:1 | function declaration | 0 |
|
||||
|
||||
@@ -9,4 +9,4 @@
|
||||
| pkg1/tst.go:33:1:35:1 | function declaration | 1 |
|
||||
| pkg1/tst.go:37:1:37:26 | function declaration | 0 |
|
||||
| pkg1/tst.go:39:1:57:1 | function declaration | 0 |
|
||||
| unknownFunction.go:10:1:14:1 | function declaration | 0 |
|
||||
| unknownFunction.go:8:1:12:1 | function declaration | 0 |
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
| unknownFunction.go:11:7:11:21 | unknownFunction | invalid type |
|
||||
| unknownFunction.go:11:7:11:23 | call to unknownFunction | invalid type |
|
||||
| unknownFunction.go:12:7:12:15 | ...+... | invalid type |
|
||||
| unknownFunction.go:9:7:9:21 | unknownFunction | invalid type |
|
||||
| unknownFunction.go:9:7:9:23 | call to unknownFunction | invalid type |
|
||||
| unknownFunction.go:10:7:10:15 | ...+... | invalid type |
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package main
|
||||
|
||||
// This file tests type inference for expressions referencing undeclared entities.
|
||||
// It is therefore expected to expected frontend errors.
|
||||
|
||||
// codeql test: expect frontend errors
|
||||
// It is therefore expected to produce frontend errors.
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
| main.go:36:9:36:9 | undeclared name: unknownFunction |
|
||||
@@ -1,4 +1,4 @@
|
||||
| main.go:27:2:27:2 | assignment to x | This definition of x is never used. |
|
||||
| main.go:25:2:25:2 | assignment to x | This definition of x is never used. |
|
||||
| testdata.go:32:2:32:2 | assignment to x | This definition of x is never used. |
|
||||
| testdata.go:37:2:37:2 | assignment to x | This definition of x is never used. |
|
||||
| testdata.go:61:2:61:2 | assignment to x | This definition of x is never used. |
|
||||
|
||||
@@ -2,8 +2,6 @@ package p
|
||||
|
||||
import "fmt"
|
||||
|
||||
// codeql test: expect frontend errors
|
||||
|
||||
func test() {
|
||||
if false {
|
||||
x := deadStore() // OK
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
| err.go:6:7:6:7 | undeclared name: unknownFunction |
|
||||
@@ -2,8 +2,6 @@ package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// codeql test: expect frontend errors
|
||||
|
||||
func errtest() {
|
||||
x := unknownFunction()
|
||||
var y interface{} = x
|
||||
|
||||
Reference in New Issue
Block a user