Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d16e1002 authored by Thiébaud Weksteen's avatar Thiébaud Weksteen
Browse files

Enable EnforcePermission linters for test sources

Increase the scope of the linters to be executed even for tests.

Bug: 270596429
Test: m lint-check
Test: remove annotation and helper call in EnforcePermissionTestHelper;
      m lint-check; the two errors are raised.
Change-Id: Ic8348b668664747b8a1f3c56359cdf9c02132f59
parent d1c98cc7
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ import org.jetbrains.uast.UElement
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.toUElement

import java.util.EnumSet

/**
 * Lint Detector that ensures that any method overriding a method annotated
 * with @EnforcePermission is also annotated with the exact same annotation.
@@ -206,7 +208,7 @@ class EnforcePermissionDetector : Detector(), SourceCodeScanner {
            severity = Severity.ERROR,
            implementation = Implementation(
                    EnforcePermissionDetector::class.java,
                    Scope.JAVA_FILE_SCOPE
                    EnumSet.of(Scope.JAVA_FILE, Scope.TEST_SOURCES)
            )
        )

@@ -219,7 +221,7 @@ class EnforcePermissionDetector : Detector(), SourceCodeScanner {
            severity = Severity.ERROR,
            implementation = Implementation(
                    EnforcePermissionDetector::class.java,
                    Scope.JAVA_FILE_SCOPE
                    EnumSet.of(Scope.JAVA_FILE, Scope.TEST_SOURCES)
            )
        )
    }
+4 −2
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import org.jetbrains.uast.UExpression
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.skipParenthesizedExprDown

import java.util.EnumSet

class EnforcePermissionHelperDetector : Detector(), SourceCodeScanner {
    override fun getApplicableUastTypes(): List<Class<out UElement?>> =
            listOf(UMethod::class.java)
@@ -117,7 +119,7 @@ class EnforcePermissionHelperDetector : Detector(), SourceCodeScanner {
                severity = Severity.ERROR,
                implementation = Implementation(
                        EnforcePermissionHelperDetector::class.java,
                        Scope.JAVA_FILE_SCOPE
                        EnumSet.of(Scope.JAVA_FILE, Scope.TEST_SOURCES)
                )
        )

@@ -130,7 +132,7 @@ class EnforcePermissionHelperDetector : Detector(), SourceCodeScanner {
                severity = Severity.ERROR,
                implementation = Implementation(
                        EnforcePermissionDetector::class.java,
                        Scope.JAVA_FILE_SCOPE
                        EnumSet.of(Scope.JAVA_FILE, Scope.TEST_SOURCES)
                )
        )