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

Commit c08b5ea0 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "Unify errorprone enforced rules" into main

parents 1faa169b 2256094a
Loading
Loading
Loading
Loading
+110 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ filegroup {
//    this default contains. This also means that if you add a new option that isn't
//    documented by the name of this default, rename it.
//
//  - Try avoiding adding option that would not fit "future" targets, for exemple dependencies,
//  - Try avoiding adding option that would not fit "future" targets, for example dependencies,
//    even if every modules of Bluetooth depends on a specific dependency it should be left out
//    from this default to not push it for future targets that might not need it.
cc_defaults {
@@ -73,3 +73,112 @@ cc_defaults {
    c_std: "c99",
    cpp_std: "c++20",
}

java_defaults {
    name: "bluetooth_errorprone_rules",
    errorprone: {
        enabled: true,
        javacflags: [
            "-Xep:AlmostJavadoc:ERROR",
            "-Xep:AlreadyChecked:ERROR",
            "-Xep:BadImport:ERROR",
            "-Xep:CatchAndPrintStackTrace:ERROR",
            "-Xep:CatchFail:ERROR",
            "-Xep:CheckReturnValue:ERROR",
            "-Xep:ClassCanBeStatic:ERROR",
            "-Xep:DateFormatConstant:ERROR",
            "-Xep:DirectInvocationOnMock:ERROR",
            "-Xep:EmptyBlockTag:ERROR",
            "-Xep:EmptyCatch:ERROR",
            "-Xep:EqualsGetClass:ERROR",
            "-Xep:EqualsHashCode:ERROR",
            "-Xep:EqualsIncompatibleType:ERROR",
            "-Xep:FallThrough:ERROR",
            "-Xep:Finalize:ERROR",
            "-Xep:FutureReturnValueIgnored:ERROR",
            "-Xep:GuardedBy:ERROR",
            "-Xep:HidingField:ERROR",
            "-Xep:InconsistentHashCode:ERROR",
            "-Xep:InlineFormatString:ERROR",
            "-Xep:InlineMeInliner:ERROR",
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidInlineTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:JavaUtilDate:ERROR",
            "-Xep:JdkObsolete:ERROR",
            "-Xep:LockOnNonEnclosingClassLiteral:ERROR",
            "-Xep:LongFloatConversion:ERROR",
            "-Xep:LoopOverCharArray:ERROR",
            "-Xep:MissingCasesInEnumSwitch:ERROR",
            "-Xep:MixedMutabilityReturnType:ERROR",
            "-Xep:MockNotUsedInProduction:ERROR",
            "-Xep:ModifiedButNotUsed:ERROR",
            "-Xep:ModifyCollectionInEnhancedForLoop:ERROR",
            "-Xep:NarrowCalculation:ERROR",
            "-Xep:NarrowingCompoundAssignment:ERROR",
            "-Xep:NonApiType:ERROR",
            "-Xep:NonAtomicVolatileUpdate:ERROR",
            "-Xep:NonCanonicalType:ERROR",
            "-Xep:NotJavadoc:ERROR",
            "-Xep:ObjectEqualsForPrimitives:ERROR",
            "-Xep:OperatorPrecedence:ERROR",
            "-Xep:ReferenceEquality:ERROR",
            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
            "-Xep:StaticAssignmentInConstructor:ERROR",
            "-Xep:StaticGuardedByInstance:ERROR",
            "-Xep:StringCaseLocaleUsage:ERROR",
            "-Xep:StringCharset:ERROR",
            "-Xep:SynchronizeOnNonFinalField:ERROR",
            "-Xep:ToStringReturnsNull:ERROR",
            "-Xep:TruthConstantAsserts:ERROR",
            "-Xep:TruthIncompatibleType:ERROR",
            "-Xep:UndefinedEquals:ERROR",
            "-Xep:UnnecessaryAssignment:ERROR",
            "-Xep:UnnecessaryAsync:ERROR",
            "-Xep:UnnecessaryStringBuilder:ERROR",
            "-Xep:UnrecognisedJavadocTag:ERROR",
            "-Xep:UnusedMethod:ERROR",
            "-Xep:UnusedNestedClass:ERROR",
            "-Xep:UnusedVariable:ERROR",
            "-Xep:WaitNotInLoop:ERROR",
            "-Xep:WakelockReleasedDangerously:ERROR",

            // Exclude generated files
            "-XepExcludedPaths:.*/srcjars/.*",

            // The @InlineMe annotation is not available
            // "-Xep:InlineMeSuggester:OFF",
        ],
    },
}

java_defaults {
    name: "bluetooth_framework_errorprone_rules",
    defaults: ["bluetooth_errorprone_rules"],
    plugins: [
        "error_prone_android_framework",
    ],
    errorprone: {
        javacflags: [
            "-Xep:AndroidFrameworkBinderIdentity:ERROR",
            "-Xep:AndroidFrameworkBluetoothPermission:ERROR",
            "-Xep:AndroidFrameworkCompatChange:ERROR",
            "-Xep:AndroidFrameworkEfficientParcelable:ERROR",
            "-Xep:AndroidFrameworkEfficientStrings:ERROR",
            "-Xep:AndroidFrameworkPendingIntentMutability:ERROR",
            "-Xep:AndroidFrameworkRequiresPermission:ERROR",
            "-Xep:AndroidFrameworkRethrowFromSystem:ERROR",
            "-Xep:AndroidFrameworkTargetSdk:ERROR",
            "-Xep:AndroidHideInComments:ERROR",

            // After fixing this errorprone, we decided to not merge the change.
            // It is not very readable and the benefits are minimal when looking
            // at the size of the maps used in the Bluetooth application.
            // See https://r.android.com/3200511
            "-Xep:AndroidFrameworkEfficientCollections:OFF",

            // Does not look pertinent in our situation
            "-Xep:AndroidFrameworkEfficientXml:OFF",
        ],
    },
}
+1 −72
Original line number Diff line number Diff line
@@ -220,6 +220,7 @@ cc_library {

android_app {
    name: "Bluetooth",
    defaults: ["bluetooth_framework_errorprone_rules"],

    srcs: [
        ":statslog-bluetooth-java-gen",
@@ -321,78 +322,6 @@ android_app {
    apex_available: [
        "com.android.btservices",
    ],
    errorprone: {
        enabled: true,
        javacflags: [
            "-Xep:AlmostJavadoc:ERROR",
            "-Xep:AlreadyChecked:ERROR",
            "-Xep:AndroidFrameworkBinderIdentity:ERROR",
            "-Xep:AndroidFrameworkEfficientParcelable:ERROR",
            "-Xep:AndroidFrameworkEfficientStrings:ERROR",
            "-Xep:AndroidFrameworkPendingIntentMutability:ERROR",
            "-Xep:AndroidFrameworkRequiresPermission:ERROR",
            "-Xep:BadImport:ERROR",
            "-Xep:CatchAndPrintStackTrace:ERROR",
            "-Xep:ClassCanBeStatic:ERROR",
            "-Xep:DateFormatConstant:ERROR",
            "-Xep:EmptyBlockTag:ERROR",
            "-Xep:EmptyCatch:ERROR",
            "-Xep:EqualsGetClass:ERROR",
            "-Xep:EqualsHashCode:ERROR",
            "-Xep:FallThrough:ERROR",
            "-Xep:Finalize:ERROR",
            "-Xep:GuardedBy:ERROR",
            "-Xep:HidingField:ERROR",
            "-Xep:InconsistentHashCode:ERROR",
            "-Xep:InlineMeInliner:ERROR",
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:JavaUtilDate:ERROR",
            "-Xep:JdkObsolete:ERROR",
            "-Xep:LockOnNonEnclosingClassLiteral:ERROR",
            "-Xep:LoopOverCharArray:ERROR",
            "-Xep:MissingCasesInEnumSwitch:ERROR",
            "-Xep:MixedMutabilityReturnType:ERROR",
            "-Xep:MockNotUsedInProduction:ERROR",
            "-Xep:ModifyCollectionInEnhancedForLoop:ERROR",
            "-Xep:NarrowCalculation:ERROR",
            "-Xep:NarrowingCompoundAssignment:ERROR",
            "-Xep:NonApiType:ERROR",
            "-Xep:NonAtomicVolatileUpdate:ERROR",
            "-Xep:NonCanonicalType:ERROR",
            "-Xep:NotJavadoc:ERROR",
            "-Xep:ObjectEqualsForPrimitives:ERROR",
            "-Xep:OperatorPrecedence:ERROR",
            "-Xep:ReferenceEquality:ERROR",
            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
            "-Xep:StaticAssignmentInConstructor:ERROR",
            "-Xep:StaticGuardedByInstance:ERROR",
            "-Xep:StringCaseLocaleUsage:ERROR",
            "-Xep:StringCharset:ERROR",
            "-Xep:SynchronizeOnNonFinalField:ERROR",
            "-Xep:ToStringReturnsNull:ERROR",
            "-Xep:UndefinedEquals:ERROR",
            "-Xep:UnnecessaryStringBuilder:ERROR",
            "-Xep:UnrecognisedJavadocTag:ERROR",
            "-Xep:UnusedMethod:ERROR",
            "-Xep:UnusedNestedClass:ERROR",
            "-Xep:UnusedVariable:ERROR",
            "-Xep:WaitNotInLoop:ERROR",
            "-Xep:WakelockReleasedDangerously:ERROR",

            // After fixing this errorprone, we decided to not merge the change.
            // It is not very readable and the benefits are minimal when looking
            // at the size of the maps used in the Bluetooth application.
            // See https://r.android.com/3200511
            "-Xep:AndroidFrameworkEfficientCollections:OFF",

            // Does not look pertinent in our situation
            "-Xep:AndroidFrameworkEfficientXml:OFF",

            // Exclude generated files
            "-XepExcludedPaths:.*/srcjars/.*",
        ],
    },
    min_sdk_version: "Tiramisu",
    sdk_version: "module_current",
}
+4 −39
Original line number Diff line number Diff line
@@ -4,7 +4,10 @@ package {

java_defaults {
    name: "BluetoothInstrumentationTestsDefaults",
    defaults: ["framework-bluetooth-tests-defaults"],
    defaults: [
        "bluetooth_errorprone_rules",
        "framework-bluetooth-tests-defaults",
    ],

    min_sdk_version: "Tiramisu",
    target_sdk_version: "current",
@@ -54,44 +57,6 @@ java_defaults {
        "mts-bluetooth",
    ],

    errorprone: {
        enabled: true,
        javacflags: [
            "-Xep:AlmostJavadoc:ERROR",
            "-Xep:BadImport:ERROR",
            "-Xep:CatchAndPrintStackTrace:ERROR",
            "-Xep:CatchFail:ERROR",
            "-Xep:ClassCanBeStatic:ERROR",
            "-Xep:DirectInvocationOnMock:ERROR",
            "-Xep:EmptyBlockTag:ERROR",
            "-Xep:EmptyCatch:ERROR",
            "-Xep:EqualsIncompatibleType:ERROR",
            "-Xep:FutureReturnValueIgnored:ERROR",
            "-Xep:GuardedBy:ERROR",
            "-Xep:InlineMeInliner:ERROR",
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidInlineTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:JavaUtilDate:ERROR",
            "-Xep:MockNotUsedInProduction:ERROR",
            "-Xep:ModifiedButNotUsed:ERROR",
            "-Xep:NarrowCalculation:ERROR",
            "-Xep:NonApiType:ERROR",
            "-Xep:NonCanonicalType:ERROR",
            "-Xep:NotJavadoc:ERROR",
            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
            "-Xep:StringCaseLocaleUsage:ERROR",
            "-Xep:StringCharset:ERROR",
            "-Xep:TruthConstantAsserts:ERROR",
            "-Xep:TruthIncompatibleType:ERROR",
            "-Xep:UndefinedEquals:ERROR",
            "-Xep:UnnecessaryAssignment:ERROR",
            "-Xep:UnnecessaryAsync:ERROR",
            "-Xep:UnusedMethod:ERROR",
            "-Xep:UnusedVariable:ERROR",
        ],
    },

    instrumentation_for: "Bluetooth",
}

+1 −44
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ java_library {
java_sdk_library {
    name: "framework-bluetooth",
    defaults: [
        "bluetooth_framework_errorprone_rules",
        "framework-bluetooth-defaults",
        "framework-module-defaults",
    ],
@@ -90,50 +91,6 @@ java_sdk_library {
    plugins: [
        "error_prone_android_framework",
    ],
    errorprone: {
        javacflags: [
            "-Xep:InlineMeSuggester:OFF", // The @InlineMe annotation is not available

            "-Xep:AndroidFrameworkBluetoothPermission:ERROR",
            "-Xep:AndroidFrameworkCompatChange:ERROR",
            "-Xep:AndroidFrameworkEfficientParcelable:ERROR",
            "-Xep:AndroidFrameworkEfficientStrings:ERROR",
            "-Xep:AndroidFrameworkRequiresPermission:ERROR",
            "-Xep:AndroidFrameworkRethrowFromSystem:ERROR",
            "-Xep:AndroidFrameworkTargetSdk:ERROR",
            "-Xep:AndroidHideInComments:ERROR",
            "-Xep:BadImport:ERROR",
            "-Xep:CatchFail:ERROR",
            "-Xep:ClassCanBeStatic:ERROR",
            "-Xep:EmptyBlockTag:ERROR",
            "-Xep:EmptyCatch:ERROR",
            "-Xep:FutureReturnValueIgnored:ERROR",
            "-Xep:InlineMeInliner:ERROR",
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidInlineTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:MockNotUsedInProduction:ERROR",
            "-Xep:NonApiType:ERROR",
            "-Xep:NonCanonicalType:ERROR",
            "-Xep:NotJavadoc:ERROR",
            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
            "-Xep:StringCaseLocaleUsage:ERROR",
            "-Xep:StringCharset:ERROR",
            "-Xep:UnnecessaryAssignment:ERROR",
            "-Xep:UnnecessaryAsync:ERROR",
            "-Xep:UnusedVariable:ERROR",

            // After fixing this errorprone, we decided to not merge the change.
            // It is not very readable and the benefits are minimal when looking
            // at the size of the maps used in the Bluetooth application.
            // See https://r.android.com/3200511
            "-Xep:AndroidFrameworkEfficientCollections:OFF",

            // Exclude generated files
            "-XepExcludedPaths:.*/srcjars/.*",
        ],
        enabled: true,
    },
    lint: {
        strict_updatability_linting: true,
        baseline_filename: "lint-baseline.xml",
+1 −32
Original line number Diff line number Diff line
@@ -18,38 +18,7 @@ package {

java_defaults {
    name: "service-bluetooth-buildflags",
    errorprone: {
        enabled: true,
        javacflags: [
            "-Xep:AlreadyChecked:ERROR",
            "-Xep:BadImport:ERROR",
            "-Xep:CatchFail:ERROR",
            "-Xep:CheckReturnValue:ERROR",
            "-Xep:ClassCanBeStatic:ERROR",
            "-Xep:EmptyBlockTag:ERROR",
            "-Xep:EmptyCatch:ERROR",
            "-Xep:EqualsIncompatibleType:ERROR",
            "-Xep:FutureReturnValueIgnored:ERROR",
            "-Xep:InlineFormatString:ERROR",
            "-Xep:InlineMeInliner:ERROR",
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidInlineTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:LongFloatConversion:ERROR",
            "-Xep:MockNotUsedInProduction:ERROR",
            "-Xep:NonApiType:ERROR",
            "-Xep:NonCanonicalType:ERROR",
            "-Xep:NotJavadoc:ERROR",
            "-Xep:ReferenceEquality:ERROR",
            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
            "-Xep:StringCaseLocaleUsage:ERROR",
            "-Xep:StringCharset:ERROR",
            "-Xep:UnnecessaryAssignment:ERROR",
            "-Xep:UnnecessaryAsync:ERROR",
            "-Xep:UnusedMethod:ERROR",
            "-Xep:UnusedVariable:ERROR",
        ],
    },
    defaults: ["bluetooth_errorprone_rules"],

    lint: {
        error_checks: [