coding-blocks/CBOnlineApp

View on GitHub

Showing 246 of 862 total issues

Method bindTo has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
Open

    /**
     * Items might be null if they are not paged in yet. PagedListAdapter will re-bind the
     * ViewHolder when Item is loaded.
     */
    fun bindTo(content: ContentModel, onItemClick: ((ContentModel) -> Unit)?) {

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

    override fun onResume() {
        super.onResume()
        if (vm.isLoggedIn == true) {
            vm.fetchTopRunWithStats().observe(
                thisLifecycleOwner,

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

        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_notifications)
            setSupportActionBar(notificationToolbar)
            supportActionBar?.setHomeButtonEnabled(true)

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

          override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
              super.onViewCreated(view, savedInstanceState)
      
              adminTabLayout.addOnTabSelectedListener(this)
      
      

        Method onStart has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            override fun onStart() {
                super.onStart()
                wifiSwitch.isChecked = getPrefs().SP_WIFI
        
                wifiSwitch.setOnClickListener {

          Method onCreate has 54 lines of code (exceeds 25 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 {

            File CourseViewModel.kt has 256 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            package com.codingblocks.cbonlineapp.course
            
            import androidx.lifecycle.LiveData
            import androidx.lifecycle.MutableLiveData
            import androidx.lifecycle.viewModelScope

              Method fetchQuiz has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
              Open

                  fun fetchQuiz() {
                      runIO {
                          when (val response = quiz.qnaQid.let { repo.getQuizDetails(quizId = it.toString()) }) {
                              is ResultWrapper.GenericError -> setError(response.error)
                              is ResultWrapper.Success -> {

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

              fun Context.showDialog(
                  type: String,
                  cancelable: Boolean = false,
                  @DrawableRes image: Int = R.drawable.ic_lock,
                  @StringRes primaryText: Int = R.string.confirmation,

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

                    override fun onCreate(savedInstanceState: Bundle?) {
                        super.onCreate(savedInstanceState)
                        setContentView(R.layout.activity_pdf)
                        setToolbar(toolbarPdfActivity)
                        if (savedInstanceState == null) {

                  Method checkFile has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private fun checkFile() {
                          fileName?.replace(" ", "_")
                  
                          if (MediaUtils.checkPermission(this)) {
                              path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)

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

                        override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                            super.onViewCreated(view, savedInstanceState)
                            checkoutShimmer.showShimmer(true)
                            vm.cart.observe(thisLifecycleOwner) { res ->
                                checkoutShimmer.hideAndStop()

                      Method setList has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private fun setList() {
                              val json =
                                  FileUtils.loadJsonObjectFromAsset(this, "demographics.json", "obj") as JSONObject?
                              val collegeArray = json?.getJSONArray("colleges")
                              val branchArray = json?.getJSONArray("branches")

                        Method doWork has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            override suspend fun doWork(): Result {
                                val contentId = workerParameters.inputData.getString(CONTENT_ID) ?: ""
                                val attemptId = workerParameters.inputData.getString(RUN_ATTEMPT_ID) ?: ""
                                val videoId = workerParameters.inputData.getString(VIDEO_ID) ?: ""
                                val sectionId = workerParameters.inputData.getString(SECTION_ID) ?: ""

                          Method insertCourses has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              suspend fun insertCourses(runs: List<Runs>) {
                                  runs.forEach { run ->
                                      with(run) {
                                          val response = withContext(Dispatchers.IO) { insertCourse(course) }
                                          if (!runAttempts.isNullOrEmpty()) {

                            Method changeWishlistStatus has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                            Open

                                fun changeWishlistStatus(id: String) {
                                    runIO {
                                        when (val response = repo.checkIfWishlisted(id)) {
                                            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 onCreate has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                            Open

                                override fun onCreate(savedInstanceState: Bundle?) {
                                    super.onCreate(savedInstanceState)
                                    setContentView(R.layout.activity_library)
                                    setToolbar(libraryToolbar)
                                    libraryToolbar.setNavigationOnClickListener {

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

                                suspend fun insertSections(runAttempt: RunAttempts, refresh: Boolean = false) {
                                    val runAttemptModel = RunAttemptModel(
                                        runAttempt.id,
                                        runAttempt.certificateApproved,
                                        runAttempt.end,

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

                            fun Toolbar.colouriseToolbar(context: Context, @DrawableRes toolbarDrawable: Int, @ColorInt foregroundColor: Int) {
                                background = AppCompatResources.getDrawable(context, toolbarDrawable)
                                setTitleTextColor(foregroundColor)
                                setSubtitleTextColor(foregroundColor)
                                val colorFilter = PorterDuffColorFilter(foregroundColor, PorterDuff.Mode.SRC_IN)

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

                                fun changeWishlistStatus(id: String) {
                                    runIO {
                                        when (val response = homeRepo.checkWishlisted(id)) {
                                            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

                            Severity
                            Category
                            Status
                            Source
                            Language