coding-blocks/CBOnlineApp

View on GitHub

Showing 246 of 862 total issues

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

    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 {

      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

      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

      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 {

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

            override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                super.onViewCreated(view, savedInstanceState)
                setUpBottomSheet()
        
                doubtEmptyBtn.setOnClickListener { requireActivity().dashboardBottomNav.selectedItemId = R.id.dashboard_home }

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

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

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

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

            Cognitive Complexity

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

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

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

            Further reading

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

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

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

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

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

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

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

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

                  Cognitive Complexity

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

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

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

                  Further reading

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

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

                  Cognitive Complexity

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

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

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

                  Further reading

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

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

                  Cognitive Complexity

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

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

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

                  Further reading

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

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

                  Cognitive Complexity

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

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

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

                  Further reading

                  Class MyCourseRepository has 26 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class MyCourseRepository(
                      private val sectionWithContentsDao: SectionWithContentsDao,
                      private val contentsDao: ContentDao,
                      private val sectionDao: SectionDao,
                      private val courseWithInstructorDao: CourseWithInstructorDao,

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

                        override fun onCreate(savedInstanceState: Bundle?) {
                            super.onCreate(savedInstanceState)
                            setContentView(R.layout.activity_chat)
                    
                            setSupportActionBar(chatToolbar)
                      Severity
                      Category
                      Status
                      Source
                      Language