github / github/codeql

Java: Javadoc.getCommentedElement() returns bogus MetricElement & Annotatable

Offen
#5,289 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
question
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

Relates to #3698

For some projects the predicate `Javadoc.getCommentedElement()` returns some bogus element whose only QL classes are MetricElement and Annotatable, and which has no `toString()`:
```ql
import java

from Javadoc javadoc, Top commentedElement, boolean hasToString, boolean hasLocation
where
commentedElement = javadoc.getCommentedElement()
and forall(string qlClass | qlClass = commentedElement.getAQlClass() |
qlClass = ["MetricElement", "Annotatable"]
)
and if exists(commentedElement.toString()) then hasToString = true else hasToString = false
and if exists(commentedElement.getLocation()) then hasLocation = true else hasLocation = false
select javadoc, commentedElement.getAPrimaryQlClass(), hasToString, hasLocation
```
[Query console link](https://lgtm.com/query/7390634026556959969/)

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.