speech: detekt clean (103 tests)
- Commit
7fec8636af585f105b3fa970f972760269bf83f3- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-14 23:11 UTC (21 days ago)
- Parents
bd2c735
Fix all detekt findings in speech by fixing code, not config (detekt.yml untouched, no baselines added): - UndocumentedPublicClass: KDoc for 5 types. - UnusedParameter/FunctionOnlyReturningConstant in the Robolectric AudioRecord shadow: signatures must mirror the framework API, so narrow @Suppress with justification; the fixed buffer size is now MIN_BUFFER_SIZE. - DestructuringDeclarationWithTooManyEntries: the language test now reads properties directly. Verified: ./gradlew :speech:detekt :speech:testDevUnitTest :speech:lint --max-workers=32 all pass (103 unit tests).
Diff
speech/src/main/java/com/vayunmathur/speech/MainActivity.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt b/speech/src/main/java/com/vayunmathur/speech/MainActivity.ktindex e681cc2755..b4d0ab7663 100644--- a/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt+++ b/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt@@ -59,6 +59,7 @@ import com.vayunmathur.speech.util.TtsVoiceUiState import com.vayunmathur.speech.util.WhisperModel import java.util.Locale +/** Main Activity: a ma activity implementation for main activity. */ class MainActivity : MaActivity() { @Composable override fun Content() {
speech/src/main/java/com/vayunmathur/speech/domain/SupertonicVoices.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/domain/SupertonicVoices.kt b/speech/src/main/java/com/vayunmathur/speech/domain/SupertonicVoices.ktindex 0c37dbcc80..d105374e2a 100644--- a/speech/src/main/java/com/vayunmathur/speech/domain/SupertonicVoices.kt+++ b/speech/src/main/java/com/vayunmathur/speech/domain/SupertonicVoices.kt@@ -47,6 +47,7 @@ data class SupertonicLanguage( val nativeName: String, ) +/** Singleton holding supertonic voices state and operations. */ object SupertonicVoices { /** * All 31 languages, English first because it is the default and the rest alphabetically by
speech/src/main/java/com/vayunmathur/speech/service/WhisperRecognitionService.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/service/WhisperRecognitionService.kt b/speech/src/main/java/com/vayunmathur/speech/service/WhisperRecognitionService.ktindex e184b97a83..ca53cd11e5 100644--- a/speech/src/main/java/com/vayunmathur/speech/service/WhisperRecognitionService.kt+++ b/speech/src/main/java/com/vayunmathur/speech/service/WhisperRecognitionService.kt@@ -330,6 +330,7 @@ open class WhisperRecognitionService : RecognitionService() { private fun rmsToDb(rms: Double): Float = (DB_SCALE * log10(rms + RMS_FLOOR)).toFloat().coerceIn(MIN_DB, MAX_DB) / DB_DIVISOR + /** Shared constants and helpers for WhisperRecognitionService. */ companion object { private const val TAG = "WhisperRecognition" private const val SAMPLE_RATE = 16000
speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.kt b/speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.ktindex 8619e3c9b4..3441026a59 100644--- a/speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.kt+++ b/speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.kt@@ -61,6 +61,7 @@ interface SpeechSetupActions { /** Re-read the device state after a step completes. */ fun refresh() {} + /** Shared constants and helpers for SpeechSetupActions. */ companion object { val Noop: SpeechSetupActions = object : SpeechSetupActions {} }
speech/src/main/java/com/vayunmathur/speech/util/WhisperTokenizer.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/util/WhisperTokenizer.kt b/speech/src/main/java/com/vayunmathur/speech/util/WhisperTokenizer.ktindex 8771ca1142..1af0cca0b0 100644--- a/speech/src/main/java/com/vayunmathur/speech/util/WhisperTokenizer.kt+++ b/speech/src/main/java/com/vayunmathur/speech/util/WhisperTokenizer.kt@@ -31,6 +31,7 @@ class WhisperTokenizer private constructor(private val idToToken: Array<String?> return bytes.toString("UTF-8") } + /** Shared constants and helpers for WhisperTokenizer. */ companion object { /** Ids at or above this are special/timestamp tokens with no text form. */ const val FIRST_SPECIAL_ID = 50257
speech/src/test/java/com/vayunmathur/speech/domain/SupertonicVoicesTest.kt
diff --git a/speech/src/test/java/com/vayunmathur/speech/domain/SupertonicVoicesTest.kt b/speech/src/test/java/com/vayunmathur/speech/domain/SupertonicVoicesTest.ktindex 6b6b7b92fe..f6f2775cae 100644--- a/speech/src/test/java/com/vayunmathur/speech/domain/SupertonicVoicesTest.kt+++ b/speech/src/test/java/com/vayunmathur/speech/domain/SupertonicVoicesTest.kt@@ -180,8 +180,7 @@ class SupertonicVoicesTest { assertEquals("en-US", en.bcp47) assertEquals("eng", en.iso3) assertEquals("USA", en.iso3Country)- val (code, bcp47, iso3, country, english, native) = en assertEquals(listOf("en", "en-US", "eng", "USA", "English", "English"),- listOf(code, bcp47, iso3, country, english, native))+ listOf(en.code, en.bcp47, en.iso3, en.iso3Country, en.englishName, en.nativeName)) } }
speech/src/test/java/com/vayunmathur/speech/testing/FakeAudioRecordShadow.kt
diff --git a/speech/src/test/java/com/vayunmathur/speech/testing/FakeAudioRecordShadow.kt b/speech/src/test/java/com/vayunmathur/speech/testing/FakeAudioRecordShadow.ktindex 3dad2320c7..9c67613bc8 100644--- a/speech/src/test/java/com/vayunmathur/speech/testing/FakeAudioRecordShadow.kt+++ b/speech/src/test/java/com/vayunmathur/speech/testing/FakeAudioRecordShadow.kt@@ -15,6 +15,8 @@ import org.robolectric.annotation.Implements @Implements(AudioRecord::class) class FakeAudioRecordShadow { + // Signature must mirror AudioRecord's constructor for Robolectric; the values are not needed.+ @Suppress("UnusedParameter") @Implementation fun __constructor__(audioSource: Int, sampleRateInHz: Int, channelConfig: Int, audioFormat: Int, bufferSizeInBytes: Int) = Unit @@ -68,8 +70,13 @@ class FakeAudioRecordShadow { fun releaseBlock() { blockRelease?.countDown() } + // Signature must mirror AudioRecord.getMinBufferSize for Robolectric; args are not needed.+ @Suppress("UnusedParameter") @Implementation @JvmStatic- fun getMinBufferSize(sampleRateInHz: Int, channelConfig: Int, audioFormat: Int): Int = 3200+ fun getMinBufferSize(sampleRateInHz: Int, channelConfig: Int, audioFormat: Int): Int = MIN_BUFFER_SIZE++ /** Fixed minimum buffer the fake reports, in bytes. */+ const val MIN_BUFFER_SIZE = 3200 } }