coding-blocks/CBOnlineApp

View on GitHub

Showing 246 of 862 total issues

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

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        arguments?.let {
            inboxRoot.removeAllViews()
            conversationId = it.getString(CONVERSATION_ID) ?: ""
Severity: Major
Found in app/src/main/java/com/codingblocks/cbonlineapp/admin/InboxFragment.kt - About 2 hrs to fix

    Method getPerformance has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
    Open

        private fun getPerformance() {
            runIO {
                val mRank = repo.getHackerBlocksPerformance().value
                when (val response = repo.getPerformance()) {
                    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 fetchMyCourses has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
    Open

        fun fetchMyCourses(offset: String = "0") {
            runIO {
                when (val response = myCourseRepo.fetchMyCourses(offset)) {
                    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 onCreate has 72 lines of code (exceeds 25 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)

      Method attachObservers has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private fun attachObservers() {
      
              viewModel.progress.observer(thisLifecycleOwner) {
                  swiperefresh.isRefreshing = it
              }

        File MyCourseViewModel.kt has 282 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        package com.codingblocks.cbonlineapp.mycourse
        
        import android.app.DownloadManager
        import android.content.Context
        import android.net.Uri

          Method createTile has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              @SuppressLint("RestrictedApi")
              private Drawable createTile(Drawable drawable, boolean clip) {
                  if (drawable instanceof DrawableWrapper) {
                      Drawable inner = ((DrawableWrapper) drawable).getWrappedDrawable();
                      if (inner != null) {

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

                                      override fun onItemClick(position: Int, id: String) {
                                          if (result == null) {
                                              // marking correct option in the list
                                              viewModel.bottomSheetQuizData.value?.get(pos)?.value = true
                                              question.choices?.get(position)?.marked = true

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

          package com.codingblocks.cbonlineapp.library
          
          import android.os.Bundle
          import android.os.Environment
          import android.view.LayoutInflater

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

                override fun onCreate(savedInstanceState: Bundle?) {
                    super.onCreate(savedInstanceState)
                    setContentView(R.layout.activity_code_challenge)
                    setToolbar(toolbarCodeChallenge, title = "")
                    if (savedInstanceState == null) {

              Method onStart has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
              Open

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

              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 VideoPlayerRepository has 23 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class VideoPlayerRepository(
                  private val notesDao: NotesDao,
                  private val contentDao: ContentDao,
                  private val bookmarkDao: BookmarkDao,
                  private val sectionDao: SectionWithContentsDao,

                Method findUser has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                Open

                    fun findUser(userMap: HashMap<String, String>) {
                        runIO {
                            when (val response = repo.findUser(userMap)) {
                                is ResultWrapper.GenericError -> setError(response.error)
                                is ResultWrapper.Success -> {
                Severity: Minor
                Found in app/src/main/java/com/codingblocks/cbonlineapp/auth/AuthViewModel.kt - About 2 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 fetchUser has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                Open

                    fun fetchUser() = liveData(Dispatchers.IO) {
                        when (val response = homeRepo.fetchUser()) {
                            is ResultWrapper.GenericError -> setError(response.error)
                            is ResultWrapper.Success -> {
                                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 onActivityCreated has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    override fun onActivityCreated(savedInstanceState: Bundle?) {
                        super.onActivityCreated(savedInstanceState)
                        sectionItemsAdapter.starter = this
                        sectionItemsAdapter.onItemClick = {
                            when (it) {

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

                      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                          super.onViewCreated(view, savedInstanceState)
                          setUpBottomSheet()
                  
                          courseTypeTv.apply {

                    Method showDialog has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private fun showDialog(size: Int, prize: String, descriptionMsg: String) {
                            val dialog = AlertDialog.Builder(requireContext()).create()
                            val view = layoutInflater.inflate(R.layout.dialog_result, null)
                    
                            val title: String

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

                          fun loginWithEmail(name: String, password: String) {
                              runIO {
                                  when (val response = repo.loginWithEmail(name, password)) {
                                      is ResultWrapper.GenericError -> setError(response.error)
                                      is ResultWrapper.Success -> {
                      Severity: Minor
                      Found in app/src/main/java/com/codingblocks/cbonlineapp/auth/AuthViewModel.kt - About 2 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 onReceive has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                      Open

                          override fun onReceive(context: Context, intent: Intent) {
                              val alarmMgr = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
                      
                              val i = Intent(context, DoubtReceiver::class.java)
                      
                      

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

                          override fun onCreate(savedInstanceState: Bundle?) {
                              super.onCreate(savedInstanceState)
                              setContentView(R.layout.activity_referral)
                              setToolbar(referralToolbar)
                      
                      

                      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