coding-blocks/CBOnlineApp

View on GitHub
app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadService.kt

Summary

Maintainability
D
1 day
Test Coverage

Method initializeDownload has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private fun initializeDownload(mOtp: String, mPlaybackInfo: String, videoId: String) {
        val optionsDownloader = OptionsDownloader()
        optionsDownloader.downloadOptionsWithOtp(
            mOtp, mPlaybackInfo,
            object : OptionsDownloader.Callback {

    Method onStartCommand has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
            if (intent.action == ACTION_STOP) {
                stopServiceManually()
                notificationManager.cancel(NOTIFICATION_ID)
            } else {

      Method onCompleted has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          /**
           * Updates the [ContentModel] along with updating the notification.
           */
          override fun onCompleted(videoId: String, p1: DownloadStatus?) {
              val data = findDataWithId(videoId)

        Method startService has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                    context: Context,
                    sectionId: String,
                    attemptId: String,
                    videoId: String,
                    contentId: String,

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  if (response.isSuccessful) {
                      response.body()?.let {
                          downloadList[downloadData.videoId] = (downloadData)
                          val mOtp = it.get("otp").asString
                          val mPlaybackInfo = it.get("playbackInfo").asString
          app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadService.kt on lines 125..132
          app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadWorker.kt on lines 79..86

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 156.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              private fun sendNotification(data: DownloadData, downloadPercent: Int) {
                  data.notificationBuilder.setProgress(100, downloadPercent, false)
                  data.notificationBuilder.setContentText("Downloaded $downloadPercent %")
                  notificationManager.notify(data.notificationId, data.notificationBuilder.build())
              }
          app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadWorker.kt on lines 148..152

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 140.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                  val response: Response<JsonObject> = withContext(Dispatchers.IO) {
                      CBOnlineLib.api.getOtp(downloadData.videoId, downloadData.sectionId, downloadData.attemptId, true)
                  }
          app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadWorker.kt on lines 192..192

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 105.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                              if (PreferenceHelper.getPrefs(applicationContext).SP_SD_CARD && directories.size > 1) {
                                  file = directories[1]
                              } else {
                                  PreferenceHelper.getPrefs(applicationContext).SP_SD_CARD = false
                              }
          app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadService.kt on lines 148..152

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 105.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              private fun findDataWithId(videoId: String): DownloadData? {
                  for (data in downloadList) {
                      if (videoId == data.key)
                          return data.value
                  }
          app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadWorker.kt on lines 154..160
          app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadWorker.kt on lines 132..138

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 87.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

                              try {
                                  vdoDownloadManager.enqueue(request)
                                  vdoDownloadManager.addEventListener(this@DownloadService)
                              } catch (e: IllegalArgumentException) {
                              } catch (e: IllegalStateException) {
          app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadWorker.kt on lines 132..137
          app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadService.kt on lines 160..165
          app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadWorker.kt on lines 165..170

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 79.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  fun stopService(context: Context) {
                      val stopIntent = Intent(context, DownloadService::class.java)
                      context.stopService(stopIntent)
                  }
          app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadService.kt on lines 46..49

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 67.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              override fun onChanged(videoId: String, downloadStatus: DownloadStatus) {
                  val data = findDataWithId(videoId)
                  if (data != null)
                      sendNotification(data, downloadStatus.downloadPercent)
              }
          app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadWorker.kt on lines 164..168

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 60.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status