Skip to content

Instantly share code, notes, and snippets.

@helium-service
Created May 8, 2024 21:55
Show Gist options
  • Save helium-service/892d8ef1583bae4013ffab1a6785ae7b to your computer and use it in GitHub Desktop.
Save helium-service/892d8ef1583bae4013ffab1a6785ae7b to your computer and use it in GitHub Desktop.
Detekt Report for PR #1741 Timestamp 1715205255

detekt

Metrics

  • 30 number of properties

  • 52 number of functions

  • 2 number of classes

  • 3 number of packages

  • 3 number of kt files

Complexity Report

  • 1,387 lines of code (loc)

  • 916 source lines of code (sloc)

  • 684 logical lines of code (lloc)

  • 336 comment lines of code (cloc)

  • 103 cyclomatic complexity (mcc)

  • 53 cognitive complexity

  • 32 number of total code smells

  • 36% comment source ratio

  • 150 mcc per 1,000 lloc

  • 46 code smells per 1,000 lloc

Findings (32)

complexity, TooManyFunctions (1)

Too many functions inside a/an file/class/object/interface always indicate a violation of the single responsibility principle. Maybe the file/class/object/interface wants to manage too many things at once. Extract functionality which clearly belongs together.

Documentation

  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:31:7
Class 'PangleAdapter' with '17' functions detected. Defined threshold inside classes is set to '11'
28 /**
29  * The Chartboost Mediation Pangle SDK adapter.
30  */
31 class PangleAdapter : PartnerAdapter {
!!       ^ error
32     companion object {
33         /**
34          * Key for parsing the Pangle SDK application ID.

style, MagicNumber (9)

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.

Documentation

  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:145:76
This expression contains a magic number. Consider defining it to a well named constant.
142      * The time to live (TTL) value of a queued ad in milliseconds.
143      * This value is configurable via the [AppConfigStorage].
144      */
145     private var queuedAdTtlMs: Long = AppConfigStorage.queueAdTtlSeconds * 1000L
!!!                                                                            ^ error
146 
147     /**
148      * The maximum queue size.
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:170:13
This expression contains a magic number. Consider defining it to a well named constant.
167      */
168     private val delayFetchRateMs: Long
169         get() =
170             1000L *
!!!             ^ error
171                 max(
172                     AppConfigStorage.fullscreenLoadTimeoutSeconds,
173                     LoadRateLimiter().getLoadRateLimitSeconds(placement),
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:443:83
This expression contains a magic number. Consider defining it to a well named constant.
440     private fun handleAdFetchLoadResultNoAd(loadResult: ChartboostMediationFullscreenAdLoadResult) {
441         LogController.w(
442             "$LOG_PREFIX $placement failed to load ad. " +
443                 "The next fetch request has been delayed for ${delayFetchRateMs / 1000} " +
!!!                                                                                   ^ error
444                 "seconds to prevent unnecessary requests from being made.",
445         )
446         LogController.i(
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:468:83
This expression contains a magic number. Consider defining it to a well named constant.
465         fetchAdJob = null
466         LogController.w(
467             "$LOG_PREFIX $placement encountered an error during ad fetch. " +
468                 "The next fetch request has been delayed for ${delayFetchRateMs / 1000} " +
!!!                                                                                   ^ error
469                 "seconds to prevent unnecessary requests from being made.",
470         )
471         // Start another ad fetch job.
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:706:23
This expression contains a magic number. Consider defining it to a well named constant.
703     private fun getPangleBannerSize(size: Size?): PAGBannerSize {
704         return size?.height?.let {
705             when {
706                 it in 50 until 90 -> PAGBannerSize.BANNER_W_320_H_50
!!!                       ^ error
707                 it in 90 until 250 -> PAGBannerSize.BANNER_W_728_H_90
708                 it >= 250 -> PAGBannerSize.BANNER_W_300_H_250
709                 else -> PAGBannerSize.BANNER_W_320_H_50
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:706:32
This expression contains a magic number. Consider defining it to a well named constant.
703     private fun getPangleBannerSize(size: Size?): PAGBannerSize {
704         return size?.height?.let {
705             when {
706                 it in 50 until 90 -> PAGBannerSize.BANNER_W_320_H_50
!!!                                ^ error
707                 it in 90 until 250 -> PAGBannerSize.BANNER_W_728_H_90
708                 it >= 250 -> PAGBannerSize.BANNER_W_300_H_250
709                 else -> PAGBannerSize.BANNER_W_320_H_50
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:707:23
This expression contains a magic number. Consider defining it to a well named constant.
704         return size?.height?.let {
705             when {
706                 it in 50 until 90 -> PAGBannerSize.BANNER_W_320_H_50
707                 it in 90 until 250 -> PAGBannerSize.BANNER_W_728_H_90
!!!                       ^ error
708                 it >= 250 -> PAGBannerSize.BANNER_W_300_H_250
709                 else -> PAGBannerSize.BANNER_W_320_H_50
710             }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:707:32
This expression contains a magic number. Consider defining it to a well named constant.
704         return size?.height?.let {
705             when {
706                 it in 50 until 90 -> PAGBannerSize.BANNER_W_320_H_50
707                 it in 90 until 250 -> PAGBannerSize.BANNER_W_728_H_90
!!!                                ^ error
708                 it >= 250 -> PAGBannerSize.BANNER_W_300_H_250
709                 else -> PAGBannerSize.BANNER_W_320_H_50
710             }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:708:23
This expression contains a magic number. Consider defining it to a well named constant.
705             when {
706                 it in 50 until 90 -> PAGBannerSize.BANNER_W_320_H_50
707                 it in 90 until 250 -> PAGBannerSize.BANNER_W_728_H_90
708                 it >= 250 -> PAGBannerSize.BANNER_W_300_H_250
!!!                       ^ error
709                 else -> PAGBannerSize.BANNER_W_320_H_50
710             }
711         } ?: PAGBannerSize.BANNER_W_320_H_50

style, MaxLineLength (13)

Line detected, which is longer than the defined maximum line length in the code style.

Documentation

  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:266:1
Line detected, which is longer than the defined maximum line length in the code style.
263      * Starts loading ads and append them to the queue automatically until capacity has been reached.
264      */
265     fun start() {
266         if (ChartboostMediationSdk.chartboostMediationInternal.initializationStatus != ChartboostMediationSdk.ChartboostMediationInitializationStatus.INITIALIZED) {
!!! ^ error
267             LogController.d(
268                 "$LOG_PREFIX $placement the Chartboost Mediation SDK has not initialized." +
269                     " Cannot start the queue. Waiting until the Chartboost Mediation SDK has started before queuing.",
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:369:1
Line detected, which is longer than the defined maximum line length in the code style.
366                 if (isDelayed) delay(delayFetchRateMs)
367 
368                 if (fullscreenAdsQueued.size >= queueCapacity) {
369                     LogController.d("$LOG_PREFIX $placement already reached capacity. Waiting until the next queue job.")
!!! ^ error
370                     fetchAdJob = null
371                     return@launch
372                 }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:381:1
Line detected, which is longer than the defined maximum line length in the code style.
378                     // Invalidate the ad
379                     loadResult.ad?.invalidate()
380                     LogController.w(
381                         "$LOG_PREFIX $placement already has an active queue fetch job. Discarding previously loaded ad.",
!!! ^ error
382                     )
383                     return@launch
384                 }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/build.gradle.kts:40:1
Line detected, which is longer than the defined maximum line length in the code style.
37         targetSdk = 33
38         // If you touch the following line, don't forget to update scripts/get_rc_version.zsh
39         android.defaultConfig.versionName = System.getenv("VERSION_OVERRIDE") ?: "4.5.9.0.2.1"
40         buildConfigField("String", "CHARTBOOST_MEDIATION_PANGLE_ADAPTER_VERSION", "\"${android.defaultConfig.versionName}\"")
!! ^ error
41 
42         consumerProguardFiles("proguard-rules.pro")
43 
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:108:1
Line detected, which is longer than the defined maximum line length in the code style.
105                 } ?: run {
106                 PartnerLogController.log(SETUP_FAILED, "Missing application ID.")
107                 resumeOnce(
108                     Result.failure(ChartboostMediationAdException(ChartboostMediationError.CM_INITIALIZATION_FAILURE_INVALID_CREDENTIALS)),
!!! ^ error
109                 )
110             }
111         }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:125:1
Line detected, which is longer than the defined maximum line length in the code style.
122         PAGConfig.Builder()
123             .appId(appId)
124             .supportMultiProcess(PangleAdapterConfiguration.multiProcessSupport)
125             .setUserData("[{\"name\":\"mediation\",\"value\":\"Chartboost\"},{\"name\":\"adapter_version\",\"value\":\"$adapterVersion\"}]")
!!! ^ error
126             .build()
127 
128     /**
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:293:1
Line detected, which is longer than the defined maximum line length in the code style.
290             AdFormat.REWARDED.key -> loadRewardedAd(request, partnerAdListener)
291             else -> {
292                 PartnerLogController.log(LOAD_FAILED)
293                 Result.failure(ChartboostMediationAdException(ChartboostMediationError.CM_LOAD_FAILURE_UNSUPPORTED_AD_FORMAT))
!!! ^ error
294             }
295         }
296     }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:325:1
Line detected, which is longer than the defined maximum line length in the code style.
322             }
323             else -> {
324                 PartnerLogController.log(SHOW_FAILED)
325                 Result.failure(ChartboostMediationAdException(ChartboostMediationError.CM_SHOW_FAILURE_UNSUPPORTED_AD_FORMAT))
!!! ^ error
326             }
327         }
328     }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:385:1
Line detected, which is longer than the defined maximum line length in the code style.
382                     ) {
383                         PartnerLogController.log(LOAD_FAILED, "Code: $code. Error: $message")
384                         resumeOnce(
385                             Result.failure(ChartboostMediationAdException(ChartboostMediationError.CM_LOAD_FAILURE_UNKNOWN)),
!!! ^ error
386                         )
387                     }
388 
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:427:1
Line detected, which is longer than the defined maximum line length in the code style.
424                             PartnerLogController.log(LOAD_FAILED, "No Pangle banner found.")
425                             resumeOnce(
426                                 Result.failure(
427                                     ChartboostMediationAdException(ChartboostMediationError.CM_SHOW_FAILURE_AD_NOT_FOUND),
!!! ^ error
428                                 ),
429                             )
430                         }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:494:1
Line detected, which is longer than the defined maximum line length in the code style.
491                             PartnerLogController.log(LOAD_FAILED)
492                             resumeOnce(
493                                 Result.failure(
494                                     ChartboostMediationAdException(ChartboostMediationError.CM_LOAD_FAILURE_MISMATCHED_AD_PARAMS),
!!! ^ error
495                                 ),
496                             )
497                         }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:561:1
Line detected, which is longer than the defined maximum line length in the code style.
558                             PartnerLogController.log(LOAD_FAILED)
559                             resumeOnce(
560                                 Result.failure(
561                                     ChartboostMediationAdException(ChartboostMediationError.CM_LOAD_FAILURE_MISMATCHED_AD_PARAMS),
!!! ^ error
562                                 ),
563                             )
564                         }
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:688:1
Line detected, which is longer than the defined maximum line length in the code style.
685                     )
686                     resumeOnce(
687                         Result.failure(
688                             ChartboostMediationAdException(ChartboostMediationError.CM_SHOW_FAILURE_WRONG_RESOURCE_TYPE),
!!! ^ error
689                         ),
690                     )
691                 }

style, ReturnCount (1)

Restrict the number of return statements in methods.

Documentation

  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:343:17
Function startAdFetchJob has 3 return statements which exceeds the limit of 2.
340      *
341      * @param isDelayed [Boolean] Whether or not the next fetch job is delayed (optional & false as default).
342      */
343     private fun startAdFetchJob(isDelayed: Boolean = false) {
!!!                 ^ error
344         if (!isRunning) {
345             LogController.d("$LOG_PREFIX $placement is no longer running. Waiting for the queue to start running.")
346             return

style, WildcardImport (8)

Wildcard imports should be replaced with imports using fully qualified class names. Wildcard imports can lead to naming conflicts. A library update can introduce naming clashes with your classes which results in compilation errors.

Documentation

  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:12:1
com.chartboost.chartboostmediationsdk.domain.* is a wildcard import. Replace it with fully qualified imports.
9  
10 import android.content.Context
11 import com.chartboost.chartboostmediationsdk.ChartboostMediationSdk
12 import com.chartboost.chartboostmediationsdk.domain.*
!! ^ error
13 import com.chartboost.chartboostmediationsdk.network.ChartboostMediationNetworking
14 import com.chartboost.chartboostmediationsdk.network.Endpoints
15 import com.chartboost.chartboostmediationsdk.utils.LogController
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/ChartboostMediation/src/main/java/com/chartboost/chartboostmediationsdk/ad/ChartboostMediationFullscreenAdQueue.kt:17:1
kotlinx.coroutines.* is a wildcard import. Replace it with fully qualified imports.
14 import com.chartboost.chartboostmediationsdk.network.Endpoints
15 import com.chartboost.chartboostmediationsdk.utils.LogController
16 import com.chartboost.core.ChartboostCore
17 import kotlinx.coroutines.*
!! ^ error
18 import kotlinx.coroutines.Dispatchers.IO
19 import kotlinx.coroutines.Dispatchers.Main
20 import kotlin.math.max
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:14:1
com.bytedance.sdk.openadsdk.api.banner.* is a wildcard import. Replace it with fully qualified imports.
11 import android.content.Context
12 import android.util.Size
13 import com.bytedance.sdk.openadsdk.api.PAGConstant
14 import com.bytedance.sdk.openadsdk.api.banner.*
!! ^ error
15 import com.bytedance.sdk.openadsdk.api.init.*
16 import com.bytedance.sdk.openadsdk.api.interstitial.*
17 import com.bytedance.sdk.openadsdk.api.reward.*
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:15:1
com.bytedance.sdk.openadsdk.api.init.* is a wildcard import. Replace it with fully qualified imports.
12 import android.util.Size
13 import com.bytedance.sdk.openadsdk.api.PAGConstant
14 import com.bytedance.sdk.openadsdk.api.banner.*
15 import com.bytedance.sdk.openadsdk.api.init.*
!! ^ error
16 import com.bytedance.sdk.openadsdk.api.interstitial.*
17 import com.bytedance.sdk.openadsdk.api.reward.*
18 import com.chartboost.chartboostmediationsdk.domain.*
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:16:1
com.bytedance.sdk.openadsdk.api.interstitial.* is a wildcard import. Replace it with fully qualified imports.
13 import com.bytedance.sdk.openadsdk.api.PAGConstant
14 import com.bytedance.sdk.openadsdk.api.banner.*
15 import com.bytedance.sdk.openadsdk.api.init.*
16 import com.bytedance.sdk.openadsdk.api.interstitial.*
!! ^ error
17 import com.bytedance.sdk.openadsdk.api.reward.*
18 import com.chartboost.chartboostmediationsdk.domain.*
19 import com.chartboost.chartboostmediationsdk.utils.PartnerLogController
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:17:1
com.bytedance.sdk.openadsdk.api.reward.* is a wildcard import. Replace it with fully qualified imports.
14 import com.bytedance.sdk.openadsdk.api.banner.*
15 import com.bytedance.sdk.openadsdk.api.init.*
16 import com.bytedance.sdk.openadsdk.api.interstitial.*
17 import com.bytedance.sdk.openadsdk.api.reward.*
!! ^ error
18 import com.chartboost.chartboostmediationsdk.domain.*
19 import com.chartboost.chartboostmediationsdk.utils.PartnerLogController
20 import com.chartboost.chartboostmediationsdk.utils.PartnerLogController.PartnerAdapterEvents.*
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:18:1
com.chartboost.chartboostmediationsdk.domain.* is a wildcard import. Replace it with fully qualified imports.
15 import com.bytedance.sdk.openadsdk.api.init.*
16 import com.bytedance.sdk.openadsdk.api.interstitial.*
17 import com.bytedance.sdk.openadsdk.api.reward.*
18 import com.chartboost.chartboostmediationsdk.domain.*
!! ^ error
19 import com.chartboost.chartboostmediationsdk.utils.PartnerLogController
20 import com.chartboost.chartboostmediationsdk.utils.PartnerLogController.PartnerAdapterEvents.*
21 import com.chartboost.mediation.pangleadapter.PangleAdapterConfiguration.adapterVersion
  • /Users/cbx/actions-runner1/_work/helium-android/helium-android/chartboost-mediation-android-adapter-pangle/PangleAdapter/src/main/java/com/chartboost/mediation/pangleadapter/PangleAdapter.kt:20:1
com.chartboost.chartboostmediationsdk.utils.PartnerLogController.PartnerAdapterEvents.* is a wildcard import. Replace it with fully qualified imports.
17 import com.bytedance.sdk.openadsdk.api.reward.*
18 import com.chartboost.chartboostmediationsdk.domain.*
19 import com.chartboost.chartboostmediationsdk.utils.PartnerLogController
20 import com.chartboost.chartboostmediationsdk.utils.PartnerLogController.PartnerAdapterEvents.*
!! ^ error
21 import com.chartboost.mediation.pangleadapter.PangleAdapterConfiguration.adapterVersion
22 import kotlinx.coroutines.suspendCancellableCoroutine
23 import kotlinx.serialization.json.Json

generated with detekt version 1.23.5 on 2024-05-08 21:55:06 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment