EPForumL/androidApp

View on GitHub

Showing 38 of 122 total issues

Method takePhoto has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private fun takePhoto() {

        // Get a stable reference of the modifiable image capture use case
        val imageCapture = imageCapture ?: return

    Method saveDataToDevice has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            /**
             * Saved question cache and answer cache to device
             */
            fun saveDataToDevice(questionCache: ArrayList<Model.Question>, answerCache: ArrayList<Model.Answer>,
                                 allQuestionCache: ArrayList<Model.Question>, allAnswerCache: ArrayList<Model.Answer>,
    Severity: Minor
    Found in app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt - About 1 hr to fix

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

              override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
                  if(holder is CourseViewHolder){
                      val course = courses[position]
                      // call bind with name args and if the switch is checked or not
                      holder.bind(course)

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

                override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
                    if(holder is CourseViewHolder){
                        val course = courses[position]
                        // call bind with name args and if the switch is checked or not
                        holder.bind(course)

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

            @SuppressLint("SetTextI18n")
            override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                super.onViewCreated(view, savedInstanceState)
        
                // initialize recycler with saved questions

          Method getMyQuestionsMap has 30 lines of code (exceeds 25 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

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

                override fun onCreate(savedInstanceState: Bundle?) {
                    super.onCreate(savedInstanceState)
                    viewBinding = ActivityCameraBinding.inflate(layoutInflater)
                    setContentView(viewBinding.root)
            
            

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

                  override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
                      when (holder) {
                          is HeaderViewHolder -> {
                              holder.headerText.setDisplayText(question.questionText)
                          }

                Method onMessageReceived has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    override fun onMessageReceived(message: RemoteMessage) {
                
                        Log.d(TAG, "message received : $message")
                
                        val notif_data = message.data

                  Method getCurrentLocation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      @SuppressLint("MissingPermission")
                      private fun getCurrentLocation() {
                          if (isLocalizationNotGranted()) {
                              // Asks user location permissions
                              requestPermissions.launch(

                    Method retrieveUsersInitialMessages has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        /**
                         * Retrieves the messages of a specific user upon connection to the chat session
                         * @param textMsg the text box
                         * @param button the send button
                         * @param view the current view

                      Method startCamera has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private fun startCamera() {
                              val cameraProviderFuture = ProcessCameraProvider.getInstance(this)
                      
                              cameraProviderFuture.addListener({
                                  // Used to bind the lifecycle of cameras to the lifecycle owner

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

                            override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
                                db.getUserById(DatabaseManager.user!!.userId).thenAccept{
                                    val hostUser = it!!
                                    val currentItem = chatList[position]
                                    if(currentItem.senderId == hostUser.userId){

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

                              abstract fun addQuestion(userId: String, courseId: String,isAnonymous:Boolean,  questionTitle: String, questionText: String?,  image_uri: String, audioPath : String): CompletableFuture<Question>
                          Severity: Major
                          Found in app/src/main/java/com/github/ybecker/epforuml/database/Database.kt - About 50 mins to fix

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

                                override fun addQuestion(userId: String, courseId: String, isAnonymous:Boolean, questionTitle: String, questionText: String?, image_uri: String, audioPath : String): CompletableFuture<Question> {
                            Severity: Major
                            Found in app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt - About 50 mins to fix

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

                                  fun sendNotification(context: Context, from: String, title:String ,text: String, topic: String, type: NotificationType) {

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

                                        fun saveDataToDevice(questionCache: ArrayList<Model.Question>, answerCache: ArrayList<Model.Answer>,
                                                             allQuestionCache: ArrayList<Model.Question>, allAnswerCache: ArrayList<Model.Answer>,
                                                            allCoursesCache: ArrayList<Model.Course>) {
                                Severity: Minor
                                Found in app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt - About 35 mins to fix

                                  Method answerPostingSetup has a Cognitive Complexity of 21 (exceeds 20 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)
                                  
                                  

                                  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