Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 06d9d30

Browse files
committed
Java: More consistency queries
1 parent b2acb7d commit 06d9d30

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

java/ql/consistency-queries/locations.ql

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import java
2+
import semmle.code.configfiles.ConfigFiles
23

34
// Locations should either be :0:0:0:0 locations (UnknownLocation, or
45
// a whole file), or all 4 fields should be positive.
@@ -15,7 +16,20 @@ Location backwardsLocation() {
1516
result.getStartColumn() > result.getEndColumn()
1617
}
1718

19+
Location unusedLocation() {
20+
not exists(Top t | t.getLocation() = result) and
21+
not exists(XMLLocatable x | x.getLocation() = result) and
22+
not exists(ConfigLocatable c | c.getLocation() = result) and
23+
not (result.getFile().getExtension() = "xml" and
24+
result.getStartLine() = 0 and
25+
result.getStartColumn() = 0 and
26+
result.getEndLine() = 0 and
27+
result.getEndColumn() = 0)
28+
}
29+
1830
from Location l
19-
where l = badLocation() or l = backwardsLocation()
31+
where l = badLocation()
32+
or l = backwardsLocation()
33+
or l = unusedLocation()
2034
select l
2135

0 commit comments

Comments
 (0)