coding-blocks/CBOnlineApp

View on GitHub

Showing 862 of 862 total issues

Method insertContents has a Cognitive Complexity of 156 (exceeds 20 allowed). Consider refactoring.
Open

    private suspend fun insertContents(
        contentList: List<LectureContent>,
        attemptId: String,
        sectionId: String,
        name: String?

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

    fun bind(item: Course, type: String) = with(itemView) {
        courseLogo.loadImage(item.logo)
        ViewCompat.setTransitionName(courseLogo, item.title)
        val ratingText = getSpannableSring("${item.rating}/5.0", ", ${item.reviewCount} ratings")
        ratingTv.text = ratingText

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

    private fun fetchQuestion(viewModel: QuizViewModel, pos: Int, view: View) {
        if (pos == questionList.size() - 1 && result == null) {
            view.submitButton.visibility = View.VISIBLE
        }
        CBOnlineLib.onlineV2JsonApi.getQuestionById(

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 VideoPlayerActivity.kt has 811 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package com.codingblocks.cbonlineapp.mycourse.content.player

import android.animation.LayoutTransition
import android.annotation.TargetApi
import android.app.ActivityManager

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

    package com.codingblocks.cbonlineapp.course.adapter
    
    import androidx.paging.PageKeyedDataSource
    import com.codingblocks.onlineapi.CBOnlineLib
    import com.codingblocks.onlineapi.ResultWrapper
    app/src/main/java/com/codingblocks/cbonlineapp/campaign/CampaignDataSource.kt on lines 1..58

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

    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

    package com.codingblocks.cbonlineapp.campaign
    
    import androidx.paging.PageKeyedDataSource
    import com.codingblocks.onlineapi.CBOnlineLib
    import com.codingblocks.onlineapi.ResultWrapper
    app/src/main/java/com/codingblocks/cbonlineapp/course/adapter/CourseDataSource.kt on lines 1..59

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

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

        private fun makeForm(formData: MutableLiveData<ArrayList<Form>>) {
    
            val params = LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT

    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 APIModel.kt has 677 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package com.codingblocks.onlineapi.models
    
    import com.fasterxml.jackson.annotation.JsonProperty
    import com.github.jasminb.jsonapi.Links
    import com.github.jasminb.jsonapi.RelType

      Method setupUI has a Cognitive Complexity of 91 (exceeds 20 allowed). Consider refactoring.
      Open

          private fun setupUI() {
      
              vm.offlineSnackbar.observer(this) {
                  rootLayout.showSnackbar(it, Snackbar.LENGTH_SHORT, action = false)
              }

      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

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

              CBOnlineLib.api.getSignature().enqueue(
                  retrofitCallback { _, response ->
                      val signature = response?.body()?.get("signature")
                      val userId = prefs.SP_USER_ID
                      val userName = prefs.SP_USER_NAME
      app/src/main/java/com/codingblocks/cbonlineapp/admin/InboxFragment.kt on lines 57..118

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

      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

              CBOnlineLib.api.getSignature().enqueue(
                  retrofitCallback { _, response ->
                      val signature = response?.body()?.get("signature")
                      val userId = prefs.SP_USER_ID
                      val userName = prefs.SP_USER_NAME
      app/src/main/java/com/codingblocks/cbonlineapp/dashboard/ChatActivity.kt on lines 40..103

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

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

          override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
              super.onViewCreated(view, savedInstanceState)
              courseLeaderboardRv.setRv(requireContext(), leaderBoardListAdapter)
              viewModel.run?.distinctUntilChanged()?.observer(thisLifecycleOwner) { courseAndRun ->
                  if (courseAndRun.runAttempt.paused) {

      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

      Class OnlineJsonApi has 61 methods (exceeds 20 allowed). Consider refactoring.
      Open

      interface OnlineJsonApi {
      
          @GET("courses/{id}")
          suspend fun getCourse(
              @Path("id") id: String

        File VdoPlayerControls.kt has 505 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        package com.codingblocks.cbonlineapp.util.widgets
        
        import android.content.Context
        import android.os.Handler
        import android.os.HandlerThread

          Method onCreate has a Cognitive Complexity of 67 (exceeds 20 allowed). Consider refactoring.
          Open

              override fun onCreate(savedInstanceState: Bundle?) {
                  super.onCreate(savedInstanceState)
                  setContentView(R.layout.activity_complete_profile)
                  val id = JWTUtils.getIdentity(sharedPrefs.SP_JWT_TOKEN_KEY)
                  courseResumeBtn.setOnClickListener {

          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 ViewExtensions.kt has 493 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package com.codingblocks.cbonlineapp.util.extensions
          
          import android.animation.Animator
          import android.animation.AnimatorListenerAdapter
          import android.content.Context

            Class VideoPlayerActivity has 53 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class VideoPlayerActivity :
                BaseCBActivity(),
                EditNoteClickListener,
                AnkoLogger,
                VdoPlayer.InitializationListener,

              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

              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

              Severity
              Category
              Status
              Source
              Language