Class ExposeAsStateFlowDetector

  • All Implemented Interfaces:
    com.android.tools.lint.detector.api.Detector.UastScanner , com.android.tools.lint.detector.api.FileScanner , com.android.tools.lint.detector.api.SourceCodeScanner

    
    public final class ExposeAsStateFlowDetector
    extends Detector implements Detector.UastScanner
                        

    Ensures that MutableStateFlow is not exposed directly as StateFlow.

    Problematic: private val _state = MutableStateFlow(initial) val state: StateFlow<State> = _state // can be downcast to MutableStateFlow and mutated val state: StateFlow<State> get() = _state

    Correct: private val _state = MutableStateFlow(initial) val state: StateFlow<State> = _state.asStateFlow() val state: StateFlow<State> get() = _state.asStateFlow()

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      List<Class<out UElement>> getApplicableUastTypes()
      UElementHandler createUastHandler(JavaContext context)
      • Methods inherited from class com.android.tools.lint.detector.api.Detector

        afterCheckEachProject, afterCheckFile, afterCheckLibraryProject, afterCheckProject, afterCheckRootProject, analyzeCallGraph, applicableAnnotations, applicableSuperClasses, appliesTo, appliesTo, appliesToResourceRefs, beforeCheckEachProject, beforeCheckFile, beforeCheckLibraryProject, beforeCheckProject, beforeCheckRootProject, checkBinaryResource, checkCall, checkClass, checkClass, checkDslPropertyAssignment, checkDslPropertyAssignment, checkFolder, checkInstruction, checkMergedProject, checkMethodCall, checkMethodCall, checkPartialResults, createPsiVisitor, filterIncident, getApplicableAsmNodeTypes, getApplicableAttributes, getApplicableCallNames, getApplicableCallOwners, getApplicableConstructorTypes, getApplicableElements, getApplicableFiles, getApplicableMethodNames, getApplicablePsiTypes, getApplicableReferenceNames, getCustomVisitor, getSpeed, inheritAnnotation, isApplicableAnnotationUsage, isCallGraphRequired, run, sameMessage, visitAnnotationUsage, visitAnnotationUsage, visitAnnotationUsage, visitAnnotationUsage, visitAttribute, visitBuildScript, visitBuildScript, visitClass, visitClass, visitConstructor, visitConstructor, visitDocument, visitElement, visitElementAfter, visitMethod, visitMethod, visitMethodCall, visitReference, visitReference, visitResourceReference, visitResourceReference
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait