EPForumL/androidApp

View on GitHub

Showing 122 of 122 total issues

Method onBindViewHolder has a Cognitive Complexity of 149 (exceeds 20 allowed). Consider refactoring.
Open

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        when (holder) {

            is HeaderViewHolder -> {
                // Sets the mathView text for the question detail and disables zooming on the view

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

/**
 * This class is a database that should only be used for tests
 */
class MockDatabase : Database() {

    Class Database has 50 methods (exceeds 20 allowed). Consider refactoring.
    Open

    /**
     * An abstract class that defines a set of methods to be implemented by concrete database implementations.
     */
    abstract class Database {
    
    
    Severity: Minor
    Found in app/src/main/java/com/github/ybecker/epforuml/database/Database.kt - About 7 hrs to fix

      Method onBindViewHolder has 175 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
              when (holder) {
      
                  is HeaderViewHolder -> {
                      // Sets the mathView text for the question detail and disables zooming on the view

        File MockDatabase.kt has 379 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        package com.github.ybecker.epforuml.database
        
        import android.util.Log
        import com.github.ybecker.epforuml.database.Model.*
        import com.google.android.gms.maps.model.LatLng

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

              // Fetch the questions and the corresponding courses and display them in the recycler view
              private fun getMyQuestionsMap() {
                  if (DatabaseManager.user == null) {
                      val notConnected = view?.findViewById<TextView>(R.id.not_connected_text_view)
                      notConnected?.visibility = View.VISIBLE

          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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                          if (it != null) {
                              externUser = it
                              chatList = db.getChat(hostId, externId)
                              view.findViewById<TextView>(R.id.title_chat).text = externUser.username
                              val button = view.findViewById<ImageButton>(R.id.send_text)
          app/src/main/java/com/github/ybecker/epforuml/features/chat/RealChatFragment.kt on lines 116..128

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 274.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                      if (it != null) {
                          externUser = it
                          chatList = db.getChat(hostId, externId)
                          view.findViewById<TextView>(R.id.title_chat).text = externUser.username
                          val button = view.findViewById<ImageButton>(R.id.send_text)
          app/src/main/java/com/github/ybecker/epforuml/features/chat/RealChatFragment.kt on lines 77..89

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 274.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          File QuestionDetailsActivity.kt has 297 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package com.github.ybecker.epforuml.basicEntities.questions
          
          import android.content.Intent
          import android.content.SharedPreferences
          import android.graphics.PorterDuff

            Method updateRecycler has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
            Open

                private fun updateRecycler() {
            
                    if (MainActivity.isConnected()) {
            
                        db.getUserById(question!!.userId).thenAccept {

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

            package com.github.ybecker.epforuml.basicEntities.answers
            
            import android.app.Activity
            import android.app.Dialog
            import android.content.Context

              Method startRecordingVideo has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private fun startRecordingVideo() {
              
                      val videoCapture = this.videoCapture ?: return
              
                      isRecording=true

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    class HeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
                        val headerText : MathView = itemView.findViewById(R.id.qdetails_question_content)
                        val image : ImageView = itemView.findViewById(R.id.image_question)
                        val video: PlayerView = itemView.findViewById(R.id.video_question)
                    }
                app/src/main/java/com/github/ybecker/epforuml/basicEntities/answers/AnswerAdapter.kt on lines 330..334
                app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatHomeAdapter.kt on lines 52..56

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 162.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    class ChatHomeViewHolder(itemView:View) : RecyclerView.ViewHolder(itemView) {
                        val chatImage : ImageView = itemView.findViewById(R.id.profilePicture)
                        val chatWithText : TextView = itemView.findViewById(R.id.whoToChatWith)
                        val chatWithButton : CardView = itemView.findViewById(R.id.buttonChatWith)
                    }
                app/src/main/java/com/github/ybecker/epforuml/basicEntities/answers/AnswerAdapter.kt on lines 324..328
                app/src/main/java/com/github/ybecker/epforuml/basicEntities/answers/AnswerAdapter.kt on lines 330..334

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 162.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    class AnswerViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView) {
                        val username : TextView = itemView.findViewById(R.id.qdetails_answer_username)
                        val answerText : MathView = itemView.findViewById(R.id.qdetails_answer_text)
                        val button : ImageButton = itemView.findViewById(R.id.chatWithUser)
                    }
                app/src/main/java/com/github/ybecker/epforuml/basicEntities/answers/AnswerAdapter.kt on lines 324..328
                app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatHomeAdapter.kt on lines 52..56

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 162.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        val contentValues = ContentValues().apply {
                            put(MediaStore.MediaColumns.DISPLAY_NAME, name)
                            put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg")
                            if(Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
                                put(MediaStore.Images.Media.RELATIVE_PATH, "Pictures/CameraX-Image")
                app/src/main/java/com/github/ybecker/epforuml/features/camera/CameraActivity.kt on lines 167..173

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 159.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        val contentValues = ContentValues().apply {
                            put(MediaStore.MediaColumns.DISPLAY_NAME, name)
                            put(MediaStore.MediaColumns.MIME_TYPE, "video/mp4")
                            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
                                put(MediaStore.Video.Media.RELATIVE_PATH, "Movies/CameraX-Video")
                app/src/main/java/com/github/ybecker/epforuml/features/camera/CameraActivity.kt on lines 114..120

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 159.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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_main)
                        FirebaseApp.initializeApp(this)
                        context = applicationContext
                Severity: Major
                Found in app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt - About 2 hrs to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      override fun getUserNotificationIds(userId: String): CompletableFuture<List<String>> {
                          val list = users[userId]?.notifications
                          if(list == null || list.isEmpty()){
                              return CompletableFuture.completedFuture(listOf())
                          }
                  app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 357..363

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 154.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      override fun getCourseNotificationUserIds(courseId: String): CompletableFuture<List<String>> {
                          val list = courses[courseId]?.notifications
                          if(list == null || list.isEmpty()){
                              return CompletableFuture.completedFuture(listOf())
                          }
                  app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 365..371

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 154.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language