mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Add a consistency query
This commit is contained in:
21
java/ql/consistency-queries/locations.ql
Normal file
21
java/ql/consistency-queries/locations.ql
Normal file
@@ -0,0 +1,21 @@
|
||||
import java
|
||||
|
||||
// Locations should either be :0:0:0:0 locations (UnknownLocation, or
|
||||
// a whole file), or all 4 fields should be positive.
|
||||
Location badLocation() {
|
||||
[result.getStartLine(), result.getEndLine(), result.getStartColumn(), result.getEndColumn()] != 0 and
|
||||
[result.getStartLine(), result.getEndLine(), result.getStartColumn(), result.getEndColumn()] < 1
|
||||
}
|
||||
|
||||
// The start should not be after the end.
|
||||
Location backwardsLocation() {
|
||||
result.getStartLine() > result.getEndLine()
|
||||
or
|
||||
result.getStartLine() = result.getEndLine() and
|
||||
result.getStartColumn() > result.getEndColumn()
|
||||
}
|
||||
|
||||
from Location l
|
||||
where l = badLocation() or l = backwardsLocation()
|
||||
select l
|
||||
|
||||
Reference in New Issue
Block a user