coding-blocks/CBOnlineApp

View on GitHub
app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt

Summary

Maintainability
F
4 days
Test Coverage

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

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        setUpBottomSheet()
        typeTv.text = vm.type
        when (vm.type) {

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 onViewCreated has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        setUpBottomSheet()
        typeTv.text = vm.type
        when (vm.type) {

    File LibraryViewFragment.kt has 281 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package com.codingblocks.cbonlineapp.library
    
    import android.os.Bundle
    import android.os.Environment
    import android.view.LayoutInflater

      Method onClick has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  override fun onClick(item: BaseModel) {
                      when (item) {
                          is ContentLecture -> startActivity(
                              createVideoPlayerActivityIntent(requireContext(), item.lectureContentId, item.lectureSectionId)
                          )

        Method updateNotes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private fun updateNotes(item: NotesModel) {
                sheetDialog.apply {
                    bottomSheetTitleTv.text = getString(R.string.add_note)
                    doubtTitleTv.isVisible = false
                    bottoSheetDescTv.setText(item.text)

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

                      getString(R.string.notes) -> {
                          libraryListAdapter = LibraryListAdapter(LibraryTypes.NOTE)
                          vm.fetchNotes().observe(thisLifecycleOwner) {
                              if (it.isNullOrEmpty()) {
                                  libraryListAdapter.submitList(emptyList())
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 121..131

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

          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

                      getString(R.string.bookmarks) -> {
                          libraryListAdapter = LibraryListAdapter(LibraryTypes.BOOKMARK)
                          vm.fetchBookmarks().observe(thisLifecycleOwner) {
                              if (it.isNullOrEmpty()) {
                                  libraryListAdapter.submitList(emptyList())
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 109..119

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

          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

                  GlobalScope.launch(Dispatchers.Main) {
                      progressDialog.show()
                      withContext(Dispatchers.IO) { FileUtils.deleteRecursive(dir) }
                      delay(3000)
                      vm.updateDownload(0, lectureId)
          app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/player/VideoPlayerActivity.kt on lines 537..543

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

          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

                      getString(R.string.bookmarks) -> {
                          libEmptyImg.setImageResource(R.drawable.ic_bookmark_big)
                          libEmptyMessageTv.text = getString(R.string.empty_bookmark_title)
                          libEmptyDescriptionTv.text = getString(R.string.empty_bookmark_text)
                      }
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 240..244
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 250..254

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

          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

                      getString(R.string.notes) -> {
                          libEmptyImg.setImageResource(R.drawable.ic_note_big)
                          libEmptyMessageTv.text = getString(R.string.empty_notes_title)
                          libEmptyDescriptionTv.text = getString(R.string.empty_notes_text)
                      }
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 245..249
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 250..254

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

          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

                      getString(R.string.downloads) -> {
                          libEmptyImg.setImageResource(R.drawable.ic_download_big)
                          libEmptyMessageTv.text = getString(R.string.empty_download_title)
                          libEmptyDescriptionTv.text = getString(R.string.empty_download_text)
                      }
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 240..244
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 245..249

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

          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

                              getString(R.string.bookmarks) -> {
                                  selectionTracker?.selection?.forEach {
                                      vm.removeBookmark(it)
                                  }.also { deleteContainer.isVisible = false }
                              }
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 190..194

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

          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

                              getString(R.string.notes) -> {
                                  selectionTracker?.selection?.forEach {
                                      vm.deleteNote(it)
                                  }.also { deleteContainer.isVisible = false }
                              }
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 195..199

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

          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_library_view, 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/mycourse/content/CourseContentFragment.kt on lines 104..105
          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 3 locations. Consider refactoring.
          Open

                                      CODE ->
                                          startActivity(
                                              intentFor<CodeChallengeActivity>(
                                                  CONTENT_ID to item.contentId,
                                                  SECTION_ID to item.sectionId
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 62..68
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 73..79

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

          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

                                      QNA ->
                                          startActivity(
                                              intentFor<QuizActivity>(
                                                  CONTENT_ID to item.contentId,
                                                  SECTION_ID to item.sectionId
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 62..68
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 80..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 74.

          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

                                      DOCUMENT ->
                                          startActivity(
                                              intentFor<PdfActivity>(
                                                  CONTENT_ID to item.contentId,
                                                  SECTION_ID to item.sectionId
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 73..79
          app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt on lines 80..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 74.

          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