EPForumL/androidApp

View on GitHub

Showing 38 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

          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

                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

                  Method loadDataFromDevice has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private fun loadDataFromDevice() {
                          val sharedQuestions : SharedPreferences = context.getSharedPreferences("QUESTIONS", MODE_PRIVATE)
                          val sharedAnswers : SharedPreferences = context.getSharedPreferences("ANSWERS", MODE_PRIVATE)
                  
                          val qGson = Gson()
                  Severity: Minor
                  Found in app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt - About 1 hr to fix

                    Method updateRecycler has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Method onCreateView has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          override fun onCreateView(
                              inflater: LayoutInflater, container: ViewGroup?,
                              savedInstanceState: Bundle?
                          ): View? {
                              val view = inflater.inflate(layout.fragment_chat_list, container, false)

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

                            override fun onCreate(savedInstanceState: Bundle?) {
                                super.onCreate(savedInstanceState)
                                setContentView(R.layout.activity_search)
                                listView = findViewById(R.id.listView)
                                searchView = findViewById(R.id.searchView)

                          Method endorsementSetup has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private fun endorsementSetup() {
                                  db.getQuestionFollowers(questionId).thenAccept {
                                      val notificationButton = findViewById<ImageButton>(R.id.addFollowButton)
                                      val followButton = findViewById<TextView>(R.id.notificationCount)
                                      val count = it.size

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

                                override fun onCreate(savedInstanceState: Bundle?) {
                                    super.onCreate(savedInstanceState)
                                    setContentView(R.layout.activity_question_details)
                            
                                    audioPlayer = AndroidAudioPlayer(this)

                              Method answerPostingSetup has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private fun answerPostingSetup() {
                                      val replyBox : EditText = findViewById(R.id.write_reply_box)
                                      val sendButton : ImageButton = findViewById(R.id.post_reply_button)
                                      val latexButton : ImageButton = findViewById(R.id.question_details_latex)
                              
                              

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

                                        fun bind(course: Course) {
                                            courseTitleTextView.text = course.courseName
                                            subscriptionSwitch.isEnabled = user.userId.length != 0
                                            val is_subscribed = userSubscriptions.map { it.courseId }.contains(course.courseId)
                                            subscriptionSwitch.isChecked = is_subscribed

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

                                        fun bind(course: Course) {
                                            courseTitleTextView.text = course.courseName
                                            subscriptionSwitch.isEnabled = user.userId.length != 0
                                            val is_subscribed = userSubscriptions.map { it.courseId }.contains(course.courseId)
                                            subscriptionSwitch.isChecked = is_subscribed
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language