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

Commit 262448f6 authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

Support lint suppression

Fix reported scope of SysUI's linters so that @SuppressWarnings
annotation can be used when necessary.

Test: SystemUILintCheckerTest
Bug: 238457012
Bug: 258902612
Change-Id: Ie6650ae1a33e5401ab6ceb521b3d02be93641477
parent 82e7167b
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -59,9 +59,9 @@ class BindServiceOnMainThreadDetector : Detector(), SourceCodeScanner {
                    !hasWorkerThreadAnnotation(context, node.getParentOfType(UClass::class.java))
            ) {
                context.report(
                    ISSUE,
                    method,
                    context.getLocation(node),
                    issue = ISSUE,
                    location = context.getLocation(node),
                    message =
                        "This method should be annotated with `@WorkerThread` because " +
                            "it calls ${method.name}",
                )
+3 −4
Original line number Diff line number Diff line
@@ -52,10 +52,9 @@ class BroadcastSentViaContextDetector : Detector(), SourceCodeScanner {
        val evaluator = context.evaluator
        if (evaluator.isMemberInSubClassOf(method, CLASS_CONTEXT)) {
            context.report(
                    ISSUE,
                    method,
                    context.getNameLocation(node),
                    "`Context.${method.name}()` should be replaced with " +
                    issue = ISSUE,
                    location = context.getNameLocation(node),
                    message = "`Context.${method.name}()` should be replaced with " +
                    "`BroadcastSender.${method.name}()`"
            )
        }
+3 −4
Original line number Diff line number Diff line
@@ -38,10 +38,9 @@ class NonInjectedMainThreadDetector : Detector(), SourceCodeScanner {
    override fun visitMethodCall(context: JavaContext, node: UCallExpression, method: PsiMethod) {
        if (context.evaluator.isMemberInSubClassOf(method, CLASS_CONTEXT)) {
            context.report(
                ISSUE,
                method,
                context.getNameLocation(node),
                "Replace with injected `@Main Executor`."
                issue = ISSUE,
                location = context.getNameLocation(node),
                message = "Replace with injected `@Main Executor`."
            )
        }
    }
+9 −9
Original line number Diff line number Diff line
@@ -44,9 +44,9 @@ class NonInjectedServiceDetector : Detector(), SourceCodeScanner {
                method.containingClass?.qualifiedName == CLASS_CONTEXT
        ) {
            context.report(
                ISSUE,
                method,
                context.getNameLocation(node),
                issue = ISSUE,
                location = context.getNameLocation(node),
                message =
                    "Use `@Inject` to get system-level service handles instead of " +
                        "`Context.getSystemService()`"
            )
@@ -56,9 +56,9 @@ class NonInjectedServiceDetector : Detector(), SourceCodeScanner {
                method.containingClass?.qualifiedName == "android.accounts.AccountManager"
        ) {
            context.report(
                ISSUE,
                method,
                context.getNameLocation(node),
                issue = ISSUE,
                location = context.getNameLocation(node),
                message =
                    "Replace `AccountManager.get()` with an injected instance of `AccountManager`"
            )
        }
+4 −4
Original line number Diff line number Diff line
@@ -38,10 +38,10 @@ class RegisterReceiverViaContextDetector : Detector(), SourceCodeScanner {
    override fun visitMethodCall(context: JavaContext, node: UCallExpression, method: PsiMethod) {
        if (context.evaluator.isMemberInSubClassOf(method, CLASS_CONTEXT)) {
            context.report(
                    ISSUE,
                    method,
                    context.getNameLocation(node),
                    "Register `BroadcastReceiver` using `BroadcastDispatcher` instead of `Context`"
                    issue = ISSUE,
                    location = context.getNameLocation(node),
                    message = "Register `BroadcastReceiver` using `BroadcastDispatcher` instead " +
                    "of `Context`"
            )
        }
    }
Loading