coding-blocks/CBOnlineApp

View on GitHub

Showing 246 of 862 total issues

Method fetchDoubts has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
Open

    private fun fetchDoubts() {
        runIO {
            if (!attemptId.value.isNullOrEmpty())
                when (val response = repo.fetchDoubtsByCourseRun(attemptId.value ?: "")) {
                    is ResultWrapper.GenericError -> setError(response.error)

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

    private fun fetchDoubts() {
        runIO {
            if (!attemptId.value.isNullOrEmpty())
                when (val response = repo.fetchDoubtsByCourseRun(attemptId.value ?: "")) {
                    is ResultWrapper.GenericError -> setError(response.error)

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 onResourceReady has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

                    resource: Drawable?,
                    model: Any?,
                    target: Target<Drawable>?,
                    dataSource: DataSource?,
                    isFirstResource: Boolean

    Method getLeaderBoard has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            @Query("filter[visible_all]") filter: String = "true",
            @Query("include") include: String = "user",
            @Query("sort") sort: String = "-rating_all",
            @Query("page[limit]") page: String = "10",
            @Query("page[offset]") offset: Int = 0

      Method findCourses has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              @Query("exclude") exclude: String = "ratings,instructors.*,jobs",
              @Query("filter[title][\$iLike]") query: String,
              @Query("filter[unlisted]") unlisted: String = "false",
              @Query("page[limit]") page: Int = 100,
              @Query("include") include: String = "instructors,runs"

        Method onResourceReady has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                resource: Drawable?,
                model: Any?,
                target: Target<Drawable>?,
                dataSource: DataSource?,
                isFirstResource: Boolean

          Method setToolbar has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              toolbar: Toolbar,
              hasUpEnabled: Boolean = true,
              homeButtonEnabled: Boolean = true,
              title: String = "",
              show: Boolean = true

            Method createUser has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                suspend fun createUser(name: List<String>, username: String, mobile: String, email: String, uniqueId: String) =
            Severity: Minor
            Found in app/src/main/java/com/codingblocks/cbonlineapp/auth/AuthRepository.kt - About 35 mins to fix

              Method changeViewState has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  recyclerView: RecyclerView,
                  internetView: LinearLayout,
                  emptyView: LinearLayout,
                  shimmerView: ShimmerFrameLayout,
                  boolean: Boolean

                Method startDownload has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    fun startDownload(videoId: String, contentId: String, title: String, attemptId: String, sectionId: String)

                  Method getWinnings has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          @Query("exclude") exclude: String = "spin_prize.*,user",
                          @Query("filter[used]") filter1: String = "true",
                          @Query("filter[won]") filter2: String = "true",
                          @Query("sort") sort: String = "-used_at",
                          @Query("include") include: String = "spin_prize"

                    Method startDownload has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            videoId: String,
                            contentId: String,
                            title: String,
                            attemptId: String,
                            sectionId: String

                      Method onLayout has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {

                        Method fetchSections has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                        Open

                            fun fetchSections() {
                                runIO {
                                    if (withContext(Dispatchers.IO) { courseRepo.getSectionWithContentNonLive(attemptId!!) }.isEmpty())
                                        when (val response = courseRepo.fetchSections(attemptId!!)) {
                                            is ResultWrapper.GenericError -> setError(response.error)

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

                            public boolean canScrollVertically(AbsListView view) {
                                boolean canScroll = false;
                        
                                if (view != null && view.getChildCount() > 0) {
                                    boolean isOnTop = view.getFirstVisiblePosition() != 0 || view.getChildAt(0).getTop() != 0;

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

                            private fun loginUserWithClaim() {
                                runIO {
                                    when (val response = repo.loginWithClaim(uniqueId!!)) {
                                        is ResultWrapper.GenericError -> setError(response.error)
                                        is ResultWrapper.Success -> {
                        Severity: Minor
                        Found in app/src/main/java/com/codingblocks/cbonlineapp/auth/AuthViewModel.kt - About 35 mins 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 updateUser has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                        Open

                            fun updateUser(id: String, map: Map<String, String>): MutableLiveData<String> {
                                val res = MutableLiveData<String>()
                                runIO {
                                    when (val response = repo.updateUser(id, map)) {
                                        is ResultWrapper.GenericError -> res.postValue(response.error)

                        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

                        Avoid too many return statements within this method.
                        Open

                                return "$interval Hours Ago"

                          Avoid too many return statements within this method.
                          Open

                                  return drawable;

                            Avoid too many return statements within this method.
                            Open

                                    return "$interval Minutes Ago"
                              Severity
                              Category
                              Status
                              Source
                              Language