mirror of
https://github.com/github/codeql.git
synced 2026-07-13 23:38:15 +02:00
The Kotlin internal queries job (odasa-buildutils/kotlin_internal_queries)
flagged two code-quality issues introduced by the K1/K2 convergence helpers.
Both are pure source refactors with no effect on extractor output, so no
.expected files change.
1. possiblyThrowingExpressions.ql / notNullExpr: extractVariableExpr used a
`!!` not-null assertion (`currentDesugarTemp!!.second`) guarded by a
separate `currentDesugarTemp?.first === v` check. The extractor must avoid
`!!` (it can throw and lose a source file). Bind `currentDesugarTemp` to a
local val and null-check it in the `when`, which smart-casts the subsequent
`.first`/`.second` accesses. Behaviour is identical.
2. separated_overloads.ql: two overload groups were split by newly added
helpers, which the lint reports as harder-to-read code:
- `getPsiBasedConstructorBodyLocation` sat between the two
`extractBlockBody` overloads; moved it below both.
- the destructuring helpers (`destructuringContainerK1NameRegex`,
`isDestructuringContainerVariable`,
`getPsiBasedDestructuringContainerLocation`) sat between the
`getPsiBasedLocation(IrVariable)` and `getPsiBasedLocation(IrProperty)`
overloads; moved them below the third overload so all three
`getPsiBasedLocation` overloads are adjacent.
Verified the standalone extractor still compiles under both K2 (2.4.0) and
K1 (1.9.20-Beta).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>