False positive java/local-variable-is-never-read for Kotlin data object-generated equals temporaries
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
The false positive comes from the java/local-variable-is-never-read query (UnreadLocal.ql) reporting compiler-generated other_with_cast locals in zero-property Kotlin data object equals methods. Start by reproducing with the reduced LoadState source in a CodeQL database, then check how the query and the Kotlin extractor model generated locals. Done means these temporaries are excluded while genuinely unused user locals are still reported.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description of the false positive
java/local-variable-is-never-read reports Kotlin compiler-generated other_with_cast temporaries for zero-property data object declarations. The diagnostic is attached to the Kotlin file without a source region; GitHub displays line1. The application does not declare these variables or an equals implementation.
Environment actually observed
- CodeQL CLI 2.27.3, as selected by
github/codeql-actionv4.39.1 at9b3254085494b55a0f7c4c2b3d2d52cc712ce370. - Kotlin 2.4.21, JVM 27, Java/Kotlin manual build,
security-extendedwith the remote threat model. - The observations below come from a completed Android/Compose analysis and its SARIF, not an independently rerun CodeQL database for the reduced source below.
Reduced source
private sealed interface LoadState {
data object Loading : LoadState
data object Failed : LoadState
}
fun main() {
val states: List<LoadState> = listOf(LoadState.Loading, LoadState.Failed)
states.forEach { println(it) }
}
Observed SARIF diagnostic
Rule: java/local-variable-is-never-read
Level: note
Variable 'Loading tmp0_other_with_cast' is never read.
Variable 'Failed tmp0_other_with_cast' is never read.
Physical location: Kotlin source artifact, without a source region
The same analysis reports the same temporary-name pattern for two other zero-property data objects in another Kotlin source file.
Compiler and bytecode evidence
Kotlinv2.4.21 DataClassMembersGenerator.kt creates other_with_cast before iterating through properties. Reads occur within that loop. For a zero-property data object, the compiler-generated local therefore has no property read.
The Kotlin data-object contract specifies generated equals/hashCode implementations and prohibits supplying custom implementations. javap -p -c -l -v on both affected compiled classes confirms that equals(Object) exists despite being absent from application source; its LocalVariableTable contains only this and other after JVM lowering. No application declaration named tmp0_other_with_cast exists.
Expected behavior
Exclude this generated data-object equality temporary from the unread-source-local diagnostic, while retaining detection of genuinely unused user declarations.
Version-check limit
I did not execute a new CodeQL analysis with 2.27.4. Its official query is byte-identical to2.27.3 (UnreadLocal.ql SHA256 aae0d6fd7a2df5291352a3b2597cdff9e92a41f264e413801bb57ffbee071894), and the official Kotlin-extractor source subtree is identical (17c4961985b50180674d18fb4b12d64d3fd36b23). This is not a claim that an upgrade fixes or reproduces the issue; it records the inspected source boundaries.
The application has not been rewritten and the query has not been suppressed. The public example above contains no application-specific code, credentials or private repository references.
- Lenguaje dominante
- CodeQL
- Estrellas
- 10.3k
- Forks
- 2.1k
- Merge medio
- 1 d 22 h
- PR fusionados (30 d)
- 126
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/codeql
-
JavaScript externs model StorageEvent() with no type argumentPosiblemente ocupada @asgerf la tomó hace 14 días. Abiertofalse-positive javascript
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
github/codeql#22632 · 3 comentarios · 1 reacción · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
Add AlertSuppression.ql for Rust (inline // codeql[...] suppression)Posiblemente ocupada @cnuss la tomó hace 215 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
github/codeql#21637 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
false-positive
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
github/codeql#21076 · 3 comentarios · 3 reacciones ·
Los mantenedores suelen responder en 1 día
-
General issueAbiertoquestion
Dificultad 5/5 Más de una semana Aptitud para principiantes 5/100
Los mantenedores suelen responder en 1 día
-
java/unused-reference-type and java/unused-container: silenced by any annotation, even an empty oneAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de github/codeql
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
area:parser bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
jmbarzee/temporal-architect#290 ·
Los mantenedores suelen responder en 1 día
-
[bug] A prompt queued during a run is assessed without its textPosiblemente ocupada @jwiegley la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
DevMortimer/pi-warden#211 ·
Los mantenedores suelen responder en 1 día
-
check-relative-paths reports links to existing directories as missingPosiblemente ocupada @reidbaker-agent la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
google/skills_lint.dart#202 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
HorusGoul/trizum#559 · 1 comentario ·
Los mantenedores suelen responder en 1 día