1
0
Fork 0

For #4326 - Updates codebase to support latest version of detekt

master
Jeff Boek 2019-08-21 10:52:09 -07:00
parent e601fe7c9f
commit 68f5d211d3
10 changed files with 46 additions and 45 deletions

View File

@ -145,7 +145,7 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
browserInitialized = initializeUI(view) != null
}
@Suppress("ComplexMethod")
@Suppress("ComplexMethod", "LongMethod")
@CallSuper
protected open fun initializeUI(view: View): Session? {
val sessionManager = requireComponents.core.sessionManager

View File

@ -56,7 +56,7 @@ import org.mozilla.fenix.quickactionsheet.QuickActionSheetView
*/
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
@Suppress("TooManyFunctions")
@Suppress("TooManyFunctions", "LargeClass")
class BrowserFragment : BaseBrowserFragment(), BackHandler {
private lateinit var quickActionSheetView: QuickActionSheetView
private var quickActionSheetSessionObserver: QuickActionSheetSessionObserver? = null

View File

@ -34,6 +34,7 @@ import org.mozilla.fenix.home.sessioncontrol.Tab
import org.mozilla.fenix.home.sessioncontrol.TabCollection
import org.mozilla.fenix.mvi.UIView
@SuppressWarnings("LargeClass")
class CollectionCreationUIView(
container: ViewGroup,
actionEmitter: Observer<CollectionCreationAction>,
@ -104,7 +105,7 @@ class CollectionCreationUIView(
}
}
@Suppress("ComplexMethod")
@Suppress("ComplexMethod", "LongMethod")
override fun updateView() = Consumer<CollectionCreationState> {
step = it.saveCollectionStep
selectedTabs = it.selectedTabs
@ -231,17 +232,16 @@ class CollectionCreationUIView(
}, TRANSITION_DURATION)
}
transition.addListener(object : Transition.TransitionListener {
override fun onTransitionStart(transition: Transition) {
}
override fun onTransitionStart(transition: Transition) { /* noop */ }
override fun onTransitionEnd(transition: Transition) {
view.name_collection_edittext.showKeyboard()
transition.removeListener(this)
}
override fun onTransitionCancel(transition: Transition) {}
override fun onTransitionPause(transition: Transition) {}
override fun onTransitionResume(transition: Transition) {}
override fun onTransitionCancel(transition: Transition) { /* noop */ }
override fun onTransitionPause(transition: Transition) { /* noop */ }
override fun onTransitionResume(transition: Transition) { /* noop */ }
})
TransitionManager.beginDelayedTransition(
view.collection_constraint_layout,
@ -289,17 +289,16 @@ class CollectionCreationUIView(
}, TRANSITION_DURATION)
}
transition.addListener(object : Transition.TransitionListener {
override fun onTransitionStart(transition: Transition) {
}
override fun onTransitionStart(transition: Transition) { /* noop */ }
override fun onTransitionEnd(transition: Transition) {
view.name_collection_edittext.showKeyboard()
transition.removeListener(this)
}
override fun onTransitionCancel(transition: Transition) {}
override fun onTransitionPause(transition: Transition) {}
override fun onTransitionResume(transition: Transition) {}
override fun onTransitionCancel(transition: Transition) { /* noop */ }
override fun onTransitionPause(transition: Transition) { /* noop */ }
override fun onTransitionResume(transition: Transition) { /* noop */ }
})
TransitionManager.beginDelayedTransition(
view.collection_constraint_layout,

View File

@ -45,7 +45,7 @@ class AdjustMetricsService(private val application: Application) : MetricsServic
}
// We're not currently sending events directly to Adjust
override fun track(event: Event) { }
override fun track(event: Event) { /* noop */ }
override fun shouldTrack(event: Event): Boolean = false
companion object {
@ -61,14 +61,14 @@ class AdjustMetricsService(private val application: Application) : MetricsServic
Adjust.onPause()
}
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { /* noop */ }
override fun onActivityStarted(activity: Activity) {}
override fun onActivityStarted(activity: Activity) { /* noop */ }
override fun onActivityStopped(activity: Activity) {}
override fun onActivityStopped(activity: Activity) { /* noop */ }
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { /* noop */ }
override fun onActivityDestroyed(activity: Activity) {}
override fun onActivityDestroyed(activity: Activity) { /* noop */ }
}
}

View File

@ -63,7 +63,7 @@ class DefaultBrowserToolbarController(
@ExperimentalCoroutinesApi
@ObsoleteCoroutinesApi
@SuppressWarnings("ComplexMethod")
@SuppressWarnings("ComplexMethod", "LongMethod")
override fun handleToolbarItemInteraction(item: ToolbarMenu.Item) {
val sessionUseCases = context.components.useCases.sessionUseCases
trackToolbarItemInteraction(item)

View File

@ -303,7 +303,7 @@ class HomeFragment : Fragment(), AccountObserver {
}
}
@SuppressWarnings("ComplexMethod")
@SuppressWarnings("ComplexMethod", "LongMethod")
private fun handleTabAction(action: TabAction) {
Do exhaustive when (action) {
is TabAction.SaveTabGroup -> {
@ -423,6 +423,7 @@ class HomeFragment : Fragment(), AccountObserver {
}
}
@SuppressWarnings("LongMethod")
private fun handleCollectionAction(action: CollectionAction) {
when (action) {
is CollectionAction.Expand -> {
@ -801,8 +802,8 @@ class HomeFragment : Fragment(), AccountObserver {
border?.visibility = View.GONE
}
override fun onAnimationStart(animation: Animator?) {}
override fun onAnimationRepeat(animation: Animator?) {}
override fun onAnimationStart(animation: Animator?) { /* noop */ }
override fun onAnimationRepeat(animation: Animator?) { /* noop */ }
override fun onAnimationEnd(animation: Animator?) {
border?.animate()?.alpha(0.0F)?.setStartDelay(ANIM_ON_SCREEN_DELAY)
?.setDuration(FADE_ANIM_DURATION)

View File

@ -35,7 +35,7 @@ class HistoryDataSource(
}
}
override fun loadBefore(params: LoadParams<Int>, callback: LoadCallback<HistoryItem>) {}
override fun loadBefore(params: LoadParams<Int>, callback: LoadCallback<HistoryItem>) { /* noop */ }
companion object {
private const val INITIAL_OFFSET = 0L

View File

@ -249,7 +249,7 @@ open class QuickActionSheetBehavior<V : View>(context: Context, attrs: Attribute
}
}
@Suppress("ComplexCondition")
@Suppress("ComplexCondition", "LongMethod")
override fun onViewReleased(releasedChild: View, xvel: Float, yvel: Float) {
val top: Int
@State val targetState: Int

View File

@ -58,6 +58,9 @@ detekt {
enabled = true
destination = file("$projectDir/build/reports/detekt.html")
}
xml {
enabled = false
}
}
}

View File

@ -1,24 +1,6 @@
autoCorrect: true
failFast: false
test-pattern: # Configure exclusions for test sources
active: true
patterns: # Test file regexes
- '.*/test/.*'
- '.*Test.kt'
- '.*Spec.kt'
exclude-rule-sets:
- 'comments'
exclude-rules:
- 'NamingRules'
- 'WildcardImport'
- 'MagicNumber'
- 'MaxLineLength'
- 'LateinitUsage'
- 'StringLiteralDuplication'
- 'SpreadOperator'
- 'TooManyFunctions'
build:
maxIssues: 0
weights:
@ -54,6 +36,7 @@ output-reports:
comments:
active: true
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
CommentOverPrivateFunction:
active: false
CommentOverPrivateProperty:
@ -87,10 +70,16 @@ complexity:
active: false
LargeClass:
active: true
threshold: 150
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
# Had to increase the threshold as RC13 started counting lines of code
# https://github.com/mozilla-mobile/fenix/issues/4861
threshold: 200
LongMethod:
active: true
threshold: 20
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
# Had to increase the threshold as RC13 started counting lines of code
# https://github.com/mozilla-mobile/fenix/issues/4861
threshold: 75
LongParameterList:
active: true
threshold: 6
@ -103,12 +92,14 @@ complexity:
threshold: 4
StringLiteralDuplication:
active: false
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
threshold: 3
ignoreAnnotation: true
excludeStringsWithLessThan5Characters: true
ignoreStringsRegex: '$^'
TooManyFunctions:
active: true
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
thresholdInFiles: 11
thresholdInClasses: 11
thresholdInInterfaces: 11
@ -134,6 +125,7 @@ empty-blocks:
active: true
EmptyFunctionBlock:
active: true
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
EmptyIfBlock:
active: true
EmptyInitBlock:
@ -211,6 +203,7 @@ naming:
minimumFunctionNameLength: 3
FunctionNaming:
active: true
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern: '$^'
MatchingDeclarationName:
@ -247,6 +240,7 @@ performance:
active: true
SpreadOperator:
active: true
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
UnnecessaryTemporaryInstantiation:
active: true
@ -268,6 +262,7 @@ potential-bugs:
active: false
LateinitUsage:
active: false
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
excludeAnnotatedProperties: ""
ignoreOnClassesPattern: ""
UnconditionalJumpStatementInLoop:
@ -309,6 +304,7 @@ style:
maxJumpCount: 1
MagicNumber:
active: true
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
ignoreNumbers: '-1,0,1,2'
ignoreHashCodeFunction: false
ignorePropertyDeclaration: false
@ -319,6 +315,7 @@ style:
ignoreEnums: false
MaxLineLength:
active: true
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
maxLineLength: 120
excludePackageStatements: false
excludeImportStatements: false
@ -376,4 +373,5 @@ style:
active: false
WildcardImport:
active: true
excludes: "**/*Test.kt, **/*Spec.kt, **/test/**, **/androidTest/**"
excludeImports: 'java.util.*,kotlinx.android.synthetic.*'