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:
Max Schaefer
2020-08-24 17:37:51 +01:00
parent d7cfcf46a5
commit 57180c24c7
14 changed files with 14 additions and 22 deletions

View File

@@ -0,0 +1 @@
| test.go:7:1:7:1 | expected declaration, found This |

View File

@@ -0,0 +1 @@
| test.go:7:1:7:1 | expected declaration, found This |

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1 @@
| unknownFunction.go:9:7:9:7 | undeclared name: unknownFunction |

View File

@@ -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 |

View File

@@ -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 |

View File

@@ -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 |

View File

@@ -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"

View File

@@ -0,0 +1 @@
| main.go:36:9:36:9 | undeclared name: unknownFunction |

View File

@@ -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. |

View File

@@ -2,8 +2,6 @@ package p
import "fmt"
// codeql test: expect frontend errors
func test() {
if false {
x := deadStore() // OK

View File

@@ -0,0 +1 @@
| err.go:6:7:6:7 | undeclared name: unknownFunction |

View File

@@ -2,8 +2,6 @@ package main
import "fmt"
// codeql test: expect frontend errors
func errtest() {
x := unknownFunction()
var y interface{} = x