зеркало из https://github.com/github/codeql.git
Kotlin: Enable java/misnamed-type query
We used to get alerts for the class around a local function, a lambda, or a function reference, which we give name "". Now those are marked as compiler-generated, and the query ignores compiler-generated types.
This commit is contained in:
Родитель
3c7f7511be
Коммит
a423f5f695
|
@ -5396,6 +5396,7 @@ open class KotlinFileExtractor(
|
|||
val id = ids.type.javaResult.id.cast<DbClass>()
|
||||
val pkgId = extractPackage("")
|
||||
tw.writeClasses(id, "", pkgId, id)
|
||||
tw.writeCompiler_generated(id, CompilerGeneratedKinds.CALLABLE_CLASS.kind)
|
||||
tw.writeHasLocation(id, locId)
|
||||
|
||||
// Extract constructor
|
||||
|
@ -5520,5 +5521,6 @@ open class KotlinFileExtractor(
|
|||
DEFAULT_ARGUMENTS_METHOD(10),
|
||||
INTERFACE_FORWARDER(11),
|
||||
ENUM_CONSTRUCTOR_ARGUMENT(12),
|
||||
CALLABLE_CLASS(13),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ class Element extends @element, Top {
|
|||
i = 11 and result = "Forwarder for a Kotlin class inheriting an interface default method"
|
||||
or
|
||||
i = 12 and result = "Argument for enum constructor call"
|
||||
or
|
||||
i = 13 and result = "The class around a local function, a lambda, or a function reference"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ import java
|
|||
|
||||
from RefType t
|
||||
where
|
||||
t.getFile().isJavaSourceFile() and
|
||||
t.fromSource() and
|
||||
not t instanceof AnonymousClass and
|
||||
not t.isCompilerGenerated() and
|
||||
not t.getName().substring(0, 1).toUpperCase() = t.getName().substring(0, 1)
|
||||
select t, "Class and interface names should start in uppercase."
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The query `java/misnamed-type` is now enabled for Kotlin.
|
|
@ -0,0 +1 @@
|
|||
| Test.kt:12:1:12:13 | aaaa | Class and interface names should start in uppercase. |
|
Загрузка…
Ссылка в новой задаче