coding-blocks/CBOnlineApp

View on GitHub

Showing 862 of 862 total issues

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

    fun removeBookmark() {
        runIO {
            val uid = bookmark.value?.bookmarkUid
            when (val response = uid?.let { repo.removeBookmark(it) }) {
                is ResultWrapper.GenericError -> setError(response.error)
app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfViewModel.kt on lines 60..76

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

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

        try {
            for (i in 0 until collegeArray?.length()!!) {
                val ref = collegeArray.getJSONObject(i)?.getString("name")
                if (ref != null) {
                    collegeList.add(ref)
app/src/main/java/com/codingblocks/cbonlineapp/auth/onboarding/CompleteProfileActivity.kt on lines 46..61

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

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

        try {
            for (i in 0 until collegeArray?.length()!!) {
                val ref = collegeArray.getJSONObject(i)?.getString("name")
                if (ref != null) {
                    collegeList.add(ref)
app/src/main/java/com/codingblocks/cbonlineapp/profile/ProfileActivity.kt on lines 90..105

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

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 fetchQuestion has 94 lines of code (exceeds 25 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(

    File MyCourseRepository.kt has 323 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package com.codingblocks.cbonlineapp.mycourse
    
    import com.codingblocks.cbonlineapp.database.BookmarkDao
    import com.codingblocks.cbonlineapp.database.ContentDao
    import com.codingblocks.cbonlineapp.database.CourseWithInstructorDao

      Method bind has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
      Open

              fun bind(item: DoubtsModel) = with(itemView) {
                  doubtTitleTv.text = item.title
                  val markWon = Markwon.create(context)
                  markWon.setMarkdown(doubtDescriptionTv, item.body)
                  doubtTimeTv.text = item.createdAt.timeAgo()

      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

          fun fetchProfessions(): MutableLiveData<List<Professions>> {
              val professions = MutableLiveData<List<Professions>>()
      
              runIO {
                  when (val response = repo.getProfessions()) {
      app/src/main/java/com/codingblocks/cbonlineapp/tracks/TrackViewModel.kt on lines 42..57

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

      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 fetchTracks(): MutableLiveData<List<CareerTracks>> {
              val tracks = MutableLiveData<List<CareerTracks>>()
              runIO {
                  when (val response = repo.getTracks()) {
                      is ResultWrapper.GenericError -> setError(response.error)
      app/src/main/java/com/codingblocks/cbonlineapp/tracks/TrackViewModel.kt on lines 74..90

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

      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 93 lines of code (exceeds 25 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 {

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

            private fun fetchDoubts() {
                runIO {
                    if (!attemptId.value.isNullOrEmpty())
                        when (val response = repo.fetchDoubtsByCourseRun(attemptId.value ?: "")) {
                            is ResultWrapper.GenericError -> setError(response.error)
        app/src/main/java/com/codingblocks/cbonlineapp/dashboard/doubts/DashboardDoubtsViewModel.kt on lines 16..32

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

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

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

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

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

        Refactorings

        Further Reading

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

            private fun fetchDoubts() {
                runIO {
                    if (!attemptId.value.isNullOrEmpty())
                        when (val response = repo.fetchDoubtsByCourseRun(attemptId.value ?: "")) {
                            is ResultWrapper.GenericError -> setError(response.error)
        app/src/main/java/com/codingblocks/cbonlineapp/dashboard/DashboardViewModel.kt on lines 304..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 250.

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

            fun fetchJob(jobId: String) {
                CBOnlineLib.onlineV2JsonApi.getJobById(
                    jobId
                ).enqueue(
                    retrofitCallback { _, response ->

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

            override fun onCreate(savedInstanceState: Bundle?) {
                super.onCreate(savedInstanceState)
                setContentView(R.layout.activity_my_course)
                setToolbar(toolbar_mycourse)
                intent.getStringExtra(RUN_ATTEMPT_ID)?.let {

        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

                vm.type.observer(thisLifecycleOwner) {
                    when (it) {
                        LIVE -> {
                            liveDoubtBtn.isActivated = true
                            resolvedDoubtBtn.isActivated = false
        app/src/main/java/com/codingblocks/cbonlineapp/jobs/JobsActivity.kt on lines 102..125

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

        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

                viewModel.type.observer(this) {
                    when (it) {
                        ALL -> {
                            liveDoubtBtn.isActivated = true
                            resolvedDoubtBtn.isActivated = false
        app/src/main/java/com/codingblocks/cbonlineapp/dashboard/doubts/DashboardDoubtsFragment.kt on lines 123..146

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

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

            fun verifyOtp(otp: String) {
                runIO {
                    if (uniqueId.isNullOrEmpty()) {
                        errorLiveData.postValue("There was some error.Please try Again!")
                    } else {
        Severity: Minor
        Found in app/src/main/java/com/codingblocks/cbonlineapp/auth/AuthViewModel.kt - About 3 hrs to fix

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

            fun updateCart() {
                runIO {
                    when (val response = safeApiCall { CBOnlineLib.api.updateCart(map) }) {
                        is ResultWrapper.GenericError -> setError(response.error)
                        is ResultWrapper.Success -> with(response.value) {

        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

            fun deleteNote(noteId: String) {
                runIO {
                    when (val response = repo.deleteNote(noteId)) {
                        is ResultWrapper.GenericError ->
                            if (response.code in 100..103)
        app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/player/VideoPlayerViewModel.kt on lines 176..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 235.

        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 deleteNote(noteId: String) {
                runIO {
                    when (val response = repo.deleteNote(noteId)) {
                        is ResultWrapper.GenericError ->
                            if (response.code in 100..103)
        app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewModel.kt on lines 82..100

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

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

            override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                super.onViewCreated(view, savedInstanceState)
                vm.getCart()
        
                useBalance.setOnClickListener {
          Severity
          Category
          Status
          Source
          Language