ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.53k stars 2.21k forks source link

Lint: enable "ThrowableNotAtBeginning" #17248

Open david-allison opened 1 day ago

david-allison commented 1 day ago

This rule should be working and fail on the following code (as it does inside the IDE):

https://github.com/ankidroid/Anki-Android/blob/75d9e56f8d593f0d4e36e02ad64fe477f43f7d2f/AnkiDroid/src/main/java/com/ichi2/compat/CompatV24.kt#L51

Image

https://googlesamples.github.io/android-custom-lint-rules/checks/ThrowableNotAtBeginning.md.html

But it's not, and the following patch doesn't enable it:

Subject: [PATCH] 
---
Index: lint.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lint.gradle b/lint.gradle
--- a/lint.gradle   (revision cf1e97563e1cf459a45ec17f8081bb51f1f5b4e4)
+++ b/lint.gradle   (date 1728771812056)
@@ -12,6 +12,7 @@
         textReport true
         warningsAsErrors true

+        enable += "ThrowableNotAtBeginning"
         if (System.getenv("CI") == "true") {
             // 14853: we want this to appear in the IDE, but it adds noise to CI
             disable += "WrongThread"
Index: lint-release.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lint-release.xml b/lint-release.xml
--- a/lint-release.xml  (revision cf1e97563e1cf459a45ec17f8081bb51f1f5b4e4)
+++ b/lint-release.xml  (date 1728771563394)
@@ -163,6 +163,9 @@

     <issue id="MonochromeLauncherIcon" severity="fatal" />

+    <!-- Timber rules -->
+    <issue id="ThrowableNotAtBeginning" severity="fatal" />
+
     <!-- this is temporary - needed to work with android gradle plugin 8.1 -->
     <!-- ideally commits to fix this are completed, such as in https://github.com/ankidroid/Anki-Android/pull/14158 -->
     <issue id="UnspecifiedRegisterReceiverFlag" severity="ignore" />
Giyutomioka-SS commented 1 day ago

Looking into this.