EPForumL/androidApp

View on GitHub

Showing 122 of 122 total issues

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

    override fun removeAnswerLike(userId: String, answerId: String) {
        val answer = answers[answerId]
        if(answer != null) {
            val updatedNotification = answer.like.filter { it != userId }
            answers[answerId] = answer.copy(like = updatedNotification)
app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 251..257
app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 283..289

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 144.

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

    override fun removeSubscription(userId: String, courseId: String) {
        val user = users[userId]
        if(user != null) {
            val updatedSubscription = user.subscriptions.filter { it != courseId }
            users[userId] = user.copy(subscriptions = updatedSubscription)
app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 283..289
app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 291..297

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 144.

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

    override fun removeQuestionFollower(userId: String, questionId: String) {
        val course = questions[questionId]
        if(course != null) {
            val updatedNotification = course.followers.filter { it != userId }
            questions[questionId] = course.copy(followers = updatedNotification)
app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 251..257
app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 291..297

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 144.

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

        companion object CREATOR : Parcelable.Creator<Answer> {
            override fun createFromParcel(parcel: Parcel): Answer {
                return Answer(parcel)
            }

app/src/main/java/com/github/ybecker/epforuml/database/Model.kt on lines 179..187

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 140.

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

        companion object CREATOR : Parcelable.Creator<Course> {
            override fun createFromParcel(parcel: Parcel): Course {
                return Course(parcel)
            }

app/src/main/java/com/github/ybecker/epforuml/database/Model.kt on lines 104..112

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 140.

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

    private fun updateRecycler() {

        if (MainActivity.isConnected()) {

            db.getUserById(question!!.userId).thenAccept {

    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 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)
              
              

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

                    override fun getQuestionAnswers(questionId: String): CompletableFuture<List<Answer>> {
                        return CompletableFuture.completedFuture(answers.filterValues { it.questionId == questionId }.values.toList().reversed())
                    }
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 146..148
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 336..338
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 340..342

                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 126.

                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 4 locations. Consider refactoring.
                Open

                    override fun getUserAnswers(userId: String): CompletableFuture<List<Answer>> {
                        return CompletableFuture.completedFuture(answers.filterValues { it.userId == userId }.values.toList().reversed())
                    }
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 146..148
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 150..152
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 336..338

                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 126.

                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 4 locations. Consider refactoring.
                Open

                    override fun getUserQuestions(userId: String): CompletableFuture<List<Question>> {
                        return CompletableFuture.completedFuture(questions.filterValues { it.userId == userId }.values.toList().reversed())
                    }
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 146..148
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 150..152
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 340..342

                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 126.

                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 4 locations. Consider refactoring.
                Open

                    override fun getCourseQuestions(courseId: String): CompletableFuture<List<Question>> {
                        return CompletableFuture.completedFuture(questions.filterValues { it.courseId == courseId }.values.toList().reversed())
                    }
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 150..152
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 336..338
                app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 340..342

                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 126.

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

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

                    // View holder for the forum questions
                    class ForumViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView) {
                        val profilePicture : ImageView = itemView.findViewById(R.id.question_image)
                        val currentText : TextView = itemView.findViewById(R.id.forum_question_displayed)
                    }
                app/src/main/java/com/github/ybecker/epforuml/basicEntities/answers/SavedAnswerAdapter.kt on lines 110..113
                app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatAdapter.kt on lines 91..94

                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 123.

                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 ChatViewHolder(itemView:View) : RecyclerView.ViewHolder(itemView) {
                        val currentText : TextView = itemView.findViewById(R.id.textChat)
                        val chatImage : ImageView = itemView.findViewById(R.id.profilePicture)
                    }
                app/src/main/java/com/github/ybecker/epforuml/basicEntities/answers/SavedAnswerAdapter.kt on lines 110..113
                app/src/main/java/com/github/ybecker/epforuml/basicEntities/questions/ForumAdapter.kt on lines 57..61

                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 123.

                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)
                    }
                app/src/main/java/com/github/ybecker/epforuml/basicEntities/questions/ForumAdapter.kt on lines 57..61
                app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatAdapter.kt on lines 91..94

                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 123.

                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