mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Merge pull request #10093 from smowton/smowton/feature/java-singular-locations
Java: pick an arbitrary representative location when an entity has many candidate locations.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Classes and methods that are seen with several different paths during the extraction process (for example, packaged into different JAR files) now report an arbitrarily selected location via their `getLocation` and `hasLocationInfo` predicates, rather than reporting all of them. This may lead to reduced alert duplication.
|
||||
@@ -205,5 +205,19 @@ cached
|
||||
private predicate fixedHasLocation(Top l, Location loc, File f) {
|
||||
hasSourceLocation(l, loc, f)
|
||||
or
|
||||
hasLocation(l, loc) and not hasSourceLocation(l, _, _) and locations_default(loc, f, _, _, _, _)
|
||||
// When an entity has more than one location, as it might due to
|
||||
// e.g. a parameterized generic being seen and extracted in several
|
||||
// different directories or JAR files, select an arbitrary representative
|
||||
// location to avoid needlessly duplicating alerts.
|
||||
//
|
||||
// Don't do this when the relevant location is in a source file, because
|
||||
// that is much more unusual and we would rather notice the bug than mask it here.
|
||||
loc =
|
||||
min(Location candidateLoc |
|
||||
hasLocation(l, candidateLoc)
|
||||
|
|
||||
candidateLoc order by candidateLoc.getFile().toString()
|
||||
) and
|
||||
not hasSourceLocation(l, _, _) and
|
||||
locations_default(loc, f, _, _, _, _)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user