coding-blocks/CBOnlineApp

View on GitHub

Showing 862 of 862 total issues

Method onViewCreated has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        setUpBottomSheet()

        doubtEmptyBtn.setOnClickListener { requireActivity().dashboardBottomNav.selectedItemId = R.id.dashboard_home }

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

        fun resolveDoubt(doubt: DoubtsModel, saveToDb: Boolean = false) {
            runIO {
                when (val response = repo.resolveDoubt(doubt)) {
                    is ResultWrapper.GenericError -> setError(response.error)
                    is ResultWrapper.Success -> {
    app/src/main/java/com/codingblocks/cbonlineapp/dashboard/DashboardViewModel.kt on lines 322..339

    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 232.

    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

            receiver = object : DownloadBroadcastReceiver() {
                override fun onReceive(context: Context, intent: Intent) {
                    super.onReceive(context, intent)
                    val id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
                    val file = File("$path/$fileName")
    app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivity.kt on lines 81..98

    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 232.

    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

        fun resolveDoubt(doubt: DoubtsModel, saveToDb: Boolean = false) {
            runIO {
                when (val response = repo.resolveDoubt(doubt)) {
                    is ResultWrapper.GenericError -> setError(response.error)
                    is ResultWrapper.Success -> {
    app/src/main/java/com/codingblocks/cbonlineapp/dashboard/doubts/DashboardDoubtsViewModel.kt on lines 34..51

    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 232.

    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

            receiver = object : DownloadBroadcastReceiver() {
                override fun onReceive(context: Context, intent: Intent) {
                    super.onReceive(context, intent)
                    val id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
                    val file = File("$path/$fileName")
    app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivity.kt on lines 151..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 232.

    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

                        RESOLVED -> {
                            setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, context.getDrawable(R.drawable.ic_reopen_small), null)
                            setTextColor(ContextCompat.getColor(context, R.color.neon_red))
                            setOnClickListener { _ ->
                                viewModel.resolveDoubt(
    app/src/main/java/com/codingblocks/cbonlineapp/dashboard/DoubtCommentActivity.kt on lines 79..94

    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 231.

    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

                        else -> {
                            setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, context.getDrawable(R.drawable.ic_tick), null)
                            setTextColor(ContextCompat.getColor(context, R.color.freshGreen))
                            setOnClickListener { _ ->
                                viewModel.resolveDoubt(
    app/src/main/java/com/codingblocks/cbonlineapp/dashboard/DoubtCommentActivity.kt on lines 63..78

    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 231.

    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

    Method onCreate has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override fun onCreate() {
            Thread.setDefaultUncaughtExceptionHandler(CrashHandler(applicationContext))
            super.onCreate()
            mInstance = this
            val prefs = PreferenceHelper.getPrefs(this)
    Severity: Major
    Found in app/src/main/java/com/codingblocks/cbonlineapp/CBOnlineApp.kt - About 3 hrs to fix

      Method requestChat has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
      Open

          suspend fun requestChat(doubtId: String): String = viewModelScope.async {
              when (val response = repo.getChatId(doubtId)) {
                  is ResultWrapper.GenericError -> {
                      setError(response.error)
                      return@async ""

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

              runIO {
                  when (val response = repo.addToCart(id)) {
                      is ResultWrapper.GenericError -> {
                          enrollTrialProgress.postValue(STATE.ERROR)
                          setError(response.error)
      app/src/main/java/com/codingblocks/cbonlineapp/course/CourseViewModel.kt on lines 165..181

      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 225.

      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

              runIO {
                  when (val response = repo.enrollToTrial(id)) {
      
                      is ResultWrapper.GenericError -> {
                          enrollTrialProgress.postValue(STATE.ERROR)
      app/src/main/java/com/codingblocks/cbonlineapp/course/CourseViewModel.kt on lines 185..200

      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 225.

      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

      Method onViewCreated has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
              super.onViewCreated(view, savedInstanceState)
      
              vm.fetchRecommendedCourses(0, 4)
              vm.fetchRecommendedCourses(4, 4)

        Class VdoPlayerControls has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class VdoPlayerControls @JvmOverloads constructor(
            context: Context,
            attrs: AttributeSet? = null,
            defStyle: Int = 0
        ) : FrameLayout(context, attrs, defStyle) {

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

              fun addWishlist(id: String) {
                  val wishlist = Wishlist(Course(id))
                  runIO {
                      when (val response = repo.addWishlist(wishlist)) {
                          is ResultWrapper.GenericError -> setError(response.error)
          app/src/main/java/com/codingblocks/cbonlineapp/dashboard/DashboardViewModel.kt on lines 385..399

          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 217.

          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 addWishlist(id: String) {
                  val course = Wishlist(Course(id))
                  runIO {
                      when (val response = homeRepo.addWishlist(course)) {
                          is ResultWrapper.GenericError -> setError(response.error)
          app/src/main/java/com/codingblocks/cbonlineapp/course/CourseViewModel.kt on lines 248..262

          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 217.

          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

          File DashboardActivity.kt has 296 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package com.codingblocks.cbonlineapp.dashboard
          
          import android.annotation.TargetApi
          import android.content.Context
          import android.content.Intent

            Method loadAfter has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
            Open

                override fun loadAfter(params: LoadParams<String>, callback: LoadCallback<String, Course>) {
                    scope.launch {
                        when (val response = safeApiCall { CBOnlineLib.onlineV2JsonApi.getAllCourses(params.key, "9") }) {
                            is ResultWrapper.Success -> with(response.value) {
                                if (response.value.isSuccessful)

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method loadAfter has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
            Open

                override fun loadAfter(params: LoadParams<String>, callback: LoadCallback<String, Spins>) {
                    scope.launch {
                        when (val response = safeApiCall { CBOnlineLib.onlineV2JsonApi.getCampaignLeaderBoard(params.key, "10") }) {
                            is ResultWrapper.Success -> with(response.value) {
                                if (response.value.isSuccessful)

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method onClick has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
            Open

                override fun onClick(v: View) {
                    when (v.id) {
                        R.id.bottomSheetSaveBtn -> {
                            when ((v as Button).text) {
                                "Save" -> {

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method loadAfter has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
            Open

                override fun loadAfter(params: LoadParams<String>, callback: LoadCallback<String, Wishlist>) {
                    scope.launch {
                        when (val response = safeApiCall { CBOnlineLib.onlineV2JsonApi.getWishlist(offset = params.key, page = pageSize) }) {
                            is ResultWrapper.Success -> with(response.value) {
                                if (isSuccessful)

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Severity
            Category
            Status
            Source
            Language