Using: SonarQube™ - Enterprise Edition - Version 9.9 (build 65466)
Language: Kotlin
Rule: S6313 (Classes extending “ViewModel” should not expose suspending functions).
Expectation:
Public suspend method in ViewModels which are annotated with @VisibleForTesting should not get flagged by SonarQube.
Example:
class DetailsViewModel : ViewModel() {
@VisibleForTesting
suspend fun getName(): String {
TODO()
}
}
getName() method which is explicitly annotated with @VisibleForTesting should not be flagged by rule S6313 (Classes extending “ViewModel” should not expose suspending functions) as the access modifier has been intentionally relaxed to accommodate for testing.
PS: There seem to be many other similar @VisibleForTesting annotations which are also needed to be considered, more info about those annotations have been documented here: Rules S2039 and S2156 should recognize `@VisibleForTesting` other than Guava's
I’m particularly interested in androidx.annotation.VisibleForTesting