You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iceraven-browser/mozilla-detekt-rules/src/main/java/org/mozilla/fenix/detektrules/CustomRulesetProvider.kt

29 lines
1.1 KiB
Kotlin

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.detektrules
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.RuleSet
import io.gitlab.arturbosch.detekt.api.RuleSetProvider
import org.mozilla.fenix.detektrules.perf.MozillaBannedPropertyAccess
import org.mozilla.fenix.detektrules.perf.MozillaRunBlockingCheck
import org.mozilla.fenix.detektrules.perf.MozillaStrictModeSuppression
import org.mozilla.fenix.detektrules.perf.MozillaUseLazyMonitored
class CustomRulesetProvider : RuleSetProvider {
override val ruleSetId: String = "mozilla-detekt-rules"
override fun instance(config: Config): RuleSet = RuleSet(
ruleSetId,
listOf(
MozillaBannedPropertyAccess(config),
MozillaStrictModeSuppression(config),
[fenix] 15278 detekt rule runblocking (https://github.com/mozilla-mobile/fenix/pull/15942) * For https://github.com/mozilla-mobile/fenix/issues/15278: added CoroutineManager to count runBlocking calls * For https://github.com/mozilla-mobile/fenix/issues/15278: Added actual detekt rule for runblocking and its config to the yaml * For https://github.com/mozilla-mobile/fenix/issues/15278: Added unit test for RunblockingCounter * For https://github.com/mozilla-mobile/fenix/issues/15278: renamed StrictModeStartupSuppressionCountTest.kt to PerformanceStartupTest.kt and added runBlockingCount test * Lint fix * For https://github.com/mozilla-mobile/fenix/issues/15278: made runblocking a Long to prevent overflow * For https://github.com/mozilla-mobile/fenix/issues/15278: fixed MozRunblocking name, description and moved RunBlockingCounter to perf package * For https://github.com/mozilla-mobile/fenix/issues/15278:Renamed MozillaRunblockingCheck to MozillaRunBlockingCheck * For https://github.com/mozilla-mobile/fenix/issues/15278: Added setup for unit test, since it failed without restting counter * For https://github.com/mozilla-mobile/fenix/issues/15278: Fixed naming for RunBlocking lint check * For https://github.com/mozilla-mobile/fenix/issues/15278: removed changes made to test to use runBlockingIncrement * For https://github.com/mozilla-mobile/fenix/issues/15728: added test exclusion for runBlocking check * For https://github.com/mozilla-mobile/fenix/issues/15278: changed null check and added Synchronized to count setter * For https://github.com/mozilla-mobile/fenix/issues/15278: fix for nits * For https://github.com/mozilla-mobile/fenix/issues/15278: added StartupExcessiveResourceUseTest to CODEOWNERS * For https://github.com/mozilla-mobile/fenix/issues/15278: fixed for nits * For https://github.com/mozilla-mobile/fenix/issues/15278: Moved increment function to extension function and fixed indentation * For https://github.com/mozilla-mobile/fenix/issues/15278: Added tests for Atomic Integer extension and nit fix
4 years ago
MozillaCorrectUnitTestRunner(config),
MozillaRunBlockingCheck(config),
[fenix] 16900 make navgraph inflation asynchronous (https://github.com/mozilla-mobile/fenix/pull/18889) * For https://github.com/mozilla-mobile/fenix/issues/16900: implement async navgraph inflation For https://github.com/mozilla-mobile/fenix/issues/16900: removed nav graph from xml For https://github.com/mozilla-mobile/fenix/issues/16900: inflate navGraph programatically For https://github.com/mozilla-mobile/fenix/issues/16900: Made NavGraph inflation asynchronous For https://github.com/mozilla-mobile/fenix/issues/16900: Changed to block with runBlocking For https://github.com/mozilla-mobile/fenix/issues/16900: Refactored blocking call into a function For 16900: NavGraph inflation is now async We now attach the nav graph (or check if its attached) on every nav call ( an extension function for NavController). This is done by checking the value of the job stored in PerfNavController.map which keeps track of the job with the NavController as a Key. If the job hasn't been completed, it will block the main thread until the job is done. The job itself is responsible for attaching the navgraph to the navcontroller (and the inflation of the latter too) For 16900: rebased upstream master For 16900: Rebase on master For https://github.com/mozilla-mobile/fenix/issues/16900: Fixed Async Navgraph navigation per review comments. 1)The Asynchronous method is now found in NavGraphProvider.kt. It creates a job on the IO dispatcher 2)The Job is tracked through a WeakHashMap from Controller --> NavGraph 3)The Coroutine scope doesn't use MainScope() anymore 4)The Coroutine is cancelled if the Activity is destroyed 5)The tests mockk the blockForNavGraphInflation method through the FenixReoboelectricTestApplication instead of calling the mock every setup() For https://github.com/mozilla-mobile/fenix/issues/16900: inflateNavGraphAsync now takes navController For https://github.com/mozilla-mobile/fenix/issues/16900: Pass lifecycleScope to NavGraphProvider For https://github.com/mozilla-mobile/fenix/issues/16900: removed unused mock For https://github.com/mozilla-mobile/fenix/issues/16900: Added linter rules for navigate calls We need linting rules to make sure no one calls the NavController.navigate() methods For https://github.com/mozilla-mobile/fenix/issues/16900: Added TestRule to help abstract the mocks in the code For 16900: Fix linting problems For https://github.com/mozilla-mobile/fenix/issues/16900: Cleaned duplicated code in tests For https://github.com/mozilla-mobile/fenix/issues/16900: cleaned up NavGraphTestRule for finished test For https://github.com/mozilla-mobile/fenix/issues/16900: had to revert an accidentally edited file For https://github.com/mozilla-mobile/fenix/issues/16900: rebased master * For https://github.com/mozilla-mobile/fenix/issues/16900: Review nits for async navgraph This is composed of squash commits, the original messages can be found below: -> DisableNavGraphProviderAssertionRule + kdoc. Use test rule in RobolectricApplication. Fix failing CrashReporterControllerTest Fix blame by -> navigate in tests. This commit was generated by the following commands only: ``` find app/src/test -type f -exec sed -i '' "/import org.mozilla.fenix.ext.navigateBlockingForAsyncNavGraph/d" {} \; find app/src/test -type f -exec sed -i "" "s/navigateBlockingForAsyncNavGraph/navigate/g" {} \; git checkout app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker ``` Fix various blame This is expected to be squashed into the first commit so, if so, it'd fix the blame. Move test rule to helpers pkg. add missing license header Add import change I missed fix unused imports Replace robolectricTestrunner with test rule. Improve navGraphProvider docs Remove unnecessary rule as defined by robolectric. add clarifying comment to robolectric remove unnecessary space * For https://github.com/mozilla-mobile/fenix/issues/16900: nit fixes for MozillaNavigateCheck and lint fixes 3 squash commits: *Changed violation message and fixed the lint rule for MozillaNavigateCheck *Added suppression to NavController.kt *Fixed detekt violations * For 16900: Fixed failing tests Co-authored-by: Michael Comella <michael.l.comella@gmail.com>
3 years ago
MozillaUseLazyMonitored(config),
),
)
}