coding-blocks/CBOnlineApp

View on GitHub
app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt

Summary

Maintainability
F
5 days
Test Coverage

Method attachObservers has a Cognitive Complexity of 77 (exceeds 20 allowed). Consider refactoring.
Open

    private fun attachObservers() {

        viewModel.progress.observer(thisLifecycleOwner) {
            swiperefresh.isRefreshing = it
        }

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 onActivityCreated has a Cognitive Complexity of 61 (exceeds 20 allowed). Consider refactoring.
Open

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        sectionItemsAdapter.starter = this
        sectionItemsAdapter.onItemClick = {
            when (it) {

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

File CourseContentFragment.kt has 343 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package com.codingblocks.cbonlineapp.mycourse.content

import android.app.ActivityManager
import android.content.Context
import android.os.Bundle

    Method attachObservers has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private fun attachObservers() {
    
            viewModel.progress.observer(thisLifecycleOwner) {
                swiperefresh.isRefreshing = it
            }

      Method onActivityCreated has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          override fun onActivityCreated(savedInstanceState: Bundle?) {
              super.onActivityCreated(savedInstanceState)
              sectionItemsAdapter.starter = this
              sectionItemsAdapter.onItemClick = {
                  when (it) {

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

            override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                super.onViewCreated(view, savedInstanceState)
                viewModel.fetchSections()
                typeChipGroup.setOnCheckedChangeListener { _, checkedId ->
                    when (checkedId) {

          Method checkSection has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private fun checkSection(premium: Boolean) {
                  when {
                      viewModel.runStartEnd.first < System.currentTimeMillis() -> {
                          requireContext().showDialog(
                              "expired",

            Method onViewCreated has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
            Open

                override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                    super.onViewCreated(view, savedInstanceState)
                    viewModel.fetchSections()
                    typeChipGroup.setOnCheckedChangeListener { _, checkedId ->
                        when (checkedId) {

            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 startDownload has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    videoId: String,
                    contentId: String,
                    title: String,
                    attemptId: String,
                    sectionId: String

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

                                      DOCUMENT ->
                                          if (contentDocument.documentUid.isNotEmpty()) {
                                              viewModel.updateProgress(ccid)
                                              startActivity(
                                                  intentFor<PdfActivity>(
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 310..320

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

              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

                                      QNA ->
                                          if (contentQna.qnaUid.isNotEmpty()) {
                                              viewModel.updateProgress(ccid)
                                              startActivity(
                                                  intentFor<QuizActivity>(
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 285..295

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

              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 26 locations. Consider refactoring.
              Open

                  override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?):
                      View? = inflater.inflate(R.layout.fragment_course_content, container, false)
              app/src/main/java/com/codingblocks/cbonlineapp/auth/LoginHomeFragment.kt on lines 29..33
              app/src/main/java/com/codingblocks/cbonlineapp/auth/LoginOtpFragment.kt on lines 27..31
              app/src/main/java/com/codingblocks/cbonlineapp/auth/SignInFragment.kt on lines 18..22
              app/src/main/java/com/codingblocks/cbonlineapp/auth/SignUpFragment.kt on lines 20..24
              app/src/main/java/com/codingblocks/cbonlineapp/auth/SocialLoginFragment.kt on lines 21..25
              app/src/main/java/com/codingblocks/cbonlineapp/course/batches/RunFragment.kt on lines 27..31
              app/src/main/java/com/codingblocks/cbonlineapp/course/checkout/CheckoutFailedFragment.kt on lines 17..21
              app/src/main/java/com/codingblocks/cbonlineapp/course/checkout/CheckoutOrderDetailsFragment.kt on lines 24..25
              app/src/main/java/com/codingblocks/cbonlineapp/course/checkout/CheckoutPaymentFragment.kt on lines 24..25
              app/src/main/java/com/codingblocks/cbonlineapp/course/checkout/CheckoutPersonalDetailsFragment.kt on lines 23..27
              app/src/main/java/com/codingblocks/cbonlineapp/dashboard/doubts/DashboardDoubtsFragment.kt on lines 89..94
              app/src/main/java/com/codingblocks/cbonlineapp/dashboard/explore/DashboardExploreFragment.kt on lines 109..110
              app/src/main/java/com/codingblocks/cbonlineapp/dashboard/home/DashboardHomeFragment.kt on lines 87..91
              app/src/main/java/com/codingblocks/cbonlineapp/dashboard/library/DashboardLibraryFragment.kt on lines 43..47
              app/src/main/java/com/codingblocks/cbonlineapp/dashboard/mycourses/DashboardMyCoursesFragment.kt on lines 55..59
              app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryHomeFragment.kt on lines 18..23
              app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 98..102
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/player/doubts/VideoDoubtFragment.kt on lines 65..66
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/player/notes/VideoNotesFragment.kt on lines 68..69
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/AboutQuizFragment.kt on lines 23..27
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizFragment.kt on lines 42..46
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizResultFragment.kt on lines 33..38
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/info/QuizInfoFragment.kt on lines 18..23
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/submissions/QuizSubmissionsFragment.kt on lines 38..42
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/library/CourseLibraryFragment.kt on lines 23..28

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

              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 5 locations. Consider refactoring.
              Open

                              R.id.webinarChip -> viewModel.filters.value = VIDEO.also {
                                  type = VIDEO
                              }
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 115..117
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 118..120
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 121..123
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 124..126

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

              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 5 locations. Consider refactoring.
              Open

                              R.id.quizChip -> viewModel.filters.value = QNA.also {
                                  type = QNA
                              }
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 112..114
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 115..117
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 121..123
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 124..126

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

              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 5 locations. Consider refactoring.
              Open

                              R.id.documentChip -> viewModel.filters.value = DOCUMENT.also {
                                  type = DOCUMENT
                              }
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 112..114
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 115..117
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 118..120
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 121..123

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

              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

                              requireContext().showDialog(
                                  "purchase",
                                  secondaryText = R.string.purchase,
                                  primaryButtonText = R.string.buy_now,
                                  cancelable = true
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 340..345
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 366..371

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

              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

                              requireContext().showDialog(
                                  "expired",
                                  secondaryText = R.string.expired,
                                  primaryButtonText = R.string.buy_extension,
                                  cancelable = true
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 350..355
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 366..371

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

              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 5 locations. Consider refactoring.
              Open

                              R.id.lectureChip -> viewModel.filters.value = LECTURE.also {
                                  type = LECTURE
                              }
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 112..114
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 118..120
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 121..123
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 124..126

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

              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

                              requireContext().showDialog(
                                  "Wait",
                                  secondaryText = R.string.wait,
                                  primaryButtonText = R.string.ok,
                                  cancelable = true
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 340..345
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 350..355

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

              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 5 locations. Consider refactoring.
              Open

                              R.id.codeChip -> viewModel.filters.value = CODE.also {
                                  type = CODE
                              }
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 112..114
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 115..117
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 118..120
              app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt on lines 124..126

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

              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