coding-blocks/CBOnlineApp

View on GitHub

Showing 246 of 862 total issues

Method loadInitial has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

    override fun loadInitial(params: LoadInitialParams<String>, callback: LoadInitialCallback<String, Wishlist>) {
        scope.launch {
            when (val response = safeApiCall { CBOnlineLib.onlineV2JsonApi.getWishlist(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

Method loadInitial has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

    override fun loadInitial(params: LoadInitialParams<String>, callback: LoadInitialCallback<String, Spins>) {
        scope.launch {
            when (val response = safeApiCall { CBOnlineLib.onlineV2JsonApi.getCampaignLeaderBoard("0", "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 fetchRecommendedCourses has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

    fun fetchRecommendedCourses(offset: Int, page: Int) {
        runIO {
            when (val response = exploreRepo.getSuggestedCourses(offset, page)) {
                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 a Cognitive Complexity of 24 (exceeds 20 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 }

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

        @Query("exclude") query: String = "content.*",
        @Query("filter[acknowledgedById]") acknowledgedId: String,
        @Query("filter[status]") filter: String = "ACKNOWLEDGED",
        @Query("include") include: String = "content",
        @Query("page[limit]") page: String = "10",

    Method getJobs has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            @Query("filter[deadline][\$gt]") deadline: String,
            @Query("filter[postedOn][\$lte]") postedOn: String,
            @Query("filter[location][\$ilike][\$any][]") filterLoc: List<String>? = null,
            @Query("filter[type][\$in][]") filterType: List<String>? = null,
            @Query("page[offset]") pageOffSet: String = "0",

      Method getRecommendedCourses has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              @Query("exclude") query: String = "ratings,instructors.*,jobs,runs.*",
              @Query("filter[recommended]") recommended: String = "true",
              @Query("filter[unlisted]") unlisted: String = "false",
              @Query("page[limit]") page: Int = 12,
              @Query("page[offset]") offset: Int = 0,

        Method getAllCourses has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                @Query("page[offset]") offset: String,
                @Query("page[limit]") limit: String = "20",
                @Query("exclude") query: String = "ratings,instructors.*,jobs,runs.*",
                @Query("filter[unlisted]") unlisted: String = "false",
                @Query("include") include: String = "instructors,runs",

          Method showSnackbar has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              message: String,
              length: Int = Snackbar.LENGTH_SHORT,
              anchorView: BottomNavigationView? = null,
              action: Boolean = true,
              actionText: String = "Retry",

            Method setRv has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                activity: Context,
                listAdapter: ListAdapter<out Any, out RecyclerView.ViewHolder>,
                setDivider: Boolean = false,
                type: String = "",
                orientation: Int = RecyclerView.VERTICAL,

              Avoid deeply nested control flow statements.
              Open

                                  for (k in drawables.indices) {
                                      val drawable = drawables[k]
                                      if (drawable != null) {
                                          innerView.post { innerView.compoundDrawables[k].colorFilter = colorFilter }
                                      }

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

                    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                        super.onViewCreated(view, savedInstanceState)
                        runsToolbar.setOnClickListener {
                            dialog?.dismiss()
                        }

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

                        private static byte[] decode(String s) {
                            int delta = s.endsWith("==") ? 2 : s.endsWith("=") ? 1 : 0;
                            byte[] buffer = new byte[s.length() * 3 / 4 - delta];
                            int mask = 0xFF;
                            int index = 0;
                Severity: Minor
                Found in app/src/main/java/com/codingblocks/cbonlineapp/util/JWTUtils.java - About 45 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 getBookmarksByAttemptId has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        @Query("exclude") query: String = "section.*,content.*",
                        @Query("filter[runAttemptId]") id: String,
                        @Query("page[limit]") page: Int = 10,
                        @Query("page[offset]") offset: Int = 0,
                        @Query("include") include: String = "section,content",

                  Method getLiveDoubts has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          @Query("exclude") query: String = "content.*",
                          @Query("filter[status]") filter: String = "PENDING",
                          @Query("include") include: String = "content",
                          @Query("page[limit]") page: String = "10",
                          @Query("page[offset]") offset: Int = 0,

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

                        fun createUser(name: List<String>, username: String) {
                            runIO {
                                when (val response = repo.createUser(name, username, "$dialCode-$mobile", email!!, 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 45 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 startService has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                                context: Context,
                                sectionId: String,
                                attemptId: String,
                                videoId: String,
                                contentId: String,

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

                          fun bind(item: Wishlist?, type: Int) = with(itemView) {
                              with(item?.course!!) {
                                  courseLogo.loadImage(logo)
                                  ViewCompat.setTransitionName(courseLogo, title)
                                  val ratingText = getSpannableSring("$rating/5.0", ", $reviewCount ratings")

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

                          override suspend fun doWork(): Result {
                              val contentDao: ContentDao by inject()
                              val contentId = workerParameters.inputData.getString(CONTENT_ID)
                              val attemptId = workerParameters.inputData.getString(RUN_ATTEMPT_ID)
                              var progressId: String? = withContext(Dispatchers.IO) { contentDao.getProgressId(contentId ?: "") }
                      Severity: Minor
                      Found in app/src/main/java/com/codingblocks/cbonlineapp/workers/ProgressWorker.kt - About 45 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 getOtp has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                      Open

                          fun getOtp() {
                              runIO {
                                  when (
                                      val response = repo.getOtp(
                                          currentVideoId.value ?: "", attemptId.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