Kleine robuustheids- en stijlpunten in de Kotlin-patches #100

Closed
opened 2026-10-14 13:47:05 +02:00 by midas · 1 comment
Owner

Severity: low · Categorie: code-quality · Effort: S

Probleem

Gebundelde nits:

  • MiniJson: een letterlijke BOM in de bron (gebruik ). readNumber accepteert een losse -. Een foute \u gooit een NumberFormatException in plaats van een PatchException. Een is Number-tak is overbodig.
  • De Firebase-patch en -fingerprint hebben geen KDoc.
  • Edition Disable tracking zoekt het isReleaseBuild-veld via toString().contains(...). Match op FieldReference.name.
  • Kubus:
    • drie vals heten gelderlander*;
    • een dubbele dependsOn in 5 patches;
    • featureFlagOverridePatch heeft geen compatibleWith;
    • een overbodige toList();
    • commentaar dat obfuscated namen noemt.
  • Edition Markdown voegt in na addShareAction zonder te controleren of die V teruggeeft en of er precies één match is.
  • Videoland:
    • Hide ads neemt de eerste sget-object van het eigen type;
    • Force HD en Log video assets voegen na een move-result in met gewone addInstructions in plaats van addInstructionsAtControlFlowLabel;
    • isSetVisibility is te ruim.

Waar

Bewijs

U1-6 (patches/src/main/kotlin/nl/midasvo/patches/shared/util/MiniJson.kt)

MiniJson:24 text.removePrefix(<literal invisible BOM char>)
MiniJson:212 sb.append(text.substring(pos, pos + 4).toInt(16).toChar())

U2-2 (patches/src/main/kotlin/nl/midasvo/patches/edition/tracking/DisableTrackingPatch.kt)

inst.opcode == Opcode.IGET_BOOLEAN && (inst as? ReferenceInstruction)?.reference?.toString()?.contains("isReleaseBuild") == true

U3-4 (patches/src/main/kotlin/nl/midasvo/patches/kubus/forcedupdate/DisableForcedUpdatePatch.kt)

val gelderlanderDisableForcedUpdatePatch = bytecodePatch(...)   // package kubus.forcedupdate
dependsOn(midasSettingsPatch)
dependsOn(articleComponentFilterPatch)   // split over two calls in 5 patches
val returns = getSections.instructions.withIndex().filter{...}.map{...}.toList()

U4-5 (patches/src/main/kotlin/nl/midasvo/patches/edition/markdown/CopyArticleMarkdownPatch.kt)

val addShareIndex = fingerprint.instructionMatches.first().index
...
method.addInstruction(addShareIndex + 1, "invoke-static/range {v$listRegister .. v$listRegister}, ...addMarkdownAction(Ljava/util/List;)V")

U5-5 (patches/src/main/kotlin/nl/midasvo/patches/videoland/ads/HideAdsPatch.kt)

addInstructions(index + 2, ...)  // ForceHd, directly after move-result

Impact

Klein per punt. Samen betekenen ze meer kans op een stille fout na een update.

Voorstel

Pak ze op in één opruim-commit. De twee bytecode-punten (addInstructionsAtControlFlowLabel, de check op V en één match) eerst.

Acceptatiecriteria

  • Alle genoemde punten zijn opgelost of bewust afgewezen met een reden in dit issue.
  • Applied: op een Edition-, Kubus- en Videoland-APK.

Code review @ 33e02db (2026-10-14) · findings: U1-6, U2-2, U3-4, U4-5, U5-5

**Severity:** low · **Categorie:** code-quality · **Effort:** S ## Probleem Gebundelde nits: - `MiniJson`: een letterlijke BOM in de bron (gebruik ``). `readNumber` accepteert een losse `-`. Een foute `\u` gooit een `NumberFormatException` in plaats van een `PatchException`. Een `is Number`-tak is overbodig. - De Firebase-patch en -fingerprint hebben geen KDoc. - Edition Disable tracking zoekt het `isReleaseBuild`-veld via `toString().contains(...)`. Match op `FieldReference.name`. - Kubus: - drie vals heten `gelderlander*`; - een dubbele `dependsOn` in 5 patches; - `featureFlagOverridePatch` heeft geen `compatibleWith`; - een overbodige `toList()`; - commentaar dat obfuscated namen noemt. - Edition Markdown voegt in na `addShareAction` zonder te controleren of die `V` teruggeeft en of er precies één match is. - Videoland: - Hide ads neemt de eerste `sget-object` van het eigen type; - Force HD en Log video assets voegen na een `move-result` in met gewone `addInstructions` in plaats van `addInstructionsAtControlFlowLabel`; - `isSetVisibility` is te ruim. ## Waar - [`patches/src/main/kotlin/nl/midasvo/patches/shared/util/MiniJson.kt#L24,37-38,135-139,211-212`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/shared/util/MiniJson.kt#L24) - [`patches/src/main/kotlin/nl/midasvo/patches/firebase/DisableFirebaseInAppMessagingPatch.kt#L10-12`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/firebase/DisableFirebaseInAppMessagingPatch.kt#L10-L12) - [`patches/src/main/kotlin/nl/midasvo/patches/firebase/Fingerprints.kt#L6-14`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/firebase/Fingerprints.kt#L6-L14) - [`extensions/extension/src/main/java/nl/midasvo/extension/settings/MidasSettingsActivity.java#L207-223`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/extensions/extension/src/main/java/nl/midasvo/extension/settings/MidasSettingsActivity.java#L207-L223) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/tracking/DisableTrackingPatch.kt#L78-90`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/tracking/DisableTrackingPatch.kt#L78-L90) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/forcedupdate/DisableForcedUpdatePatch.kt#L9`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/forcedupdate/DisableForcedUpdatePatch.kt#L9) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/reviewprompts/HideReviewPromptsPatch.kt#L21`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/reviewprompts/HideReviewPromptsPatch.kt#L21) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/surveys/HideSurveysPatch.kt#L13,21-22`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/surveys/HideSurveysPatch.kt#L13) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/hidesharebuttons/HideShareButtonsPatch.kt#L22-23`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/hidesharebuttons/HideShareButtonsPatch.kt#L22-L23) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/featureflags/FeatureFlagOverridePatch.kt#L78-81`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/featureflags/FeatureFlagOverridePatch.kt#L78-L81) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/MidasSettingsPatch.kt#L52-56`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/MidasSettingsPatch.kt#L52-L56) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/tracking/KubusManifestCleanupPatch.kt#L14-44`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/tracking/KubusManifestCleanupPatch.kt#L14-L44) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/ads/HideAdsPatch.kt#L33-35`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/ads/HideAdsPatch.kt#L33-L35) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/markdown/CopyArticleMarkdownPatch.kt#L41-53`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/markdown/CopyArticleMarkdownPatch.kt#L41-L53) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/markdown/Fingerprints.kt#L11-21`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/markdown/Fingerprints.kt#L11-L21) - [`patches/src/main/kotlin/nl/midasvo/patches/videoland/ads/HideAdsPatch.kt#L37-41`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/videoland/ads/HideAdsPatch.kt#L37-L41) - [`patches/src/main/kotlin/nl/midasvo/patches/videoland/quality/ForceHdPatch.kt#L58-68`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/videoland/quality/ForceHdPatch.kt#L58-L68) - [`patches/src/main/kotlin/nl/midasvo/patches/videoland/assets/LogVideoAssetsPatch.kt#L81-84`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/videoland/assets/LogVideoAssetsPatch.kt#L81-L84) - [`patches/src/main/kotlin/nl/midasvo/patches/videoland/skipintro/AutoSkipIntroPatch.kt#L102-108, 122-134`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/videoland/skipintro/AutoSkipIntroPatch.kt#L102-L108) ## Bewijs _U1-6 (patches/src/main/kotlin/nl/midasvo/patches/shared/util/MiniJson.kt)_ ```kotlin MiniJson:24 text.removePrefix(<literal invisible BOM char>) MiniJson:212 sb.append(text.substring(pos, pos + 4).toInt(16).toChar()) ``` _U2-2 (patches/src/main/kotlin/nl/midasvo/patches/edition/tracking/DisableTrackingPatch.kt)_ ```kotlin inst.opcode == Opcode.IGET_BOOLEAN && (inst as? ReferenceInstruction)?.reference?.toString()?.contains("isReleaseBuild") == true ``` _U3-4 (patches/src/main/kotlin/nl/midasvo/patches/kubus/forcedupdate/DisableForcedUpdatePatch.kt)_ ```kotlin val gelderlanderDisableForcedUpdatePatch = bytecodePatch(...) // package kubus.forcedupdate dependsOn(midasSettingsPatch) dependsOn(articleComponentFilterPatch) // split over two calls in 5 patches val returns = getSections.instructions.withIndex().filter{...}.map{...}.toList() ``` _U4-5 (patches/src/main/kotlin/nl/midasvo/patches/edition/markdown/CopyArticleMarkdownPatch.kt)_ ```kotlin val addShareIndex = fingerprint.instructionMatches.first().index ... method.addInstruction(addShareIndex + 1, "invoke-static/range {v$listRegister .. v$listRegister}, ...addMarkdownAction(Ljava/util/List;)V") ``` _U5-5 (patches/src/main/kotlin/nl/midasvo/patches/videoland/ads/HideAdsPatch.kt)_ ```kotlin addInstructions(index + 2, ...) // ForceHd, directly after move-result ``` ## Impact Klein per punt. Samen betekenen ze meer kans op een stille fout na een update. ## Voorstel Pak ze op in één opruim-commit. De twee bytecode-punten (`addInstructionsAtControlFlowLabel`, de check op `V` en één match) eerst. ## Acceptatiecriteria - [ ] Alle genoemde punten zijn opgelost of bewust afgewezen met een reden in dit issue. - [ ] `Applied:` op een Edition-, Kubus- en Videoland-APK. _Code review @ 33e02db (2026-10-14) · findings: U1-6, U2-2, U3-4, U4-5, U5-5_
Author
Owner

Opgelost in PR #120, gemerged in dev en uitgebracht in v1.10.0 (onderdeel van #105).

Opgelost in PR #120, gemerged in dev en uitgebracht in v1.10.0 (onderdeel van #105).
midas closed this issue 2026-10-17 21:22:44 +02:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
midas/midas-patches#100
No description provided.