cook4me/android

View on GitHub

Showing 61 of 61 total issues

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

        if (userId != null) {
            store.collection(USER_VOTE_PATH).add(mapOf("id" to id, "userId" to userId, "note" to note)).await()
        }
app/src/main/java/ch/epfl/sdp/cook4me/persistence/repository/RecipeNoteRepository.kt on lines 60..62

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

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

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

fun ProfileInfosField(
    icon: ImageVector,
    preview: String,
    value: String,
    isError: Boolean,
Severity: Minor
Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/common/form/Fields.kt and 1 other location - About 55 mins to fix
app/src/main/java/ch/epfl/sdp/cook4me/ui/common/form/Fields.kt on lines 121..128

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

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

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

fun BiosField(
    icon: ImageVector,
    preview: String,
    value: String,
    isError: Boolean,
Severity: Minor
Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/common/form/Fields.kt and 1 other location - About 55 mins to fix
app/src/main/java/ch/epfl/sdp/cook4me/ui/common/form/Fields.kt on lines 98..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 87.

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

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

class TupperwareRepository(
    private val store: FirebaseFirestore = FirebaseFirestore.getInstance(),
    private val storage: FirebaseStorage = FirebaseStorage.getInstance(),
    private val auth: FirebaseAuth = FirebaseAuth.getInstance()
) {
app/src/main/java/ch/epfl/sdp/cook4me/persistence/repository/RecipeRepository.kt on lines 18..22

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

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

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

class RecipeRepository(
    private val store: FirebaseFirestore = FirebaseFirestore.getInstance(),
    private val storage: FirebaseStorage = FirebaseStorage.getInstance(),
    private val auth: FirebaseAuth = FirebaseAuth.getInstance()
) {
app/src/main/java/ch/epfl/sdp/cook4me/persistence/repository/TupperwareRepository.kt on lines 15..19

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

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

                        Modifier
                            .fieldModifier()
                            .testTag(stringResource(R.string.tag_password_repeat))
                            .onFocusChanged {
                                passwordAgainState.onFocusChange(it.isFocused)
app/src/main/java/ch/epfl/sdp/cook4me/ui/user/signup/SignUpScreen.kt on lines 89..94
app/src/main/java/ch/epfl/sdp/cook4me/ui/user/signup/SignUpScreen.kt on lines 103..108

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

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

                        Modifier
                            .fieldModifier()
                            .testTag(stringResource(R.string.tag_email))
                            .onFocusChanged {
                                emailState.onFocusChange(it.isFocused)
app/src/main/java/ch/epfl/sdp/cook4me/ui/user/signup/SignUpScreen.kt on lines 103..108
app/src/main/java/ch/epfl/sdp/cook4me/ui/user/signup/SignUpScreen.kt on lines 117..122

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

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

                        Modifier
                            .fieldModifier()
                            .testTag(stringResource(R.string.tag_password))
                            .onFocusChanged {
                                passwordState.onFocusChange(it.isFocused)
app/src/main/java/ch/epfl/sdp/cook4me/ui/user/signup/SignUpScreen.kt on lines 89..94
app/src/main/java/ch/epfl/sdp/cook4me/ui/user/signup/SignUpScreen.kt on lines 117..122

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

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

    suspend fun deleteAll() {
        val ids = store.getAllObjectsFromCollection<Tupperware>(COLLECTION_PATH).keys
        ids.forEach {
            delete(it)
        }
app/src/main/java/ch/epfl/sdp/cook4me/persistence/repository/RecipeRepository.kt on lines 56..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 80.

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

    suspend fun deleteAll() {
        val ids = store.getAllObjectsFromCollection<Recipe>(COLLECTION_PATH).keys
        ids.forEach {
            delete(it)
        }
app/src/main/java/ch/epfl/sdp/cook4me/persistence/repository/TupperwareRepository.kt on lines 60..65

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

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

    val recipeSteps = "Steps: \n ${recipe.recipeSteps.map{s -> "\t - $s"}.joinToString("\n")}"
Severity: Minor
Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/recipe/RecipeScreen.kt and 1 other location - About 50 mins to fix
app/src/main/java/ch/epfl/sdp/cook4me/ui/recipe/RecipeScreen.kt on lines 20..20

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

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

    val recipeIngredients = "Ingredients: \n ${recipe.ingredients.map{s -> "\t - $s"}.joinToString("\n")}"
Severity: Minor
Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/recipe/RecipeScreen.kt and 1 other location - About 50 mins to fix
app/src/main/java/ch/epfl/sdp/cook4me/ui/recipe/RecipeScreen.kt on lines 21..21

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

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

/**
 * A component that asks for an address
 * @param question the question to be displayed
 * @param onAddressChanged the function to be called when the address is changed
 */
Severity: Minor
Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/event/form/AddressField.kt - About 45 mins 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 InputField has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    value: String,
    @StringRes question: Int,
    modifier: Modifier = Modifier,
    @StringRes label: Int? = null,
    isError: Boolean = false,
Severity: Minor
Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/common/form/Fields.kt - About 45 mins to fix

    Method MatchDialog has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
    Open

    @Composable
    fun MatchDialog(
        user: String,
        otherUser: String,
        context: Context,
    Severity: Minor
    Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/tupperware/swipe/MatchDialog.kt - About 45 mins 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 BiosField has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        icon: ImageVector,
        preview: String,
        value: String,
        isError: Boolean,
        onNewValue: (String) -> Unit,
    Severity: Minor
    Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/common/form/Fields.kt - About 45 mins to fix

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

          @StringRes onCancelText: Int,
          @StringRes onSaveText: Int,
          modifier: Modifier = Modifier,
          isLoading: Boolean = false,
          onCancelClick: () -> Unit,
      Severity: Minor
      Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/common/form/FormButtons.kt - About 45 mins to fix

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

            icon: ImageVector,
            preview: String,
            value: String,
            isError: Boolean,
            onNewValue: (String) -> Unit,
        Severity: Minor
        Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/common/form/Fields.kt - About 45 mins to fix

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

              modifier: Modifier = Modifier,
              counterValue: Int = 0,
              onChange: (Int) -> Unit = {},
              userVote: Int = 0,
              canClick: Boolean = true,
          Severity: Minor
          Found in app/src/main/java/ch/epfl/sdp/cook4me/ui/recipe/feed/VoteIcon.kt - About 45 mins to fix

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

                    IconButton(onClick = { onVote(true) }, enabled = canClick) {
                        Icon(
                            imageVector = thumbsUp,
                            contentDescription = "Upvote",
                            tint = if (upvote.value) pressedColor else notPressedColor
            app/src/main/java/ch/epfl/sdp/cook4me/ui/recipe/feed/VoteIcon.kt on lines 90..96

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

            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