Skip to content

Commit

Permalink
Closes mozilla-mobile#4004 - Increase limit for LongMethod rule
Browse files Browse the repository at this point in the history
  • Loading branch information
NotWoods committed Aug 2, 2019
1 parent b387969 commit ca3eff8
Show file tree
Hide file tree
Showing 35 changed files with 95 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ class GeckoEngineSession(
}
}

@Suppress("LongMethod")
private fun ContentBlocking.BlockEvent.toTracker(): Tracker {
val blockedContentCategories = ArrayList<Tracker.Category>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ class GeckoEngineSession(
}
}

@Suppress("LongMethod")
private fun ContentBlocking.BlockEvent.toTracker(): Tracker {
val blockedContentCategories = ArrayList<Tracker.Category>()

Expand Down Expand Up @@ -698,7 +697,6 @@ class GeckoEngineSession(
}
}

@Suppress("LongMethod")
private fun createGeckoSession(shouldOpen: Boolean = true) {
this.geckoSession = geckoSessionProvider()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
}
}

@Suppress("LongMethod")
override fun onFilePrompt(
session: GeckoSession,
title: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ class GeckoEngineSession(
}
}

@Suppress("LongMethod")
private fun ContentBlocking.BlockEvent.toTracker(): Tracker {
val blockedContentCategories = ArrayList<Tracker.Category>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ class BrowserIcons(
loadIntoViewInternal(WeakReference(view), request, placeholder, error)
}

@Suppress("LongMethod")
@MainThread
private suspend fun loadIntoViewInternal(
view: WeakReference<ImageView>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class DefaultIconGenerator(
@ArrayRes private val backgroundColorsRes: Int = R.array.mozac_browser_icons_photon_palette
) : IconGenerator {

@Suppress("LongMethod")
override fun generate(context: Context, request: IconRequest): Icon {
val size = context.resources.getDimension(request.size.dimen)
val sizePx = size.toInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class AdaptiveIconProcessor : IconProcessor {
* Creates an adaptive icon using the base icon.
* On older devices, non-maskable icons are not transformed.
*/
@Suppress("LongMethod")
override fun process(
context: Context,
request: IconRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class BrowserMenuHighlightableItem(
}
}

@Suppress("LongMethod")
private fun updateHighlight(view: View, isHighlighted: Boolean) {
val highlightImageView = view.findViewById<AppCompatImageView>(R.id.highlight_image)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class LegacySessionManager(
addInternal(session, selected, engineSession, parent = parent, viaRestore = false)
}

@Suppress("LongParameterList", "ComplexMethod", "LongMethod")
@Suppress("LongParameterList", "ComplexMethod")
private fun addInternal(
session: Session,
selected: Boolean = false,
Expand Down Expand Up @@ -429,7 +429,6 @@ class LegacySessionManager(
*
* Its implementation is synchronized with the behavior in `TabListReducer` of the `browser-state` component.
*/
@Suppress("LongMethod") // Yes, this method is pretty long. I hope we can delete it soon.
private fun findNearbySession(index: Int, predicate: (Session) -> Boolean): Int {
// Okay, this is a bit stupid and complex. This implementation intends to implement the same behavior we use in
// BrowserStore - which is operating on a list without custom tabs. Since LegacySessionManager uses a list with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ data class CustomTabConfig(
"createCustomTabConfigFromIntent(intent.unsafe)",
"mozilla.components.feature.customtabs.createCustomTabConfigFromIntent"
))
@Suppress("LongMethod", "ComplexMethod")
@Suppress("ComplexMethod")
fun createFromIntent(intent: SafeIntent, displayMetrics: DisplayMetrics? = null): CustomTabConfig {
val id = UUID.randomUUID().toString()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import android.net.Uri
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import androidx.annotation.VisibleForTesting
import androidx.browser.customtabs.CustomTabsService
import androidx.browser.customtabs.CustomTabsService.RELATION_HANDLE_ALL_URLS
import androidx.browser.customtabs.CustomTabsService.RELATION_USE_AS_ORIGIN
import androidx.browser.customtabs.CustomTabsService.Relation
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.withContext
import mozilla.components.concept.fetch.Client
Expand All @@ -27,16 +27,13 @@ import java.security.cert.X509Certificate
/**
* Used to verify postMessage origin for a designated package name.
*
* Uses Digital Asset Links to confirm that the given origin is associated with the package name as
* a postMessage origin. It caches any origin that has been verified during the current application
* Uses Digital Asset Links to confirm that the given origin is associated with the package name.
* It caches any origin that has been verified during the current application
* lifecycle and reuses that without making any new network requests.
*
* The lifecycle of this object is governed by the owner. The owner has to call
* {@link OriginVerifier#cleanUp()} for proper cleanup of dependencies.
*/
class OriginVerifier(
private val packageName: String,
@CustomTabsService.Relation private val relation: Int,
@Relation private val relation: Int,
packageManager: PackageManager,
httpClient: Client
) {
Expand All @@ -56,7 +53,7 @@ class OriginVerifier(
*/
suspend fun verifyOrigin(origin: Uri) = withContext(IO) { verifyOriginInternal(origin) }

@Suppress("LongMethod", "ReturnCount")
@Suppress("ReturnCount")
private fun verifyOriginInternal(origin: Uri): Boolean {
val cachedOrigin = cachedOriginMap[packageName]
if (cachedOrigin == origin) return true
Expand Down Expand Up @@ -112,7 +109,7 @@ class OriginVerifier(

private val cachedOriginMap = mutableMapOf<String, Uri>()

@Suppress("PackageManagerGetSignatures", "Deprecation", "LongMethod")
@Suppress("PackageManagerGetSignatures", "Deprecation")
// https://stackoverflow.com/questions/39192844/android-studio-warning-when-using-packagemanager-get-signatures
private fun PackageManager.getSignature(packageName: String): Signature? {
val packageInfo = try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import androidx.core.content.getSystemService
* Deprecated in Android Q, use MediaStore on that version.
*/
@TargetApi(Build.VERSION_CODES.P)
@Suppress("Deprecation", "LongParameterList", "LongMethod")
@Suppress("Deprecation", "LongParameterList")
internal fun Context.addCompletedDownload(
title: String,
description: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ internal class AudioFocus(
}

@Synchronized
@Suppress("LongMethod")
override fun onAudioFocusChange(focusChange: Int) {
val state = MediaStateMachine.state

Expand Down Expand Up @@ -95,7 +94,6 @@ internal class AudioFocus(
}
}

@Suppress("LongMethod")
private fun requestAudioFocusCompat(
context: Context,
listener: AudioManager.OnAudioFocusChangeListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ internal class MediaNotification(
}
}

@Suppress("LongMethod")
private fun MediaState.toNotificationData(context: Context): NotificationData {
return when (this) {
is MediaState.Playing -> NotificationData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ internal class ColorViewHolder(
itemView.setOnClickListener(this)
}

@Suppress("LongMethod")
fun bind(colorItem: ColorItem) {
// Save the color for the onClick callback
color = colorItem.color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ internal class FilePicker private constructor(
*/
private var captureUri: Uri? = null

@Suppress("LongMethod")
fun handleFileRequest(promptRequest: File, requestPermissions: Boolean = true) {
// Track which permissions are needed.
val neededPermissions = mutableListOf<String>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ internal class MonthAndYearPicker @JvmOverloads constructor(
iniYearView()
}

@Suppress("LongMethod")
override fun onValueChange(view: NumberPicker, oldVal: Int, newVal: Int) {
var month = 0
var year = 0
Expand Down
1 change: 1 addition & 0 deletions components/feature/pwa/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
implementation project(':browser-session')
implementation project(':concept-engine')
implementation project(':concept-fetch')
implementation project(':feature-customtabs')
implementation project(':feature-session')
implementation project(':support-base')
implementation project(':support-ktx')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class WebAppShortcutManager(
*
* This version has its own cache to avoid affecting tab icons.
*/
@Suppress("LongMethod")
private fun webAppIcons(
context: Context,
httpClient: Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class WebAppSiteControlsFeature(
/**
* Build the notification with site controls to be displayed while the web app is active.
*/
@Suppress("LongMethod")
private fun buildNotification(): Notification {
val channelId = ensureChannelExists()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class QrFragment : Fragment() {
* @param width The width of available size for camera preview
* @param height The height of available size for camera preview
*/
@Suppress("ComplexMethod", "LongMethod")
@Suppress("ComplexMethod")
internal fun setUpCameraOutputs(width: Int, height: Int) {
val manager = activity?.getSystemService(Context.CAMERA_SERVICE) as CameraManager? ?: return

Expand Down Expand Up @@ -364,7 +364,6 @@ class QrFragment : Fragment() {
* @param viewWidth The width of `textureView`
* @param viewHeight The height of `textureView`
*/
@Suppress("LongMethod")
private fun configureTransform(viewWidth: Int, viewHeight: Int) {
val activity = activity ?: return
val size = previewSize ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ open class FxaAccountManager(
*
* @param config Sync behaviour configuration, see [SyncConfig].
*/
@SuppressWarnings("LongMethod")
fun setSyncConfigAsync(config: SyncConfig): Deferred<Unit> = synchronized(this) {
logger.info("Enabling/updating sync with a new SyncConfig: $config")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package mozilla.components.service.fxa.sharing

import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.content.Context
import android.content.pm.PackageManager
Expand Down Expand Up @@ -77,8 +76,7 @@ object AccountSharing {
}
}

@Suppress("LongMethod")
@SuppressLint("Recycle")
@Suppress("Recycle")
private fun queryForAccount(context: Context, packageName: String): ShareableAccount? {
// assuming a certain formatting for all authorities from all sources
val authority = "$packageName.fxa.auth"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class WorkManagerSyncWorker(
return lastSyncedTs != 0L && (System.currentTimeMillis() - lastSyncedTs) < SYNC_STAGGER_BUFFER_MS
}

@Suppress("ReturnCount", "LongMethod")
@Suppress("ReturnCount")
override suspend fun doWork(): Result {
logger.debug("Starting sync... Tagged as: ${params.tags}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ open class GleanInternalAPI internal constructor () {
* as shared preferences
* @param configuration A Glean [Configuration] object with global settings.
*/
@Suppress("LongMethod")
fun initialize(
applicationContext: Context,
configuration: Configuration = Configuration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ object ErrorRecording {
* @param logger The [Logger] instance to display the warning.
* @param numErrors The optional number of errors to report for this [ErrorType].
*/
@Suppress("LongMethod")
internal fun recordError(
metricData: CommonMetricData,
errorType: ErrorType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ data class TimespanMetricType(
*
* @param elapsedNanos The elapsed time to record, in nanoseconds.
*/
@Suppress("LongMethod")
fun setRawNanos(elapsedNanos: Long) {
if (!shouldRecord(logger)) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ internal open class TimespansStorageEngineImplementation(
* @param timeUnit the time unit we want the data in when snapshotting
* @param elapsedNanos the time to record, in nanoseconds
*/
@Suppress("LongMethod")
@Synchronized
fun set(
metricData: CommonMetricData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ internal open class TimingDistributionsStorageEngineImplementation(
* be truncated nor converted)
* @param timeUnit the [TimeUnit] the samples are in
*/
@Suppress("LongMethod")
@Synchronized
fun accumulateSamples(
metricData: CommonMetricData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class TelemetryClient(
) {
private val logger = Logger("telemetry/client")

@Suppress("LongMethod")
fun uploadPing(configuration: TelemetryConfiguration, path: String, serializedPing: String): Boolean {
val request = Request(
url = configuration.serverEndpoint + path,
Expand Down
Loading

0 comments on commit ca3eff8

Please sign in to comment.