betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

File Contract.jsx has 1500 lines of code (exceeds 700 allowed). Consider refactoring.
Open

import Img from "../assets/logo-snu.png";
import React, { useEffect, useState } from "react";
import { Row } from "reactstrap";
import styled from "styled-components";
import { Formik, Field } from "formik";
Severity: Major
Found in admin/src/components/Contract.jsx - About 2 days to fix

    Function Create has a Cognitive Complexity of 128 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function Create() {
      const history = useHistory();
      const location = useLocation();
      const [selectedRepresentant, setSelectedRepresentant] = useState(1);
      const [loading, setLoading] = useState(false);
    Severity: Minor
    Found in admin/src/scenes/volontaires/create.jsx - About 2 days 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

    Function StepCoordonnees has a Cognitive Complexity of 128 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function StepCoordonnees() {
      const [wasBornInFrance, setWasBornInFrance] = useState("true");
      const [data, setData] = useState(defaultState);
      const [errors, setErrors] = useState({});
      const [corrections, setCorrections] = useState({});
    Severity: Minor
    Found in app/src/scenes/inscription2023/steps/stepCoordonnees.jsx - About 2 days 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

    Function DetailsView has a Cognitive Complexity of 126 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function DetailsView({ mission, setMission, getMission }) {
      const [values, setValues] = useState(mission);
      const [editing, setEditing] = useState(false);
      const [loading, setLoading] = useState(false);
      const [errors, setErrors] = useState({});
    Severity: Minor
    Found in admin/src/scenes/missions/view/details.jsx - About 2 days 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

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

          <tr className="flex items-center py-3 px-4 hover:bg-gray-50">
            <td className="w-[5%]">
              <input type="checkbox" className="w-5 h-5 ml-1" checked={selectedYoungs.some((y) => y._id === young._id)} onChange={() => handleSelectYoung(young)} />
            </td>
            <td className="w-[25%] table-cell truncate cursor-pointer" onClick={() => history.push(`/volontaire/${young._id}`)}>
    admin/src/scenes/volontaire-cle/consent/YoungRowConsent.tsx on lines 55..99

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

    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

          <tr className="flex items-center py-3 px-4 hover:bg-gray-50">
            <td className="w-[5%]">
              <input type="checkbox" className="w-5 h-5 ml-1" checked={selectedYoungs.some((y) => y._id === young._id)} onChange={() => handleSelectYoung(young)} />
            </td>
            <td className="w-[25%] table-cell truncate cursor-pointer" onClick={() => history.push(`/volontaire/${young._id}`)}>
    Severity: Major
    Found in admin/src/scenes/volontaire-cle/consent/YoungRowConsent.tsx and 1 other location - About 2 days to fix
    admin/src/scenes/volontaire-cle/validation/YoungRowValidation.tsx on lines 54..98

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

    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

    Function ImageRightsForm has a Cognitive Complexity of 120 (exceeds 5 allowed). Consider refactoring.
    Open

    function ImageRightsForm({ young, token, parentId }) {
      const history = useHistory();
      const [errors, setErrors] = useState({});
      const [saving, setSaving] = React.useState(false);
      const address = getInitialAdress(young, parentId);
    Severity: Minor
    Found in app/src/scenes/representants-legaux/mobile/image-rights.jsx - About 2 days 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

    File referentController.ts has 1415 lines of code (exceeds 700 allowed). Consider refactoring.
    Open

    import express, { Response } from "express";
    import { logger } from "../logger";
    import passport from "passport";
    import crypto from "crypto";
    import jwt from "jsonwebtoken";
    Severity: Major
    Found in api/src/referent/referentController.ts - About 2 days to fix

      Function StepCoordonnees has 652 lines of code (exceeds 200 allowed). Consider refactoring.
      Open

      export default function StepCoordonnees() {
        const [wasBornInFrance, setWasBornInFrance] = useState("true");
        const [data, setData] = useState(defaultState);
        const [errors, setErrors] = useState({});
        const [corrections, setCorrections] = useState({});
      Severity: Major
      Found in app/src/scenes/inscription2023/steps/stepCoordonnees.jsx - About 2 days to fix

        Function StepRepresentants has a Cognitive Complexity of 117 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function StepRepresentants() {
          const young = useSelector((state) => state.Auth.young);
          const history = useHistory();
          const parent1Keys = ["parent1Status", "parent1FirstName", "parent1LastName"];
          const parent2Keys = ["parent2Status", "parent2FirstName", "parent2LastName"];
        Severity: Minor
        Found in app/src/scenes/inscription2023/steps/stepRepresentants.jsx - About 2 days 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

        Function Details has a Cognitive Complexity of 114 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function Details({ user, setUser, currentUser }) {
          const [structures, setStructures] = useState([]);
          const [sessionOptions, setSessionOptions] = useState([]);
          const [sessionsWhereUserIsHeadCenter, setSessionsWhereUserIsHeadCenter] = useState([]);
          const [mode, setMode] = useState(MODE_DEFAULT);
        Severity: Minor
        Found in admin/src/scenes/utilisateur/edit/details.jsx - About 2 days 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

        Function EditEquivalence has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function EditEquivalence() {
          const young = useSelector((state) => state.Auth.young);
          const keyList = ["type", "desc", "structureName", "address", "zip", "city", "startDate", "endDate", "contactFullName", "contactEmail", "files", "missionDuration"];
          const [data, setData] = useState();
          const [openType, setOpenType] = useState(false);
        Severity: Minor
        Found in app/src/scenes/phase2/scenes/MonEquivalence/EditEquivalence.jsx - About 2 days 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

        Function SectionParents has a Cognitive Complexity of 103 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function SectionParents({ young, onStartRequest, currentRequest, onCorrectionRequestChange, requests, globalMode, onChange, oldCohort, readonly }) {
          const [currentParent, setCurrentParent] = useState(1);
          const [hasSpecificSituation, setHasSpecificSituation] = useState(false);
          const [sectionMode, setSectionMode] = useState(globalMode);
          const [data, setData] = useState(filterDataForYoungSection(young, "parent"));
        Severity: Minor
        Found in admin/src/scenes/phase0/components/sections/SectionParents.jsx - About 2 days 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

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

          const onSubmit = async () => {
            if (loading || disabled) return;
            if (password !== confirmPassword) return setError({ text: "Les mots de passe ne correspondent pas" });
            setLoading(true);
            try {
        Severity: Major
        Found in app/src/scenes/auth/mobile/signupInvite.jsx and 1 other location - About 2 days to fix
        app/src/scenes/auth/desktop/signupInvite.jsx on lines 41..79

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

        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

          const onSubmit = async () => {
            if (loading || disabled) return;
            if (password !== confirmPassword) return setError({ text: "Les mots de passe ne correspondent pas" });
            setLoading(true);
            try {
        Severity: Major
        Found in app/src/scenes/auth/desktop/signupInvite.jsx and 1 other location - About 2 days to fix
        app/src/scenes/auth/mobile/signupInvite.jsx on lines 41..79

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

        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

        Function Create has 561 lines of code (exceeds 200 allowed). Consider refactoring.
        Open

        export default function Create(props) {
          const structureIdFromParams = props?.match?.params?.id;
          const urlParams = new URLSearchParams(window.location.search);
          const duplicate = urlParams.get("duplicate");
          const [values, setValues] = useState({
        Severity: Major
        Found in admin/src/scenes/missions/create.jsx - About 1 day to fix

          Function CustomMission has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function CustomMission({ young, onChange }) {
            const cohortList = useSelector((state) => state.Cohorts);
            const history = useHistory();
            const [values, setValues] = useState({
              status: "VALIDATED",
          Severity: Minor
          Found in admin/src/scenes/volontaires/view/customMission.jsx - About 1 day 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

          File translation.ts has 1239 lines of code (exceeds 700 allowed). Consider refactoring.
          Open

          import { FUNCTIONAL_ERRORS } from "./constants/functionalErrors";
          
          const translate = (value) => {
            switch (value) {
              case "WAITING_REALISATION":
          Severity: Major
          Found in packages/lib/src/translation.ts - About 1 day to fix

            Function Index has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
            Open

            export default function Index() {
              const [context, setContext] = useState(null);
              const history = useHistory();
              const token = new URLSearchParams(window.location.search).get("token");
            
            
            Severity: Minor
            Found in app/src/scenes/contract/index.jsx - About 1 day 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

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

                      <div className="border-t-solid border-t-[1px] border-t-[#E5E5E5] py-[20px]">
                        <div className="flex items-center">
                          <div className="flex-grow-1">
                            <b>Je réside</b> {formattedAddress}
                          </div>
            Severity: Major
            Found in app/src/scenes/representants-legaux/mobile/consentement.jsx and 1 other location - About 1 day to fix
            app/src/scenes/representants-legaux/mobile/image-rights.jsx on lines 279..309

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

            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