github / github/codeql

Java: Comparing Location leads to incorrect results

Open
#3,644 2 comments 0 reactions 0 assignees View on GitHub
Java question
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

**Description of the issue**
It appears when comparing `Location` of two different elements non-existent or incorrect results are found.
Try the query below on the default projects on https://lgtm.com/query:
```
import java

from ArrayTypeAccess arrayTypeAccess, Location location, RValue other, Location otherLocation
where
arrayTypeAccess.getFile() = other.getFile()
and location = arrayTypeAccess.getLocation()
and otherLocation = other.getLocation()
and location.getStartLine() = otherLocation.getStartLine()
and location.getEndLine() = otherLocation.getEndLine()
and location.getStartColumn() = otherLocation.getStartColumn()
and location.getEndColumn() = otherLocation.getEndColumn()
select arrayTypeAccess, other
```

It finds ArrayTypeAccess' where there are none and also finds RValues of variables which do not exist at that position.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.