No issue: Adds lint exception for when statement (#3685)
parent
309014139d
commit
4994554576
|
@ -77,7 +77,6 @@ class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
private fun getRiskLevel(errorType: ErrorType): RiskLevel {
|
||||
return when (errorType) {
|
||||
// Low risk errors
|
||||
|
|
|
@ -65,7 +65,6 @@ class BrowserToolbarBottomBehavior(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
override fun onStopNestedScroll(
|
||||
coordinatorLayout: CoordinatorLayout,
|
||||
child: BrowserToolbar,
|
||||
|
@ -73,7 +72,7 @@ class BrowserToolbarBottomBehavior(
|
|||
type: Int
|
||||
) {
|
||||
if (shouldSnapAfterScroll || type == TYPE_NON_TOUCH) {
|
||||
if (child.translationY >= (child.height * 0.5f)) {
|
||||
if (child.translationY >= (child.height / 2f)) {
|
||||
animateSnap(child, SnapDirection.DOWN)
|
||||
} else {
|
||||
animateSnap(child, SnapDirection.UP)
|
||||
|
@ -108,7 +107,6 @@ class BrowserToolbarBottomBehavior(
|
|||
start()
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun positionSnackbar(view: View) {
|
||||
val params = view.layoutParams as CoordinatorLayout.LayoutParams
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ class BrowserToolbarTopBehavior(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
override fun onStopNestedScroll(
|
||||
coordinatorLayout: CoordinatorLayout,
|
||||
child: BrowserToolbar,
|
||||
|
@ -73,7 +72,7 @@ class BrowserToolbarTopBehavior(
|
|||
type: Int
|
||||
) {
|
||||
if (shouldSnapAfterScroll || type == TYPE_NON_TOUCH) {
|
||||
if (child.translationY >= (-child.height * 0.5f)) {
|
||||
if (child.translationY >= (-child.height / 2f)) {
|
||||
animateSnap(child, SnapDirection.DOWN)
|
||||
} else {
|
||||
animateSnap(child, SnapDirection.UP)
|
||||
|
@ -108,7 +107,6 @@ class BrowserToolbarTopBehavior(
|
|||
start()
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun positionSnackbar(view: View) {
|
||||
val params = view.layoutParams as CoordinatorLayout.LayoutParams
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.reactivex.Observer
|
||||
import kotlinx.android.synthetic.main.collections_list_item.view.*
|
||||
import kotlinx.android.synthetic.main.collections_list_item.view.collection_description
|
||||
import kotlinx.android.synthetic.main.collections_list_item.view.collection_icon
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
|
@ -94,7 +92,7 @@ class CollectionViewHolder(
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod", "MagicNumber")
|
||||
@Suppress("MagicNumber")
|
||||
private fun getIconColor(id: Long): Int {
|
||||
return when ((id % 5).toInt()) {
|
||||
0 -> R.color.collection_icon_color_violet
|
||||
|
|
|
@ -234,7 +234,6 @@ sealed class Event {
|
|||
get() = null
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
private fun Fact.toEvent(): Event? = when (Pair(component, item)) {
|
||||
Component.FEATURE_FINDINPAGE to "previous" -> Event.FindInPagePrevious
|
||||
Component.FEATURE_FINDINPAGE to "next" -> Event.FindInPageNext
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.mozilla.fenix.R
|
|||
|
||||
var rootTitles: Map<String, String> = emptyMap()
|
||||
|
||||
@SuppressWarnings("ReturnCount", "ComplexMethod")
|
||||
@SuppressWarnings("ComplexMethod")
|
||||
suspend fun BookmarkNode?.withOptionalDesktopFolders(
|
||||
context: Context?,
|
||||
showMobileRoot: Boolean = false
|
||||
|
@ -25,7 +25,7 @@ suspend fun BookmarkNode?.withOptionalDesktopFolders(
|
|||
val loggedIn = context?.components?.backgroundServices?.accountManager?.authenticatedAccount() != null
|
||||
|
||||
// If we're in the mobile root and logged in, add-in a synthetic "Desktop Bookmarks" folder.
|
||||
if ((this.guid == BookmarkRoot.Mobile.id) && loggedIn) {
|
||||
return if (guid == BookmarkRoot.Mobile.id && loggedIn) {
|
||||
// We're going to make a copy of the mobile node, and add-in a synthetic child folder to the top of the
|
||||
// children's list that contains all of the desktop roots.
|
||||
val childrenWithVirtualFolder: MutableList<BookmarkNode> = mutableListOf()
|
||||
|
@ -35,21 +35,20 @@ suspend fun BookmarkNode?.withOptionalDesktopFolders(
|
|||
childrenWithVirtualFolder.addAll(children)
|
||||
}
|
||||
|
||||
return this.copy(children = childrenWithVirtualFolder)
|
||||
} else if (this.guid == BookmarkRoot.Root.id) {
|
||||
return this.copy(
|
||||
copy(children = childrenWithVirtualFolder)
|
||||
} else if (guid == BookmarkRoot.Root.id) {
|
||||
copy(
|
||||
title = rootTitles[this.title],
|
||||
children = if (showMobileRoot) restructureMobileRoots(context, children)
|
||||
else restructureDesktopRoots(children)
|
||||
)
|
||||
|
||||
} else if (guid in listOf(BookmarkRoot.Menu.id, BookmarkRoot.Toolbar.id, BookmarkRoot.Unfiled.id)) {
|
||||
// If we're looking at one of the desktop roots, change their titles to friendly names.
|
||||
} else if (this.guid in listOf(BookmarkRoot.Menu.id, BookmarkRoot.Toolbar.id, BookmarkRoot.Unfiled.id)) {
|
||||
return this.copy(title = rootTitles[this.title])
|
||||
}
|
||||
|
||||
copy(title = rootTitles[this.title])
|
||||
} else {
|
||||
// Otherwise, just return the node as-is.
|
||||
return this
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun virtualDesktopFolder(context: Context?): BookmarkNode? {
|
||||
|
|
|
@ -295,7 +295,6 @@ class HomeFragment : Fragment(), AccountObserver {
|
|||
requireComponents.backgroundServices.accountManager.register(this, owner = this)
|
||||
}
|
||||
|
||||
@SuppressWarnings("ComplexMethod")
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
requireComponents.core.tabCollectionStorage.register(collectionStorageObserver, this)
|
||||
|
@ -441,7 +440,6 @@ class HomeFragment : Fragment(), AccountObserver {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
private fun handleCollectionAction(action: CollectionAction) {
|
||||
when (action) {
|
||||
is CollectionAction.Expand -> {
|
||||
|
|
|
@ -128,7 +128,6 @@ class SwipeToDeleteCallback(
|
|||
const val MARGIN = 32
|
||||
const val DENSITY_CONVERSION = 160f
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
private fun draw(
|
||||
background: Drawable,
|
||||
icon: Drawable,
|
||||
|
|
|
@ -117,7 +117,7 @@ class CollectionViewHolder(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod", "MagicNumber")
|
||||
@Suppress("MagicNumber")
|
||||
private fun getIconColor(id: Long): Int {
|
||||
val sessionColorIndex = (id % 5).toInt()
|
||||
return when (sessionColorIndex) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.mozilla.fenix.ext.increaseTapArea
|
|||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkAction>) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
RecyclerView.Adapter<BookmarkAdapter.BookmarkNodeViewHolder>() {
|
||||
|
||||
private var tree: List<BookmarkNode> = listOf()
|
||||
private var mode: BookmarkState.Mode = BookmarkState.Mode.Normal
|
||||
|
@ -50,7 +50,7 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
|
|||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookmarkNodeViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.bookmark_row, parent, false)
|
||||
|
||||
return when (viewType) {
|
||||
|
@ -88,25 +88,12 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
|
|||
|
||||
override fun getItemCount(): Int = tree.size
|
||||
|
||||
@SuppressWarnings("ComplexMethod")
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
|
||||
when (holder) {
|
||||
is BookmarkItemViewHolder -> holder.bind(
|
||||
override fun onBindViewHolder(holder: BookmarkNodeViewHolder, position: Int) {
|
||||
holder.bind(
|
||||
tree[position],
|
||||
mode,
|
||||
tree[position] in selected
|
||||
)
|
||||
is BookmarkFolderViewHolder -> holder.bind(
|
||||
tree[position],
|
||||
mode,
|
||||
tree[position] in selected
|
||||
)
|
||||
is BookmarkSeparatorViewHolder -> holder.bind(
|
||||
tree[position], mode,
|
||||
tree[position] in selected
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
open class BookmarkNodeViewHolder(
|
||||
|
|
|
@ -286,7 +286,6 @@ class BookmarkFragment : Fragment(), BackHandler, AccountObserver {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ComplexMethod")
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.libraryClose -> {
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.mozilla.fenix.ext.getColorIntFromAttr
|
|||
import org.mozilla.fenix.library.bookmarks.BookmarksSharedViewModel
|
||||
|
||||
class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedViewModel) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
RecyclerView.Adapter<SelectBookmarkFolderAdapter.BookmarkFolderViewHolder>() {
|
||||
|
||||
private var tree: List<BookmarkNodeWithDepth> = listOf()
|
||||
|
||||
|
@ -29,7 +29,7 @@ class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedVi
|
|||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookmarkFolderViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.bookmark_row, parent, false)
|
||||
|
||||
return when (viewType) {
|
||||
|
@ -49,11 +49,8 @@ class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedVi
|
|||
|
||||
override fun getItemCount(): Int = tree.size
|
||||
|
||||
@SuppressWarnings("ComplexMethod")
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
|
||||
when (holder) {
|
||||
is SelectBookmarkFolderAdapter.BookmarkFolderViewHolder -> holder.bind(
|
||||
override fun onBindViewHolder(holder: BookmarkFolderViewHolder, position: Int) {
|
||||
holder.bind(
|
||||
tree[position],
|
||||
tree[position].node == sharedViewModel.selectedFolder,
|
||||
object : SelectionInterface {
|
||||
|
@ -66,10 +63,8 @@ class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedVi
|
|||
}
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
})
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
interface SelectionInterface {
|
||||
|
|
|
@ -113,7 +113,6 @@ class HistoryFragment : Fragment(), BackHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
|
||||
R.id.share_history_multi_select -> {
|
||||
val selectedHistory = (historyComponent.uiView as HistoryUIView).getSelected()
|
||||
|
@ -177,7 +176,6 @@ class HistoryFragment : Fragment(), BackHandler {
|
|||
|
||||
override fun onBackPressed(): Boolean = (historyComponent.uiView as HistoryUIView).onBackPressed()
|
||||
|
||||
@SuppressWarnings("ComplexMethod")
|
||||
private fun handleNewHistoryAction(action: HistoryAction) {
|
||||
when (action) {
|
||||
is HistoryAction.Open ->
|
||||
|
|
|
@ -82,7 +82,7 @@ complexity:
|
|||
ComplexMethod:
|
||||
active: true
|
||||
threshold: 10
|
||||
ignoreSingleWhenExpression: false
|
||||
ignoreSingleWhenExpression: true
|
||||
LabeledExpression:
|
||||
active: false
|
||||
LargeClass:
|
||||
|
|
Loading…
Reference in New Issue