coding-blocks/CBOnlineApp

View on GitHub

Showing 246 of 862 total issues

Method insertCourses has a Cognitive Complexity of 53 (exceeds 20 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()) {

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 52 (exceeds 20 allowed). Consider refactoring.
Open

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_course)
        supportPostponeEnterTransition()
        setToolbar(courseToolbar)

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

    suspend fun saveCode(codeId: String, codeChallenge: CodeChallenge) {
        val newCode: CodeChallengeModel = codeId.let {

            with(codeChallenge.content!!) {
                CodeChallengeModel(

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

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_course)
        supportPostponeEnterTransition()
        setToolbar(courseToolbar)

    Class OnlineRestApi has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

    interface OnlineRestApi {
        @Deprecated("Progress is part of run")
        @GET("v2/run_attempts/{runid}/progress")
        fun getMyCourseProgress(@Path("runid") id: String): Call<HashMap<Any, Any>>
    
    

      File DashboardViewModel.kt has 366 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package com.codingblocks.cbonlineapp.dashboard
      
      import androidx.lifecycle.LiveData
      import androidx.lifecycle.MutableLiveData
      import androidx.lifecycle.SavedStateHandle

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

            override fun onCreate(savedInstanceState: Bundle?) {
                super.onCreate(savedInstanceState)
                setContentView(R.layout.activity_doubt_comment)
                setToolbar(commentsToolbar)
                commentRv.setRv(this@DoubtCommentActivity, commentsListAdapter)

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

          Method fetchCodeChallenge has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
          Open

              fun fetchCodeChallenge() = liveData(Dispatchers.IO) {
                  val codeModel = contentId?.let { repo.getCodeId(it) }
                  attempId = codeModel?.attempt_id
                  codeId = codeModel?.codeUid
                  contestId = codeModel?.codeContestId.toString()

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

              fun showConfirmation(context: Context, type: String, callback: (state: Boolean) -> Unit = { }) {
                  val confirmDialog = AlertDialog.Builder(context).create()
                  val updateView = context.layoutInflater.inflate(R.layout.custom_dialog, null)
                  when (type) {
                      VERIFY -> {
          Severity: Major
          Found in app/src/main/java/com/codingblocks/cbonlineapp/util/CustomDialog.kt - About 4 hrs to fix

            File VideoPlayerViewModel.kt has 353 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            package com.codingblocks.cbonlineapp.mycourse.content.player
            
            import androidx.lifecycle.MutableLiveData
            import androidx.lifecycle.SavedStateHandle
            import androidx.lifecycle.Transformations

              Method makeForm has 111 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Method fetchProjects has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
                Open

                    fun fetchProjects(projectIdList: ArrayList<Project>?) {
                        val list = arrayListOf<Project>()
                        if (!projectIdList.isNullOrEmpty()) {
                            runIO {
                                val projectList = projectIdList.map {

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

                    // Todo - Improvise this
                    fun fetchSections(sectionIdList: ArrayList<Sections>) {
                        val list = arrayListOf<Sections>()
                        if (!sectionIdList.isNullOrEmpty()) {
                            runIO {

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

                package com.codingblocks.cbonlineapp.mycourse.content
                
                import android.app.ActivityManager
                import android.content.Context
                import android.os.Bundle

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

                    package com.codingblocks.cbonlineapp.course
                    
                    import android.app.Activity
                    import android.content.Intent
                    import android.graphics.Typeface

                      File OnlineJsonApi.kt has 332 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      package com.codingblocks.onlineapi.api
                      
                      import com.codingblocks.onlineapi.models.Applications
                      import com.codingblocks.onlineapi.models.Bookmark
                      import com.codingblocks.onlineapi.models.CareerTracks

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

                                fun bind(item: Sections) = with(itemView) {
                                    title.text = item.name
                                    lectures.text = " ${item.contents?.size ?: 0} Items |"
                                    var duration: Long = 0
                                    for (subItems in item.contents!!) {

                        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 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(
                          Severity
                          Category
                          Status
                          Source
                          Language