Skip to content

Commit

Permalink
test(android, lint): test java lint in CI
Browse files Browse the repository at this point in the history
Java lint was not being checked anywhere, and the NewApi check in particular
would have stopped a crash. Add full lint configuration tuned for current status

Cannot enable it on the modules or our modules may fail library-consumer's builds,
but we may configure it on the sub-modules from our test app then check that

Tested and working and would have correctly failed the NewApi violation shown in #5206
  • Loading branch information
mikehardy committed Apr 24, 2021
1 parent 49c15f8 commit d807ea8
Show file tree
Hide file tree
Showing 3 changed files with 366 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
timeout_minutes: 15
retry_wait_seconds: 60
max_attempts: 3
command: cd tests/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug -Dorg.gradle.daemon=false
command: cd tests/android && ./gradlew assembleDebug assembleAndroidTest lintDebug -DtestBuildType=debug -Dorg.gradle.daemon=false

- name: Pre-fetch Javascript bundle
# Prebuild the bundle so that's fast when the app starts.
Expand Down
16 changes: 16 additions & 0 deletions tests/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,21 @@ subprojects {
}
}
}
if (project.name.contains('firebase')
&& project.hasProperty('android')) {
android {
lintOptions {
abortOnError = true
warningsAsErrors false
lintConfig file('./lint.xml')
checkReleaseBuilds = true
checkAllWarnings true
showAll true
textReport true
textOutput 'stdout'
htmlReport true
}
}
}
}
}
349 changes: 349 additions & 0 deletions tests/android/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,349 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- INFORMATION ABOUT USAGE
We use this file bacause we want to enable for the release build various checks from the
Android SDK(initially just NewApi and InlinedApi) plus our own custom checks.
Using the check() method on lintOptions in the lint.gradle file would be nice but it
doesn't work as it will NOT recognize any custom Lint checks(from a local module(like lint-rules)
or from a library added as a dependency) .
To allow more checks for the release build you will need to modify this file to change the
severity of that check to fatal. For example, to enable for release the WrongViewCast check
change:
<issue id="WrongViewCast" severity="fatal" />
Also, note that any NEW issue will appear when linting as this is not an exclusive list of
issues to use in linting, it's a file used to declare how the issues are applied to the project.
If a NEW issue is created by the Android framework or added by other libraries which should be
disabled for release then add it to this file like this:
<issue id="NewIssueId" severity="ignore"/>
-->
<lint>
<issue id="NewApi" severity="fatal" />
<issue id="HardcodedText" severity="fatal" />
<issue id="InlinedApi" severity="fatal" />
<issue id="StringFormatCount" severity="fatal" />
<issue id="StringFormatMatches" severity="fatal" />
<issue id="StringFormatInvalid" severity="fatal" />
<issue id="UnusedResources" severity="fatal" />
<issue id="ViewConstructor" severity="fatal" />
<issue id="ViewHolder" severity="fatal" />
<issue id="ViewTag" severity="fatal" />
<issue id="WrongConstant" severity="fatal" />
<issue id="WrongViewCast" severity="fatal" />

<!-- RTL Rules -->
<issue id="RtlCompat" severity="fatal" />
<issue id="RtlEnabled" severity="fatal" />
<issue id="RtlHardcoded" severity="fatal" />
<!-- RtlSymmetry is disabled because we already have RtlHardcoded rule enabled -->
<issue id="RtlSymmetry" severity="ignore" />

<!-- <issue id="UseCompatTextViewDrawableXml" severity="ignore" /> -->
<issue id="UnknownNullness" severity="ignore" />
<issue id="SyntheticAccessor" severity="ignore" />
<!-- FIXME need to remove WRITE_EXTERNAL_STORAGE from storage -->
<issue id="ScopedStorage" severity="warning" />
<issue id="AcceptsUserCertificates" severity="ignore" />
<issue id="RedundantNamespace" severity="ignore" />
<issue id="Autofill" severity="ignore" />
<issue id="ContentDescription" severity="ignore" />
<issue id="AddJavascriptInterface" severity="ignore" />
<issue id="ShortAlarm" severity="ignore" />
<issue id="AllCaps" severity="ignore" />
<issue id="AllowAllHostnameVerifier" severity="ignore" />
<issue id="AlwaysShowAction" severity="ignore" />
<issue id="InvalidUsesTagAttribute" severity="ignore" />
<issue id="MissingIntentFilterForMediaSearch" severity="ignore" />
<issue id="MissingMediaBrowserServiceIntentFilter" severity="ignore" />
<issue id="MissingOnPlayFromSearch" severity="ignore" />
<issue id="ImpliedTouchscreenHardware" severity="ignore" />
<issue id="MissingTvBanner" severity="ignore" />
<issue id="MissingLeanbackLauncher" severity="ignore" />
<issue id="MissingLeanbackSupport" severity="ignore" />
<issue id="PermissionImpliesUnsupportedHardware" severity="ignore" />
<issue id="UnsupportedTvHardware" severity="ignore" />
<issue id="SupportAnnotationUsage" severity="ignore" />
<issue id="ShiftFlags" severity="ignore" />
<issue id="LocalSuppress" severity="ignore" />
<issue id="SwitchIntDef" severity="ignore" />
<issue id="UniqueConstants" severity="ignore" />
<issue id="Override" severity="ignore" />
<issue id="ObsoleteSdkInt" severity="ignore" />
<issue id="UnusedAttribute" severity="ignore" />
<issue id="AppCompatMethod" severity="ignore" />
<issue id="AppCompatCustomView" severity="ignore" />
<issue id="AppCompatResource" severity="ignore" />
<issue id="GoogleAppIndexingApiWarning" severity="ignore" />
<issue id="GoogleAppIndexingWarning" severity="ignore" />
<issue id="AppLinksAutoVerifyError" severity="ignore" />
<issue id="AppLinksAutoVerifyWarning" severity="ignore" />
<issue id="AppLinkUrlError" severity="ignore" />
<issue id="TestAppLink" severity="ignore" />
<issue id="InconsistentArrays" severity="ignore" />
<issue id="Assert" severity="ignore" />
<issue id="BadHostnameVerifier" severity="ignore" />
<issue id="BatteryLife" severity="ignore" />
<issue id="BackButton" severity="ignore" />
<issue id="ButtonCase" severity="ignore" />
<issue id="ButtonOrder" severity="ignore" />
<issue id="ButtonStyle" severity="ignore" />
<issue id="ByteOrderMark" severity="ignore" />
<issue id="MissingSuperCall" severity="ignore" />
<issue id="AdapterViewChildren" severity="ignore" />
<issue id="ScrollViewCount" severity="ignore" />
<issue id="PermissionImpliesUnsupportedChromeOsHardware" severity="ignore" />
<issue id="UnsupportedChromeOsHardware" severity="ignore" />
<issue id="GetInstance" severity="ignore" />
<issue id="CommitTransaction" severity="ignore" />
<issue id="Recycle" severity="ignore" />
<issue id="CommitPrefEdits" severity="ignore" />
<issue id="ApplySharedPref" severity="ignore" />
<issue id="ClickableViewAccessibility" severity="ignore" />
<issue id="EasterEgg" severity="ignore" />
<issue id="StopShip" severity="ignore" />
<issue id="MissingConstraints" severity="ignore" />
<issue id="VulnerableCordovaVersion" severity="ignore" />
<issue id="CustomViewStyleable" severity="ignore" />
<issue id="CutPasteId" severity="ignore" />
<issue id="SimpleDateFormat" severity="ignore" />
<issue id="SetTextI18n" severity="ignore" />
<issue id="Deprecated" severity="ignore" />
<issue id="MissingPrefix" severity="ignore" />
<issue id="MangledCRLF" severity="ignore" />
<issue id="DuplicateIncludedIds" severity="ignore" />
<issue id="DuplicateIds" severity="ignore" />
<issue id="DuplicateDefinition" severity="ignore" />
<issue id="ReferenceType" severity="ignore" />
<issue id="StringEscaping" severity="ignore" />
<issue id="UnpackedNativeCode" severity="ignore" />
<issue id="UnsafeDynamicallyLoadedCode" severity="ignore" />
<issue id="UnsafeNativeCodeLocation" severity="ignore" />
<issue id="EllipsizeMaxLines" severity="ignore" />
<issue id="ExifInterface" severity="ignore" />
<issue id="ExtraText" severity="ignore" />
<issue id="FieldGetter" severity="ignore" />
<issue id="InvalidAnalyticsName" severity="ignore" />
<issue id="MissingFirebaseInstanceTokenRefresh" severity="ignore" />
<issue id="FontValidationError" severity="ignore" />
<issue id="FontValidationWarning" severity="ignore" />
<issue id="FullBackupContent" severity="ignore" />
<issue id="ValidFragment" severity="ignore" />
<issue id="GetContentDescriptionOverride" severity="ignore" />
<issue id="PackageManagerGetSignatures" severity="ignore" />
<issue id="AccidentalOctal" severity="ignore" />
<issue id="UseOfBundledGooglePlayServices" severity="ignore" />
<issue id="GradleCompatible" severity="ignore" />
<issue id="GradleDependency" severity="ignore" />
<issue id="GradleDeprecated" severity="ignore" />
<issue id="DevModeObsolete" severity="ignore" />
<issue id="DuplicatePlatformClasses" severity="ignore" />
<issue id="GradleGetter" severity="ignore" />
<issue id="GradlePluginVersion" severity="ignore" />
<issue id="HighAppVersionCode" severity="ignore" />
<issue id="GradleIdeError" severity="ignore" />
<issue id="GradlePath" severity="ignore" />
<issue id="GradleDynamicVersion" severity="ignore" />
<issue id="NotInterpolated" severity="ignore" />
<issue id="StringShouldBeInt" severity="ignore" />
<issue id="NewerVersionAvailable" severity="ignore" />
<issue id="MinSdkTooLow" severity="ignore" />
<issue id="GridLayout" severity="ignore" />
<issue id="HandlerLeak" severity="ignore" />
<issue id="HardcodedDebugMode" severity="ignore" />
<issue id="HardwareIds" severity="ignore" />
<issue id="IconDuplicatesConfig" severity="ignore" />
<issue id="IconDuplicates" severity="ignore" />
<issue id="GifUsage" severity="ignore" />
<issue id="IconColors" severity="ignore" />
<issue id="IconDensities" severity="ignore" />
<issue id="IconDipSize" severity="ignore" />
<issue id="IconExpectedSize" severity="ignore" />
<issue id="IconExtension" severity="ignore" />
<issue id="IconLauncherShape" severity="ignore" />
<issue id="IconLocation" severity="ignore" />
<issue id="IconMissingDensityFolder" severity="ignore" />
<issue id="IconMixedNinePatch" severity="ignore" />
<issue id="IconNoDpi" severity="ignore" />
<issue id="IconXmlAndPng" severity="ignore" />
<issue id="ConvertToWebp" severity="ignore" />
<issue id="WebpUnsupported" severity="ignore" />
<issue id="IncludeLayoutParam" severity="ignore" />
<issue id="DisableBaselineAlignment" severity="ignore" />
<issue id="InefficientWeight" severity="ignore" />
<issue id="NestedWeights" severity="ignore" />
<issue id="Orientation" severity="ignore" />
<issue id="Suspicious0dp" severity="ignore" />
<issue id="InstantApps" severity="ignore" />
<issue id="DuplicateDivider" severity="ignore" />
<issue id="TrustAllX509TrustManager" severity="ignore" />
<issue id="InvalidImeActionId" severity="ignore" />
<issue id="InvalidPackage" severity="ignore" />
<issue id="DrawAllocation" severity="ignore" />
<issue id="UseSparseArrays" severity="ignore" />
<issue id="UseValueOf" severity="ignore" />
<issue id="JavascriptInterface" severity="ignore" />
<issue id="JobSchedulerService" severity="ignore" />
<issue id="KeyboardInaccessibleWidget" severity="ignore" />
<issue id="LabelFor" severity="ignore" />
<issue id="InconsistentLayout" severity="ignore" />
<issue id="InflateParams" severity="ignore" />
<issue id="StaticFieldLeak" severity="ignore" />
<issue id="DefaultLocale" severity="ignore" />
<issue id="LocaleFolder" severity="ignore" />
<issue id="GetLocales" severity="ignore" />
<issue id="InvalidResourceFolder" severity="ignore" />
<issue id="WrongRegion" severity="ignore" />
<issue id="UseAlpha2" severity="ignore" />
<issue id="LogConditional" severity="ignore" />
<issue id="LongLogTag" severity="ignore" />
<issue id="LogTagMismatch" severity="ignore" />
<issue id="AllowBackup" severity="ignore" />
<issue id="MissingApplicationIcon" severity="ignore" />
<issue id="DeviceAdmin" severity="ignore" />
<issue id="DuplicateActivity" severity="ignore" />
<issue id="DuplicateUsesFeature" severity="ignore" />
<issue id="GradleOverrides" severity="ignore" />
<issue id="IllegalResourceRef" severity="ignore" />
<issue id="MipmapIcons" severity="ignore" />
<issue id="MockLocation" severity="ignore" />
<issue id="MultipleUsesSdk" severity="ignore" />
<issue id="ManifestOrder" severity="ignore" />
<issue id="MissingVersion" severity="ignore" />
<issue id="OldTargetApi" severity="ignore" />
<issue id="UniquePermission" severity="ignore" />
<issue id="UsesMinSdkAttributes" severity="ignore" />
<issue id="WearableBindListener" severity="ignore" />
<issue id="WrongManifestParent" severity="ignore" />
<issue id="InvalidPermission" severity="ignore" />
<issue id="ManifestResource" severity="ignore" />
<issue id="ManifestTypo" severity="ignore" />
<!-- <issue id="FloatMath" severity="ignore" /> -->
<issue id="MergeMarker" severity="ignore" />
<issue id="MergeRootFrame" severity="ignore" />
<issue id="IncompatibleMediaBrowserServiceCompatVersion" severity="ignore" />
<issue id="InnerclassSeparator" severity="ignore" />
<issue id="Instantiatable" severity="ignore" />
<!-- <issue id="MissingRegistered" severity="ignore" /> -->
<issue id="MissingId" severity="ignore" />
<issue id="LibraryCustomView" severity="ignore" />
<issue id="ResAuto" severity="ignore" />
<issue id="NamespaceTypo" severity="ignore" />
<issue id="UnusedNamespace" severity="ignore" />
<issue id="NegativeMargin" severity="ignore" />
<issue id="NestedScrolling" severity="ignore" />
<issue id="NetworkSecurityConfig" severity="ignore" />
<issue id="MissingBackupPin" severity="ignore" />
<issue id="PinSetExpiry" severity="ignore" />
<issue id="NfcTechWhitespace" severity="ignore" />
<issue id="UnlocalizedSms" severity="ignore" />
<issue id="ObjectAnimatorBinding" severity="ignore" />
<issue id="AnimatorKeep" severity="ignore" />
<issue id="ObsoleteLayoutParam" severity="ignore" />
<issue id="OnClick" severity="ignore" />
<issue id="Overdraw" severity="ignore" />
<issue id="DalvikOverride" severity="ignore" />
<issue id="OverrideAbstract" severity="ignore" />
<issue id="ParcelCreator" severity="ignore" />
<issue id="UnusedQuantity" severity="ignore" />
<issue id="MissingQuantity" severity="ignore" />
<issue id="ImpliedQuantity" severity="ignore" />
<issue id="ExportedPreferenceActivity" severity="ignore" />
<issue id="PrivateApi" severity="ignore" />
<issue id="PackagedPrivateKey" severity="ignore" />
<issue id="PrivateResource" severity="ignore" />
<issue id="ProguardSplit" severity="ignore" />
<issue id="Proguard" severity="ignore" />
<issue id="PropertyEscape" severity="ignore" />
<issue id="UsingHttp" severity="ignore" />
<issue id="SpUsage" severity="ignore" />
<issue id="InOrMmUsage" severity="ignore" />
<issue id="PxUsage" severity="ignore" />
<issue id="SmallSp" severity="ignore" />
<issue id="ParcelClassLoader" severity="ignore" />
<issue id="PendingBindings" severity="ignore" />
<issue id="RecyclerView" severity="ignore" />
<issue id="Registered" severity="ignore" />
<issue id="RelativeOverlap" severity="ignore" />
<issue id="RequiredSize" severity="ignore" />
<issue id="AaptCrash" severity="ignore" />
<issue id="ResourceCycle" severity="ignore" />
<issue id="ResourceName" severity="ignore" />
<issue id="ValidRestrictions" severity="ignore" />
<issue id="ScrollViewSize" severity="ignore" />
<issue id="SdCardPath" severity="ignore" />
<issue id="SecureRandom" severity="ignore" />
<issue id="TrulyRandom" severity="ignore" />
<issue id="ExportedContentProvider" severity="ignore" />
<issue id="ExportedReceiver" severity="ignore" />
<issue id="ExportedService" severity="ignore" />
<issue id="SetWorldReadable" severity="ignore" />
<issue id="SetWorldWritable" severity="ignore" />
<issue id="GrantAllUris" severity="ignore" />
<issue id="WorldReadableFiles" severity="ignore" />
<issue id="WorldWriteableFiles" severity="ignore" />
<issue id="ServiceCast" severity="ignore" />
<issue id="WifiManagerLeak" severity="ignore" />
<issue id="WifiManagerPotentialLeak" severity="ignore" />
<issue id="SetJavaScriptEnabled" severity="ignore" />
<issue id="SignatureOrSystemPermissions" severity="ignore" />
<issue id="SQLiteString" severity="ignore" />
<issue id="SSLCertificateSocketFactoryCreateSocket" severity="ignore" />
<issue id="SSLCertificateSocketFactoryGetInsecure" severity="ignore" />
<issue id="StateListReachable" severity="ignore" />
<issue id="AuthLeak" severity="ignore" />
<issue id="PluralsCandidate" severity="ignore" />
<issue id="UseCheckPermission" severity="ignore" />
<issue id="CheckResult" severity="ignore" />
<issue id="ResourceAsColor" severity="ignore" />
<issue id="MissingPermission" severity="ignore" />
<issue id="Range" severity="ignore" />
<issue id="ResourceType" severity="ignore" />
<issue id="RestrictedApi" severity="ignore" />
<issue id="WrongThread" severity="ignore" />
<issue id="VisibleForTests" severity="ignore" />
<issue id="ProtectedPermissions" severity="ignore" />
<issue id="TextFields" severity="ignore" />
<issue id="TextViewEdits" severity="ignore" />
<issue id="SelectableText" severity="ignore" />
<issue id="MenuTitle" severity="ignore" />
<issue id="ShowToast" severity="ignore" />
<issue id="TooDeepLayout" severity="ignore" />
<issue id="TooManyViews" severity="ignore" />
<issue id="ExtraTranslation" severity="ignore" />
<issue id="MissingTranslation" severity="ignore" />
<issue id="Typos" severity="ignore" />
<issue id="TypographyDashes" severity="ignore" />
<issue id="TypographyEllipsis" severity="ignore" />
<issue id="TypographyFractions" severity="ignore" />
<issue id="TypographyOther" severity="ignore" />
<issue id="TypographyQuotes" severity="ignore" />
<issue id="UnsafeProtectedBroadcastReceiver" severity="ignore" />
<issue id="UnprotectedSMSBroadcastReceiver" severity="ignore" />
<issue id="UnusedIds" severity="ignore" />
<issue id="UseCompoundDrawables" severity="ignore" />
<issue id="UselessLeaf" severity="ignore" />
<issue id="UselessParent" severity="ignore" />
<issue id="EnforceUTF8" severity="ignore" />
<issue id="VectorRaster" severity="ignore" />
<issue id="VectorDrawableCompat" severity="ignore" />
<issue id="VectorPath" severity="ignore" />
<issue id="InvalidVectorPath" severity="ignore" />
<issue id="FindViewByIdCast" severity="ignore" />
<issue id="Wakelock" severity="ignore" />
<issue id="WakelockTimeout" severity="ignore" />
<issue id="InvalidWearFeatureAttribute" severity="ignore" />
<issue id="WearStandaloneAppFlag" severity="ignore" />
<issue id="WebViewLayout" severity="ignore" />
<issue id="WrongCall" severity="ignore" />
<issue id="WrongCase" severity="ignore" />
<issue id="InvalidId" severity="ignore" />
<issue id="NotSibling" severity="ignore" />
<issue id="UnknownId" severity="ignore" />
<issue id="UnknownIdInLayout" severity="ignore" />
<issue id="SuspiciousImport" severity="ignore" />
<issue id="WrongFolder" severity="ignore" />
<issue id="WrongThreadInterprocedural" severity="ignore" />
</lint>

1 comment on commit d807ea8

@vercel
Copy link

@vercel vercel bot commented on d807ea8 Apr 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.