asfoury/projmag

View on GitHub

Showing 24 of 26 total issues

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

package com.sdp13epfl2021.projmag.curriculumvitae.fragments

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
app/src/main/java/com/sdp13epfl2021/projmag/curriculumvitae/fragments/LanguagesFragment.kt on lines 1..87

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

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

package com.sdp13epfl2021.projmag.curriculumvitae.fragments

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
app/src/main/java/com/sdp13epfl2021/projmag/curriculumvitae/fragments/SkillsFragment.kt on lines 1..87

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

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 addListenersToAppliedProjects has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

    private fun addListenersToAppliedProjects() {
        appliedProjects.forEach {
            candidatureDatabase.addListener(it) { _: ProjectId, list: List<Candidature> ->
                val ownCandidatureThatChanged: Candidature? =
                    list.find { candidature -> candidature.userId == userId }

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

package com.sdp13epfl2021.projmag.database.impl.firebase

import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.google.firebase.firestore.DocumentReference

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

        /**
         * Function that handles the click and long click of elements of the tag recycler view
         *
         * @param tagRecyclerView : the tag recycler view
         * @param tagsDataset : the dataset of tags
    app/src/main/java/com/sdp13epfl2021/projmag/activities/SectionSelectionActivity.kt on lines 39..73

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

    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

        /**
         * Handling of what happens when you click on sections in the UI
         *
         * @param sectionRecyclerView : the section recycler view
         * @param sectionDataset : the dataset of sections
    app/src/main/java/com/sdp13epfl2021/projmag/activities/TagsSelectorActivity.kt on lines 41..75

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

    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

    Class ProjectsListActivity has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

    /**
     * Displays a list of projects. User can filter based on various criteria and search by name.
     */
    @AndroidEntryPoint
    class ProjectsListActivity : AppCompatActivity() {

      Method getProfile has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

          override fun getProfile(
              userID: String,
              onSuccess: (profile: ImmutableProfile?) -> Unit,
              onFailure: (Exception) -> Unit
          ) {

      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 build has 16 arguments (exceeds 5 allowed). Consider refactoring.
      Open

                  id: String,
                  name: String,
                  lab: String,
                  authorId: String,
                  teacher: String,

        Method buildCopy has 16 arguments (exceeds 5 allowed). Consider refactoring.
        Open

                id: String = this.id,
                name: String = this.name,
                lab: String = this.lab,
                authorId: String = this.authorId,
                teacher: String = this.teacher,

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

              override fun getProfile(
                  userID: String,
                  onSuccess: (profile: ImmutableProfile?) -> Unit,
                  onFailure: (Exception) -> Unit
              ) {

            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_profile_display)
            
                    val profile: ImmutableProfile? = intent.getParcelableExtra(MainActivity.profile)

              Method invoke has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
              Open

                  /**
                   * Tells if the given project match the constraints
                   *
                   * @param project the project to check constraint
                   *
              Severity: Minor
              Found in app/src/main/java/com/sdp13epfl2021/projmag/model/ProjectFilter.kt - About 1 hr to fix

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

                  override fun onCreate(savedInstanceState: Bundle?) {
                      super.onCreate(savedInstanceState)
                      setContentView(R.layout.activity_profile_page)
              
              
              

                Method onActivityResult has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    /**
                     * This function is called after the user comes back
                     * from selecting a video from the file explorer
                     */
                    public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

                  Method buildFromMap has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          /**
                           * Build a project from the given map
                           *
                           * @param map : a map containing all fields of the project
                           * @param projectId : the id of the project

                    Method build has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            /**
                             * Function that allows create a Project
                             * returns a project wrapped in a success wrapper, or a failure with the explanation wrapped as a string
                             *
                             * @param id : project id from firebase

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

                          /**
                           * Load profile and cv for a particular candidature, then add the resulting candidature to the collection of candidatures if valid.
                           *
                           * @param candidatures a queue where candidature will be inserted.
                           * @param projectID the id of the project.

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

                            override fun onBindViewHolder(holder: CandidatureHolder, position: Int) {
                                val candidature = candidatures[position]
                                holder.firstnameView.text =
                                    resources.getString(R.string.waiting_firstname, candidature.profile.firstName)
                                holder.lastnameView.text =

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

                              override fun onCreate(savedInstanceState: Bundle?) {
                                  super.onCreate(savedInstanceState)
                                  setContentView(R.layout.project_filter_settings)
                          
                                  // Update the view for this activity
                            Severity
                            Category
                            Status
                            Source
                            Language