baublet/w8mngr

View on GitHub
client/pages/UserPreferences.tsx

Summary

Maintainability
F
4 days
Test Coverage

Function UserPreferences has 246 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function UserPreferences() {
  const { data } = useGetCurrentUserQuery();
  const [loading, setLoading] = React.useState(true);
  const [, setUserPreferences] = React.useState<PreferencesForm>({
    birthday: "",
Severity: Major
Found in client/pages/UserPreferences.tsx - About 1 day to fix

    File UserPreferences.tsx has 302 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React from "react";
    import { boolean, date, number, object, string } from "yup";
    
    import { getWithDefault, objectEntries } from "../../shared";
    import { GhostButton } from "../components/Button/Ghost";
    Severity: Minor
    Found in client/pages/UserPreferences.tsx - About 3 hrs to fix

      Function submit has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const submit = React.useCallback(async () => {
          setLoading(true);
      
          const values = preferencesForm.getValues();
      
      
      Severity: Minor
      Found in client/pages/UserPreferences.tsx - About 1 hr to fix

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

                            <div className="w-1/3">
                              <Input
                                className="w-full"
                                disabled={!preferencesForm.getValue("faturdays")}
                                label="Carbs"
        Severity: Major
        Found in client/pages/UserPreferences.tsx and 3 other locations - About 2 hrs to fix
        client/pages/UserPreferences.tsx on lines 231..243
        client/pages/UserPreferences.tsx on lines 246..256
        client/pages/UserPreferences.tsx on lines 268..278

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

        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

                            <div className="w-1/3">
                              <Input
                                className="w-full"
                                disabled={!preferencesForm.getValue("faturdays")}
                                label="Protein"
        Severity: Major
        Found in client/pages/UserPreferences.tsx and 3 other locations - About 2 hrs to fix
        client/pages/UserPreferences.tsx on lines 231..243
        client/pages/UserPreferences.tsx on lines 246..256
        client/pages/UserPreferences.tsx on lines 257..267

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

        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

                            <div className="w-full">
                              <Input
                                className="w-full"
                                disabled={!preferencesForm.getValue("faturdays")}
                                label="Faturday Calories"
        Severity: Major
        Found in client/pages/UserPreferences.tsx and 3 other locations - About 2 hrs to fix
        client/pages/UserPreferences.tsx on lines 246..256
        client/pages/UserPreferences.tsx on lines 257..267
        client/pages/UserPreferences.tsx on lines 268..278

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

        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

                            <div className="w-1/3">
                              <Input
                                className="w-full"
                                disabled={!preferencesForm.getValue("faturdays")}
                                label="Fat"
        Severity: Major
        Found in client/pages/UserPreferences.tsx and 3 other locations - About 2 hrs to fix
        client/pages/UserPreferences.tsx on lines 231..243
        client/pages/UserPreferences.tsx on lines 257..267
        client/pages/UserPreferences.tsx on lines 268..278

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

        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

                        <div className="md:w-1/2 flex flex-col gap-2">
                          <Input
                            label="Height"
                            placeholder={`e.g., 5 ft 3 inches`}
                            type="text"
        Severity: Major
        Found in client/pages/UserPreferences.tsx and 1 other location - About 2 hrs to fix
        client/pages/UserPreferences.tsx on lines 199..211

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

        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

                        <div className="md:w-1/2 flex flex-col gap-2">
                          <Input
                            label="Birthday"
                            placeholder={`e.g., October 13, 1982`}
                            type="text"
        Severity: Major
        Found in client/pages/UserPreferences.tsx and 1 other location - About 2 hrs to fix
        client/pages/UserPreferences.tsx on lines 186..198

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

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

                          <div>
                            <Toggle
                              id="faturdays"
                              label="Faturdays"
                              labelPosition="right"
        Severity: Major
        Found in client/pages/UserPreferences.tsx and 6 other locations - About 1 hr to fix
        client/components/Foods/FoodMeasurementsForm.tsx on lines 127..135
        client/components/Foods/FoodMeasurementsForm.tsx on lines 136..144
        client/components/Foods/FoodMeasurementsForm.tsx on lines 145..153
        client/components/Foods/FoodMeasurementsForm.tsx on lines 154..162
        client/components/Foods/FoodMeasurementsForm.tsx on lines 163..171
        client/components/Foods/FoodMeasurementsForm.tsx on lines 172..180

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

        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

        function FeatureDescription({ children }: React.PropsWithChildren<{}>) {
          return <div className="text-xs text-slate-500">{children}</div>;
        }
        Severity: Major
        Found in client/pages/UserPreferences.tsx and 3 other locations - About 50 mins to fix
        client/Application.tsx on lines 116..118
        client/components/Foods/AddableFoodMeasurements.tsx on lines 292..294
        client/pages/Nutrition.tsx on lines 71..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 51.

        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

        There are no issues that match your filters.

        Category
        Status