diff --git a/focus-android/build.gradle b/focus-android/build.gradle index d6cbf9d610d2..0ee6a6796d08 100644 --- a/focus-android/build.gradle +++ b/focus-android/build.gradle @@ -40,11 +40,10 @@ buildscript { } plugins { - id "io.gitlab.arturbosch.detekt" version "1.19.0" // Variables in plugins {} aren't supported + id "io.gitlab.arturbosch.detekt" version "1.22.0" // Variables in plugins {} aren't supported } detekt { - buildUponDefaultConfig = true input = files("$projectDir/app") config = files("$projectDir/quality/detekt.yml") baseline = file("$projectDir/quality/detekt-baseline.xml") @@ -54,9 +53,34 @@ detekt { enabled = true destination = file("$projectDir/build/reports/detekt.html") } + xml { + enabled = false + } + txt { + enabled = false + } } } +tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach() { + autoCorrect = true + + exclude "**/test/**" + exclude "**/androidTest/**" + exclude "**/build/**" + exclude "**/resources/**" + exclude "**/tmp/**" +} + +// Apply same path exclusions as for the main task +tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach() { + exclude "**/test/**" + exclude "**/androidTest/**" + exclude "**/build/**" + exclude "**/resources/**" + exclude "**/tmp/**" +} + allprojects { repositories { google() diff --git a/focus-android/quality/detekt-baseline.xml b/focus-android/quality/detekt-baseline.xml index b95304af7a4f..5caa43869fda 100644 --- a/focus-android/quality/detekt-baseline.xml +++ b/focus-android/quality/detekt-baseline.xml @@ -4,61 +4,24 @@ CollapsibleIfStatements:MainActivity.kt$MainActivity$if (!isTaskRoot) { if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN == intent.action) { finish() return } } CollapsibleIfStatements:UrlInputFragment.kt$UrlInputFragment.<no name provided>$if (reverse) { if (isOverlay) { dismiss() } } - ConstructorParameterNaming:FocusNimbus.kt$CookieBanner$_variables: Variables = NullVariables.instance - ConstructorParameterNaming:FocusNimbus.kt$CookieBanner$private val _defaults: Defaults - ConstructorParameterNaming:FocusNimbus.kt$CookieBanner$private val _variables: Variables - ConstructorParameterNaming:FocusNimbus.kt$Onboarding$_variables: Variables = NullVariables.instance - ConstructorParameterNaming:FocusNimbus.kt$Onboarding$private val _defaults: Defaults - ConstructorParameterNaming:FocusNimbus.kt$Onboarding$private val _variables: Variables EmptyFunctionBlock:AutocompleteListFragment.kt$AutocompleteListFragment.<no name provided>${} - EmptyFunctionBlock:BiometricAuthenticationFragmentTest.kt$BiometricAuthenticationFragmentTest.<no name provided>${ } EmptyFunctionBlock:ExceptionsListFragment.kt$ExceptionsListFragment.<no name provided>${} EmptyFunctionBlock:FirstrunFragment.kt$FirstrunFragment.<no name provided>${} - FunctionOnlyReturningConstant:ExternalIntentNavigationTest.kt$ShadowPerformance$@Implementation @Suppress("Unused_Parameter") fun processIntentIfPerformanceTest(bundle: Bundle?, context: Context) LongParameterList:FullScreenIntegration.kt$FullScreenIntegration$( val activity: Activity, val store: BrowserStore, tabId: String?, sessionUseCases: SessionUseCases, private val settings: Settings, private val toolbarView: BrowserToolbar, private val statusBar: View, private val engineView: EngineView, ) - MatchingDeclarationName:SettingsSearchMenuRobot.kt$SearchSettingsRobot - MaxLineLength:BiometricAuthenticationFragmentTest.kt$BiometricAuthenticationFragmentTest$fun - MaxLineLength:BrowserRobot.kt$BrowserRobot$fun verifyOpenLinksInAppsPrompt(openLinksInAppsEnabled: Boolean, link: String) - MaxLineLength:BrowserRobot.kt$BrowserRobot.Transition$fun - MaxLineLength:BrowserToolbarIntegrationTest.kt$BrowserToolbarIntegrationTest$fun - MaxLineLength:BrowserToolbarTest.kt$BrowserToolbarTest$assertTrue((engineView.layoutParams as? CoordinatorLayout.LayoutParams)?.behavior is EngineViewBrowserToolbarBehavior) - MaxLineLength:CfrMiddlewareTest.kt$CfrMiddlewareTest$fun - MaxLineLength:ExternalIntentNavigationTest.kt$ExternalIntentNavigationTest$fun - MaxLineLength:FocusNimbus.kt$Onboarding$_defaults = Defaults(isCfrEnabled = isCfrEnabled, isEnabled = isEnabled, isPromoteSearchWidgetDialogEnabled = isPromoteSearchWidgetDialogEnabled ) - MaxLineLength:HomeScreenScreenshots.kt$HomeScreenScreenshots$TestHelper.mDevice.findObject(UiSelector().resourceId("${TestHelper.packageName}:id/mozac_browser_toolbar_edit_url_view")) - MaxLineLength:HomeScreenScreenshots.kt$HomeScreenScreenshots$TestHelper.mDevice.findObject(UiSelector().resourceId("${TestHelper.packageName}:id/mozac_browser_toolbar_menu")) - MaxLineLength:HomeScreenScreenshots.kt$HomeScreenScreenshots$private - MaxLineLength:IntentUtilsTest.kt$IntentUtilsTest$fun - MaxLineLength:MainActivityTestRule.kt$MainActivityIntentsTestRule$open - MaxLineLength:MobileMetricsPingStorageTest.kt$MobileMetricsPingStorageTest$private val file = File("${(ApplicationProvider.getApplicationContext() as FocusApplication).cacheDir}/${MobileMetricsPingStorage.STORAGE_FOLDER}/${MobileMetricsPingStorage.FILE_NAME}") - MaxLineLength:OnboardingStorageTest.kt$OnboardingStorageTest$assertEquals(testContext.getString(OnboardingStep.ON_BOARDING_FIRST_SCREEN.prefId), prefManager.getString(testContext.getString(R.string.pref_key_onboarding_step), "")) - MaxLineLength:OnboardingStorageTest.kt$OnboardingStorageTest$assertEquals(testContext.getString(OnboardingStep.ON_BOARDING_SECOND_SCREEN.prefId), prefManager.getString(testContext.getString(R.string.pref_key_onboarding_step), "")) - MaxLineLength:OnboardingStorageTest.kt$OnboardingStorageTest$fun - MaxLineLength:SearchRobot.kt$private val clearSearchButton = mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_clear_view")) - MaxLineLength:SearchWidgetProviderTest.kt$SearchWidgetProviderTest$fun - MaxLineLength:SettingsPrivacyMenuRobot.kt$. - MaxLineLength:SettingsPrivacyMenuRobot.kt$SettingsPrivacyMenuRobot.Transition$fun - MaxLineLength:SitePermissionOptionsStorageTest.kt$SitePermissionOptionsStorageTest$fun - MaxLineLength:SitePermissionOptionsStoreTest.kt$SitePermissionOptionsStoreTest$doReturn(listOf(SitePermissionOption.AskToAllow(), SitePermissionOption.Blocked())).`when`(storage).getSitePermissionOptions(SitePermission.CAMERA) - MaxLineLength:SitePermissionOptionsStoreTest.kt$SitePermissionOptionsStoreTest$doReturn(testContext.getString(R.string.preference_phone_feature_camera)).`when`(storage).getSitePermissionLabel(SitePermission.CAMERA) - MaxLineLength:SitePermissionOptionsStoreTest.kt$SitePermissionOptionsStoreTest$fun - MaxLineLength:SitePermissionOptionsStoreTest.kt$SitePermissionOptionsStoreTest$verify(storage).saveCurrentSitePermissionOptionInSharePref(SitePermissionOption.Blocked(), SitePermission.CAMERA) - MaxLineLength:SitePermissionsFragmentTest.kt$SitePermissionsFragmentTest$fun - MaxLineLength:StartupPathProviderTest.kt$StartupPathProviderTest$fun - MaxLineLength:StartupStateProviderTest.kt$StartupStateProviderTest$fun - MaxLineLength:StartupTypeTelemetryTest.kt$StartupTypeTelemetryTest$fun - MaxLineLength:StringTest.kt$StringTest$"http://amazon.com/Mockingjay-Hunger-Games-Suzanne-Collins/dp/0545663261/ref=pd_sim_14_2?_encoding=UTF8&psc=1&refRID=90ZHE3V976TKBGDR9VAM" - MaxLineLength:StringTest.kt$StringTest$"https://www.nytimes.com/2017/08/30/world/europe/princess-diana-death-anniversary.html?hp&action=click&pgtype=Homepage&clickSource=story-heading&module=second-column-region&region=top-news&WT.nav=top-news" - MaxLineLength:StringTest.kt$StringTest$"https://www.wsj.com/articles/mexican-presidential-candidate-calls-for-nafta-talks-to-be-suspended-1504137175" - MaxLineLength:UriTest.kt$UriTest$assertTruncatedHost("yahoo.com", "https://de.search.yahoo.com/search?p=mozilla&fr=yfp-t&fp=1&toggle=1&cop=mss&ei=UTF-8") MayBeConst:CrashReporterFragment.kt$CrashReporterFragment.Companion$val FRAGMENT_TAG = "crash-reporter" MayBeConst:IconGenerator.kt$IconGenerator.Companion$private val DEFAULT_ICON_CHAR = '?' MayBeConst:IconGenerator.kt$IconGenerator.Companion$private val TEXT_SIZE_DP = 36f MayBeConst:ManualAddSearchEnginePreference.kt$ManualAddSearchEnginePreference.Companion$private val SEARCH_ENGINE_NAME_KEY = "search-engine-name" MayBeConst:ManualAddSearchEnginePreference.kt$ManualAddSearchEnginePreference.Companion$private val SEARCH_QUERY_KEY = "search-query" MayBeConst:ManualAddSearchEnginePreference.kt$ManualAddSearchEnginePreference.Companion$private val SUPER_STATE_KEY = "super-state" - PrintStackTrace:TestHelper.kt$TestHelper$e - SpacingBetweenPackageAndImports:FocusNimbus.kt$ + SwallowedException:AppReviewUtils.kt$AppReviewUtils.Companion$e: ActivityNotFoundException + SwallowedException:BrowserFragment.kt$BrowserFragment$e: IllegalStateException + SwallowedException:FenixProductDetector.kt$FenixProductDetector$e: PackageManager.NameNotFoundException + SwallowedException:LocalizedContent.kt$LocalizedContent$e: PackageManager.NameNotFoundException + SwallowedException:ManualAddSearchEngineSettingsFragment.kt$ManualAddSearchEngineSettingsFragment.Companion$e: IOException + SwallowedException:MobileMetricsPingStorage.kt$MobileMetricsPingStorage$e: FileNotFoundException + SwallowedException:MobileMetricsPingStorage.kt$MobileMetricsPingStorage$e: IOException + SwallowedException:MobileMetricsPingStorage.kt$MobileMetricsPingStorage$e: JSONException UndocumentedPublicClass:AboutFragment.kt$AboutFragment : BaseSettingsLikeFragment UndocumentedPublicClass:AdvancedSettingsFragment.kt$AdvancedSettingsFragment : BaseSettingsFragmentOnSharedPreferenceChangeListener UndocumentedPublicClass:AppAction.kt$AppAction$NavigateUp : AppAction @@ -118,7 +81,6 @@ UndocumentedPublicClass:FirstrunFragment.kt$FirstrunFragment : FragmentOnClickListener UndocumentedPublicClass:FirstrunPagerAdapter.kt$FirstrunPagerAdapter : PagerAdapter UndocumentedPublicClass:FocusApplication.kt$FocusApplication : LocaleAwareApplicationProviderCoroutineScope - UndocumentedPublicClass:FocusNimbus.kt$FocusNimbus$Features UndocumentedPublicClass:FocusSnackbar.kt$FocusSnackbar : BaseTransientBottomBar UndocumentedPublicClass:FocusSnackbarDelegate.kt$FocusSnackbarDelegate : SnackbarDelegate UndocumentedPublicClass:FullScreenIntegration.kt$FullScreenIntegration : LifecycleAwareFeatureUserInteractionHandler @@ -311,7 +273,7 @@ UndocumentedPublicFunction:FocusTheme.kt$fun phoneDimensions() UndocumentedPublicFunction:FocusTheme.kt$fun tabletDimensions() UndocumentedPublicFunction:HomeMenu.kt$HomeMenu$fun getMenuBuilder(): BrowserMenuBuilder - UndocumentedPublicFunction:IconGenerator.kt$IconGenerator.Companion$/* * This method needs to be separate from generateAdaptiveLauncherIcon so that we can generate * the pre-Oreo icon to display in the Add To Home screen Dialog */ @JvmStatic fun generateLauncherIconPreOreo(context: Context, character: Char): Bitmap + UndocumentedPublicFunction:IconGenerator.kt$IconGenerator.Companion$@JvmStatic fun generateLauncherIconPreOreo(context: Context, character: Char): Bitmap UndocumentedPublicFunction:InstallFirefoxActivity.kt$InstallFirefoxActivity.Companion$fun open(context: Context) UndocumentedPublicFunction:InstallFirefoxActivity.kt$InstallFirefoxActivity.Companion$fun resolveAppStore(context: Context): ActivityInfo? UndocumentedPublicFunction:InstalledSearchEnginesSettingsFragment.kt$InstalledSearchEnginesSettingsFragment.Companion$fun newInstance() @@ -427,8 +389,8 @@ UndocumentedPublicFunction:StudiesViewHolder.kt$StudiesViewHolder.SectionViewHolder$fun bindSection(section: StudiesListItem.Section) UndocumentedPublicFunction:StudiesViewModel.kt$StudiesViewModel$fun removeStudy(study: StudiesListItem.ActiveStudy) UndocumentedPublicFunction:StudiesViewModel.kt$StudiesViewModel$fun setStudiesState(state: Boolean) - UndocumentedPublicFunction:SupportUtils.kt$SupportUtils$// For some reason this URL has a different format than the other SUMO URLs fun getSafeBrowsingURL(): String UndocumentedPublicFunction:SupportUtils.kt$SupportUtils$fun getGenericSumoURLForTopic(topic: SumoTopic): String + UndocumentedPublicFunction:SupportUtils.kt$SupportUtils$fun getSafeBrowsingURL(): String UndocumentedPublicFunction:SupportUtils.kt$SupportUtils$fun getSumoURLForTopic(context: Context, topic: SumoTopic): String UndocumentedPublicFunction:SupportUtils.kt$SupportUtils$fun openDefaultBrowserSumoPage(context: Context) UndocumentedPublicFunction:SupportUtils.kt$SupportUtils$fun openUrlInCustomTab(activity: FragmentActivity, destinationUrl: String) @@ -520,13 +482,17 @@ UndocumentedPublicFunction:WhatsNewStorage.kt$WhatsNewStorage$fun getVersion(): WhatsNewVersion? UndocumentedPublicFunction:WhatsNewStorage.kt$WhatsNewStorage$fun setSessionCounter(sessionCount: Int) UndocumentedPublicFunction:WhatsNewStorage.kt$WhatsNewStorage$fun setVersion(version: WhatsNewVersion) - UnusedPrivateMember:DownloadRobot.kt$private val downloadNotificationText = getStringResource(R.string.mozac_feature_downloads_completed_notification_text2) - UnusedPrivateMember:ExternalIntentNavigationTest.kt$ShadowPerformance$bundle: Bundle? - UnusedPrivateMember:ExternalIntentNavigationTest.kt$ShadowPerformance$context: Context - UnusedPrivateMember:SettingsGeneralMenuRobot.kt$private val openWithDialogTitle = mDevice.findObject( UiSelector() .text("Open with"), ) - UnusedPrivateMember:SettingsGeneralMenuRobot.kt$private val openWithList = mDevice.findObject( UiSelector() .resourceId("android:id/resolver_list"), ) - UnusedPrivateMember:TelemetryMiddleware.kt$TelemetryMiddleware$ @Suppress("ComplexMethod") private fun generateOptions(customTabConfig: CustomTabConfig): List<String> - UnusedPrivateMember:WhatsNewTest.kt$WhatsNewTest$i + UnusedPrivateMember:TelemetryMiddleware.kt$TelemetryMiddleware$@Suppress("ComplexMethod") private fun generateOptions(customTabConfig: CustomTabConfig): List<String> + UseCheckOrError:ClientWrapper.kt$ClientWrapper$throw IllegalStateException("Non-private request") + UseCheckOrError:CookieBannerExceptionStore.kt$throw IllegalStateException( "You need to add CookieBannerExceptionMiddleware to your CookieBannerStore. ($action)", ) + UseCheckOrError:LanguageScreenStore.kt$throw IllegalStateException("You need to add LanguageMiddleware to your LanguageScreenStore. ($action)") + UseCheckOrError:MainActivityNavigation.kt$MainActivityNavigation$throw IllegalStateException("Trying to lock unsupported device") + UseCheckOrError:SanityCheckMiddleware.kt$SanityCheckMiddleware$throw IllegalStateException("State contains non-private tabs") + UseCheckOrError:SessionNotificationService.kt$SessionNotificationService$throw IllegalStateException("Unknown intent: $intent") + UseCheckOrError:SettingsFragment.kt$SettingsFragment$throw IllegalStateException("Unknown preference: ${preference.key}") + UseCheckOrError:SitePermissionOptionsScreenStore.kt$throw IllegalStateException( "You need to add SitePermissionsOptionsMiddleware to your SitePermissionsOptionsScreenStore. ($action)", ) + UseCheckOrError:UrlInputFragment.kt$UrlInputFragment$throw IllegalStateException("Unhandled view in onClick()") + UseRequire:FactsProcessor.kt$throw IllegalArgumentException("Fact is not a context menu fact") UtilityClassWithPublicConstructor:AppReviewUtils.kt$AppReviewUtils UtilityClassWithPublicConstructor:IconGenerator.kt$IconGenerator diff --git a/focus-android/quality/detekt.yml b/focus-android/quality/detekt.yml index 51c4b4433dc8..939371387a88 100644 --- a/focus-android/quality/detekt.yml +++ b/focus-android/quality/detekt.yml @@ -10,10 +10,17 @@ build: # style: 1 # comments: 1 +config: + validation: true + warningsAsErrors: false + checkExhaustiveness: false + # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' + excludes: '' + processors: active: true exclude: - # - 'DetektProgressListener' + - 'DetektProgressListener' # - 'KtFileCountProcessor' # - 'PackageCountProcessor' # - 'ClassCountProcessor' @@ -35,7 +42,15 @@ console-reports: # - 'NotificationReport' # - 'FindingsReport' # - 'FileBasedFindingsReport' - - 'LiteFindingsReport' + # - 'LiteFindingsReport' + +output-reports: + active: true + exclude: + # - 'TxtOutputReport' + # - 'XmlOutputReport' + # - 'HtmlOutputReport' + # - 'MdOutputReport' comments: active: true @@ -52,23 +67,36 @@ comments: EndOfSentenceFormat: active: false endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' + KDocReferencesNonPublicProperty: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] OutdatedDocumentation: active: false matchTypeParameters: true matchDeclarationsOrder: true + allowParamOnConstructorProperties: false UndocumentedPublicClass: - active: true + active: true # Enabled in https://github.com/mozilla-mobile/android-components/issues/76 + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] searchInNestedClass: true searchInInnerClass: true searchInInnerObject: true searchInInnerInterface: true + searchInProtectedClass: false UndocumentedPublicFunction: - active: true + active: true # Enabled in https://github.com/mozilla-mobile/android-components/issues/76 + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + searchProtectedFunction: false UndocumentedPublicProperty: active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + searchProtectedProperty: false complexity: active: true + CognitiveComplexMethod: + active: false + threshold: 15 ComplexCondition: active: true threshold: 4 @@ -77,10 +105,11 @@ complexity: threshold: 10 includeStaticDeclarations: false includePrivateDeclarations: false - ComplexMethod: + ignoreOverloaded: false + CyclomaticComplexMethod: active: true - threshold: 18 - ignoreSingleWhenExpression: true + threshold: 18 # (Default: 15) Increased in https://github.com/mozilla-mobile/android-components/pull/10328 + ignoreSingleWhenExpression: true # Enabled in https://github.com/mozilla-mobile/android-components/pull/3271 ignoreSimpleWhenEntries: false ignoreNestingFunctions: false nestingFunctions: @@ -101,12 +130,12 @@ complexity: threshold: 600 LongMethod: active: true - threshold: 75 + threshold: 75 # (Default: 60) Increased in https://github.com/mozilla-mobile/android-components/issues/6350 LongParameterList: active: true functionThreshold: 6 constructorThreshold: 7 - ignoreDefaultParameters: true + ignoreDefaultParameters: true # Enabled in https://github.com/mozilla-mobile/android-components/issues/10835 ignoreDataClasses: true ignoreAnnotatedParameter: [] MethodOverloading: @@ -115,23 +144,35 @@ complexity: NamedArguments: active: false threshold: 3 + ignoreArgumentsMatchingNames: false NestedBlockDepth: active: true threshold: 4 + NestedScopeFunctions: + active: false + threshold: 1 + functions: + - 'kotlin.apply' + - 'kotlin.run' + - 'kotlin.with' + - 'kotlin.let' + - 'kotlin.also' ReplaceSafeCallChainWithRun: active: false StringLiteralDuplication: active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] threshold: 3 ignoreAnnotation: true excludeStringsWithLessThan5Characters: true ignoreStringsRegex: '$^' TooManyFunctions: active: true - thresholdInFiles: 26 - thresholdInClasses: 26 - thresholdInInterfaces: 26 - thresholdInObjects: 26 + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + thresholdInFiles: 26 # (Default: 11) Increased in https://github.com/mozilla-mobile/android-components/pull/9927 + thresholdInClasses: 26 # (Default: 11) Increased in https://github.com/mozilla-mobile/android-components/pull/9927 + thresholdInInterfaces: 26 # (Default: 11) Increased in https://github.com/mozilla-mobile/android-components/pull/9927 + thresholdInObjects: 26 # (Default: 11) Increased in https://github.com/mozilla-mobile/android-components/pull/9927 thresholdInEnums: 11 ignoreDeprecated: false ignorePrivate: false @@ -142,17 +183,19 @@ coroutines: GlobalCoroutineUsage: active: false InjectDispatcher: - active: false + active: true dispatcherNames: - 'IO' - 'Default' - 'Unconfined' RedundantSuspendModifier: - active: false + active: true SleepInsteadOfDelay: + active: true + SuspendFunWithCoroutineScopeReceiver: active: false SuspendFunWithFlowReturnType: - active: false + active: true empty-blocks: active: true @@ -192,14 +235,15 @@ empty-blocks: exceptions: active: true ExceptionRaisedInUnexpectedLocation: - active: false + active: true methodNames: - 'equals' - 'finalize' - 'hashCode' - 'toString' InstanceOfCheckForException: - active: false + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] NotImplementedDeclaration: active: false ObjectExtendsThrowable: @@ -207,12 +251,12 @@ exceptions: PrintStackTrace: active: true RethrowCaughtException: - active: false + active: true ReturnFromFinally: active: true ignoreLabeled: false SwallowedException: - active: false + active: true ignoredExceptionTypes: - 'InterruptedException' - 'MalformedURLException' @@ -224,7 +268,8 @@ exceptions: ThrowingExceptionInMain: active: false ThrowingExceptionsWithoutMessageOrCause: - active: false + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] exceptions: - 'ArrayIndexOutOfBoundsException' - 'Exception' @@ -239,6 +284,7 @@ exceptions: active: true TooGenericExceptionCaught: active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] exceptionNames: - 'ArrayIndexOutOfBoundsException' - 'Error' @@ -262,6 +308,7 @@ naming: BooleanPropertyNaming: active: false allowedPattern: '^(is|has|are)' + ignoreOverridden: true ClassNaming: active: true classPattern: '[A-Z][a-zA-Z0-9]*' @@ -285,18 +332,20 @@ naming: minimumFunctionNameLength: 3 FunctionNaming: active: true - functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)' + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + functionPattern: '[a-z][a-zA-Z0-9]*' excludeClassPattern: '$^' ignoreOverridden: true - ignoreAnnotated: ['Composable'] + ignoreAnnotated: ['Composable'] # Configuration for Compose https://github.com/mozilla-mobile/android-components/issues/11866 FunctionParameterNaming: active: true parameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' ignoreOverridden: true InvalidPackageDeclaration: - active: false + active: true rootPackage: '' + requireRootInDeclaration: false LambdaParameterNaming: active: false parameterPattern: '[a-z][A-Za-z0-9]*|_' @@ -304,10 +353,10 @@ naming: active: true mustBeFirst: true MemberNameEqualsClassName: - active: false + active: true ignoreOverridden: true NoNameShadowing: - active: false + active: true NonBooleanPropertyPrefixedWithIs: active: false ObjectPropertyNaming: @@ -340,17 +389,24 @@ performance: active: true ArrayPrimitive: active: true + CouldBeSequence: + active: false + threshold: 3 ForEachOnRange: active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] SpreadOperator: active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + UnnecessaryPartOfBinaryExpression: + active: false UnnecessaryTemporaryInstantiation: active: true potential-bugs: active: true AvoidReferentialEquality: - active: false + active: true forbiddenTypePatterns: - 'kotlin.String' CastToNullableType: @@ -360,9 +416,18 @@ potential-bugs: DontDowncastCollectionTypes: active: false DoubleMutabilityForCollection: - active: false - DuplicateCaseInWhenExpression: active: true + mutableTypes: + - 'kotlin.collections.MutableList' + - 'kotlin.collections.MutableMap' + - 'kotlin.collections.MutableSet' + - 'java.util.ArrayList' + - 'java.util.LinkedHashSet' + - 'java.util.HashSet' + - 'java.util.LinkedHashMap' + - 'java.util.HashMap' + ElseCaseInsteadOfExhaustiveWhen: + active: false EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: @@ -372,17 +437,22 @@ potential-bugs: ExplicitGarbageCollectionCall: active: true HasPlatformType: - active: false + active: true IgnoredReturnValue: - active: false - restrictToAnnotatedMethods: true + active: true + restrictToConfig: true returnValueAnnotations: - '*.CheckResult' - '*.CheckReturnValue' ignoreReturnValueAnnotations: - '*.CanIgnoreReturnValue' + returnValueTypes: + - 'kotlin.sequences.Sequence' + - 'kotlinx.coroutines.flow.*Flow' + - 'java.util.stream.*Stream' + ignoreFunctionCall: [] ImplicitDefaultLocale: - active: false + active: true ImplicitUnitReturnType: active: false allowExplicitReturnType: true @@ -394,53 +464,62 @@ potential-bugs: active: true LateinitUsage: active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] ignoreOnClassesPattern: '' MapGetWithNotNullAssertionOperator: - active: false + active: true MissingPackageDeclaration: active: false excludes: ['**/*.kts'] - MissingWhenCase: - active: true - allowElseExpression: true + NullCheckOnMutableProperty: + active: false NullableToStringCall: active: false - RedundantElseInWhen: - active: true UnconditionalJumpStatementInLoop: active: false + UnnecessaryNotNullCheck: + active: false UnnecessaryNotNullOperator: active: true UnnecessarySafeCall: active: true UnreachableCatchBlock: - active: false + active: true UnreachableCode: active: true UnsafeCallOnNullableType: active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] UnsafeCast: active: true UnusedUnaryOperator: - active: false + active: true UselessPostfixExpression: - active: false + active: true WrongEqualsTypeParameter: active: true style: active: true + AlsoCouldBeApply: + active: false + CanBeNonNullable: + active: false + CascadingCallWrapping: + active: false + includeElvis: true ClassOrdering: active: false CollapsibleIfStatements: - active: true + active: true # Enabled in https://github.com/mozilla-mobile/android-components/pull/78 DataClassContainsFunctions: active: false - conversionFunctionPrefix: 'to' + conversionFunctionPrefix: + - 'to' DataClassShouldBeImmutable: active: false DestructuringDeclarationWithTooManyEntries: - active: false + active: true maxDestructuringEntries: 3 EqualsNullCall: active: true @@ -449,7 +528,7 @@ style: ExplicitCollectionElementAccessMethod: active: false ExplicitItLambdaParameter: - active: false + active: true ExpressionBodySyntax: active: false includeLineWrapping: false @@ -468,41 +547,35 @@ style: ForbiddenMethodCall: active: false methods: - - 'kotlin.io.print' - - 'kotlin.io.println' - ForbiddenPublicDataClass: - active: true - excludes: ['**'] - ignorePackages: - - '*.internal' - - '*.internal.*' - ForbiddenVoid: + - reason: 'print does not allow you to configure the output stream. Use a logger instead.' + value: 'kotlin.io.print' + - reason: 'println does not allow you to configure the output stream. Use a logger instead.' + value: 'kotlin.io.println' + ForbiddenSuppress: active: false + rules: [] + ForbiddenVoid: + active: true ignoreOverridden: false ignoreUsageInGenerics: false FunctionOnlyReturningConstant: active: true ignoreOverridableFunction: true ignoreActualFunction: true - excludedFunctions: '' - LibraryCodeMustSpecifyReturnType: - active: true - excludes: ['**'] - LibraryEntitiesShouldNotBePublic: - active: true - excludes: ['**'] + excludedFunctions: [] LoopWithTooManyJumpStatements: - active: false + active: true maxJumpCount: 1 MagicNumber: active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts'] ignoreNumbers: - '-1' - '0' - '1' - '2' ignoreHashCodeFunction: true - ignorePropertyDeclaration: true + ignorePropertyDeclaration: true # Enabled for Compose in https://github.com/mozilla-mobile/android-components/issues/11864 ignoreLocalVariableDeclaration: false ignoreConstantDeclaration: true ignoreCompanionObjectPropertyDeclaration: true @@ -512,29 +585,38 @@ style: ignoreRanges: false ignoreExtensionFunctions: true MandatoryBracesIfStatements: - active: true + active: true # Enabled in https://github.com/mozilla-mobile/android-components/issues/1015 MandatoryBracesLoops: active: false + MaxChainedCallsOnSameLine: + active: false + maxChainedCalls: 5 MaxLineLength: active: true maxLineLength: 120 excludePackageStatements: true excludeImportStatements: true excludeCommentStatements: false + excludeRawStrings: true MayBeConst: active: true ModifierOrder: active: true MultilineLambdaItParameter: active: false + MultilineRawStringIndentation: + active: false + indentSize: 4 NestedClassesVisibility: active: true NewLineAtEndOfFile: active: true NoTabs: - active: true - ObjectLiteralToLambda: + active: true # Enabled in https://github.com/mozilla-mobile/android-components/pull/78 + NullableBooleanCheck: active: false + ObjectLiteralToLambda: + active: true OptionalAbstractKeyword: active: true OptionalUnit: @@ -548,13 +630,14 @@ style: RedundantExplicitType: active: false RedundantHigherOrderMapUsage: - active: false + active: true RedundantVisibilityModifierRule: active: false ReturnCount: active: true - max: 3 - excludedFunctions: 'equals' + max: 3 # (Default: 2) Increased in https://github.com/mozilla-mobile/android-components/issues/3 + excludedFunctions: + - 'equals' excludeLabeled: false excludeReturnFromLambda: true excludeGuardClauses: false @@ -563,30 +646,38 @@ style: SerialVersionUIDInSerializableClass: active: true SpacingBetweenPackageAndImports: - active: true + active: true # Enabled in https://github.com/mozilla-mobile/android-components/pull/78 ThrowsCount: active: true max: 2 excludeGuardClauses: false TrailingWhitespace: active: false + TrimMultilineRawString: + active: false UnderscoresInNumericLiterals: active: false acceptableLength: 4 + allowNonStandardGrouping: false UnnecessaryAbstractClass: active: true UnnecessaryAnnotationUseSiteTarget: active: false UnnecessaryApply: active: true - UnnecessaryFilter: + UnnecessaryBackticks: active: false + UnnecessaryFilter: + active: true UnnecessaryInheritance: active: true + UnnecessaryInnerClass: + active: false UnnecessaryLet: active: false UnnecessaryParentheses: active: false + allowForUnclearPrecedence: false UntilInsteadOfRangeTo: active: false UnusedImports: @@ -596,15 +687,15 @@ style: UnusedPrivateMember: active: true allowedNames: '(_|ignored|expected|serialVersionUID)' - ignoreAnnotated: ['Composable'] + ignoreAnnotated: ['Preview'] # Configuration for Compose https://github.com/mozilla-mobile/android-components/issues/11866 UseAnyOrNoneInsteadOfFind: - active: false + active: true UseArrayLiteralsInAnnotations: - active: false + active: true UseCheckNotNull: active: true UseCheckOrError: - active: false + active: true UseDataClass: active: false allowVars: false @@ -615,19 +706,22 @@ style: UseIfInsteadOfWhen: active: false UseIsNullOrEmpty: - active: false + active: true UseOrEmpty: active: true UseRequire: active: true UseRequireNotNull: active: true + UseSumOfInsteadOfFlatMapSize: + active: false UselessCallOnNotNull: active: true UtilityClassWithPublicConstructor: active: true VarCouldBeVal: active: true + ignoreLateinitVar: false WildcardImport: active: true excludeImports: