mirror of
https://github.com/github/codeql.git
synced 2026-04-21 15:05:56 +02:00
Allow @param tags to apply to record parameters
This commit is contained in:
@@ -32,12 +32,24 @@ where
|
||||
)
|
||||
or
|
||||
documentable instanceof ClassOrInterface and
|
||||
not documentable instanceof Record and
|
||||
not exists(TypeVariable tv | tv.getGenericType() = documentable |
|
||||
"<" + tv.getName() + ">" = paramTag.getParamName()
|
||||
) and
|
||||
msg =
|
||||
"@param tag \"" + paramTag.getParamName() +
|
||||
"\" does not match any actual type parameter of type \"" + documentable.getName() + "\"."
|
||||
or
|
||||
documentable instanceof Record and
|
||||
not exists(TypeVariable tv | tv.getGenericType() = documentable |
|
||||
"<" + tv.getName() + ">" = paramTag.getParamName()
|
||||
) and
|
||||
not documentable.(Record).getCanonicalConstructor().getAParameter().getName() =
|
||||
paramTag.getParamName() and
|
||||
msg =
|
||||
"@param tag \"" + paramTag.getParamName() +
|
||||
"\" does not match any actual type parameter or record parameter of record \"" +
|
||||
documentable.getName() + "\"."
|
||||
else
|
||||
// The tag has no value at all.
|
||||
msg = "This @param tag does not have a value."
|
||||
|
||||
5
java/ql/src/change-notes/2024-04-02-javadoc-records.md
Normal file
5
java/ql/src/change-notes/2024-04-02-javadoc-records.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The `java/unknown-javadoc-parameter` now accepts `@param` tags that apply to the parameters of a
|
||||
record.
|
||||
@@ -120,5 +120,18 @@ public class Test<V> {
|
||||
*/
|
||||
interface GenericInterface<T> {}
|
||||
|
||||
/**
|
||||
* @param i exists
|
||||
* @param k does not
|
||||
*/
|
||||
static record SomeRecord(int i, int j) {}
|
||||
|
||||
/**
|
||||
* @param <T> exists
|
||||
* @param i exists
|
||||
* @param k does not
|
||||
*/
|
||||
static record GenericRecord<T>(int i, int j) {}
|
||||
|
||||
// Diagnostic Matches: Incomplete inheritance relation for type java.lang.Object and supertype none
|
||||
}
|
||||
|
||||
1
java/ql/test/query-tests/SpuriousJavadocParam/options
Normal file
1
java/ql/test/query-tests/SpuriousJavadocParam/options
Normal file
@@ -0,0 +1 @@
|
||||
//semmle-extractor-options: --javac-args -source 16 -target 16
|
||||
@@ -12,3 +12,5 @@
|
||||
| Test.java:112:6:112:12 | @param | @param tag "<X>" does not match any actual type parameter of type "GenericClass". |
|
||||
| Test.java:118:6:118:12 | @param | @param tag "T" does not match any actual type parameter of type "GenericInterface". |
|
||||
| Test.java:119:6:119:12 | @param | @param tag "<X>" does not match any actual type parameter of type "GenericInterface". |
|
||||
| Test.java:125:6:125:12 | @param | @param tag "k" does not match any actual type parameter or record parameter of record "SomeRecord". |
|
||||
| Test.java:132:6:132:12 | @param | @param tag "k" does not match any actual type parameter or record parameter of record "GenericRecord". |
|
||||
|
||||
Reference in New Issue
Block a user