EPForumL/androidApp

View on GitHub

Showing 122 of 122 total issues

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

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

            if(!users[receiverId]?.chatsWith?.contains(senderId)!!){
                users[receiverId]?.chatsWith = users[receiverId]?.chatsWith?.plus(senderId) ?: listOf(senderId)
            }
    app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 129..131

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

    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

            if(!users[senderId]?.chatsWith?.contains(receiverId)!!){
                users[senderId]?.chatsWith = users[senderId]?.chatsWith?.plus(receiverId) ?: listOf(receiverId)
            }
    app/src/main/java/com/github/ybecker/epforuml/database/MockDatabase.kt on lines 132..134

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

    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 onCreateViewHolder(parent: ViewGroup, viewType: Int): ChatHomeViewHolder {
            val itemViewHost = LayoutInflater.from(parent.context).inflate(R.layout.chat_home_item, parent, false)
            return ChatHomeViewHolder(itemViewHost)
        }
    app/src/main/java/com/github/ybecker/epforuml/basicEntities/questions/ForumAdapter.kt on lines 21..25
    app/src/main/java/com/github/ybecker/epforuml/basicEntities/questions/MyQuestionsAdapter.kt on lines 26..30
    app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatAdapter.kt on lines 28..31

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

    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 onCreateViewHolder(parent: ViewGroup, viewType: Int): ChatViewHolder {
            val itemViewHost = LayoutInflater.from(parent.context).inflate(R.layout.chat_item, parent, false)
            return ChatViewHolder(itemViewHost)
        }
    app/src/main/java/com/github/ybecker/epforuml/basicEntities/questions/ForumAdapter.kt on lines 21..25
    app/src/main/java/com/github/ybecker/epforuml/basicEntities/questions/MyQuestionsAdapter.kt on lines 26..30
    app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatHomeAdapter.kt on lines 25..28

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

    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

        // Inflate the forum item layout and create a new view holder
        override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ForumViewHolder {
            val itemView = LayoutInflater.from(parent.context).inflate(R.layout.forum_item, parent, false)
            return ForumViewHolder(itemView)
        }
    app/src/main/java/com/github/ybecker/epforuml/basicEntities/questions/MyQuestionsAdapter.kt on lines 26..30
    app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatAdapter.kt on lines 28..31
    app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatHomeAdapter.kt on lines 25..28

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

    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

        // Inflate the layout for each item in the RecyclerView
        override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyQuestionsViewHolder {
            val itemView = LayoutInflater.from(parent.context).inflate(R.layout.fragment_my_questions, parent, false)
            return MyQuestionsViewHolder(itemView)
        }
    app/src/main/java/com/github/ybecker/epforuml/basicEntities/questions/ForumAdapter.kt on lines 21..25
    app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatAdapter.kt on lines 28..31
    app/src/main/java/com/github/ybecker/epforuml/features/chat/ChatHomeAdapter.kt on lines 25..28

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

    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

            if (questionsMap.isEmpty()) {
                // Display a message if there are no questions
                val message = "There is no questions yet."
                val messageView = view?.findViewById<TextView>(R.id.no_question)
                messageView?.text = message
    app/src/main/java/com/github/ybecker/epforuml/basicEntities/questions/MyQuestionsFragment.kt on lines 100..105

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

    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

            if (myQuestionsMap.isEmpty()) {
                val message = "You have no questions yet."
                val messageView = view?.findViewById<TextView>(R.id.no_question)
                messageView?.text = message
                messageView?.visibility = View.VISIBLE
    app/src/main/java/com/github/ybecker/epforuml/structure/HomeFragment.kt on lines 161..167

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

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

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

                          permissions.getOrDefault(Manifest.permission.ACCESS_FINE_LOCATION, false) -> {
                              // Precise location access granted.
                              // requireActivity().invalidateOptionsMenu()
                              DatabaseManager.user?.sharesLocation = true
                              DatabaseManager.db.updateLocalization(user.userId, position, true)
      app/src/main/java/com/github/ybecker/epforuml/features/maps/MapsFragment.kt on lines 238..243

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

      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

                          permissions.getOrDefault(Manifest.permission.ACCESS_COARSE_LOCATION, false) -> {
                              // Only approximate location access granted.
                              DatabaseManager.user?.sharesLocation = true
                              DatabaseManager.db.updateLocalization(user.userId, position, true)
                              getCurrentLocation()
      app/src/main/java/com/github/ybecker/epforuml/features/maps/MapsFragment.kt on lines 231..237

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

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

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

                    if (qJson != null) {
                        val cacheTmp = qGson.fromJson<ArrayList<Model.Question>>(qJson)
                        if (cacheTmp != null) {
                            cache = cacheTmp
                        }
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 277..282
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 295..300
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 302..307
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 309..314

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

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

                    if (qJson != null) {
                        val allQuestionsTmp = qGson.fromJson<ArrayList<Model.Question>>(qJson)
                        if (allQuestionsTmp != null) {
                            allQuestionsCache = allQuestionsTmp
                        }
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 270..275
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 277..282
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 302..307
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 309..314

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

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

                    if (aJson != null) {
                        val allAnswersTmp = aGson.fromJson<ArrayList<Model.Answer>>(aJson)
                        if (allAnswersTmp != null) {
                            allAnswersCache = allAnswersTmp
                        }
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 270..275
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 277..282
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 295..300
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 309..314

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

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

                    if (cJson != null) {
                        val allCoursesTmp = cGson.fromJson<ArrayList<Model.Course>>(cJson)
                        if (allCoursesTmp != null) {
                            allCoursesCache = allCoursesTmp
                        }
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 270..275
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 277..282
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 295..300
            app/src/main/java/com/github/ybecker/epforuml/util/MainActivity.kt on lines 302..307

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

            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