betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

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/image-rights.jsx and 1 other location - About 1 day to fix
app/src/scenes/representants-legaux/mobile/consentement.jsx on lines 278..308

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

Function StepEligibilite has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
Open

export default function StepEligibilite() {
  const isLoggedIn = !!useSelector((state) => state?.Auth?.young);
  const [STEPS, context, isBirthdayModificationDisabled, uri, bdcUri] = isLoggedIn
    ? [REINSCRIPTION_STEPS, ReinscriptionContext, true, "reinscription", "jetais-inscrit-en-2023-comment-me-reinscrire-en-2024"]
    : [PREINSCRIPTION_STEPS, PreInscriptionContext, false, "preinscription", "je-me-preinscris-et-cree-mon-compte-volontaire"];
Severity: Minor
Found in app/src/scenes/preinscription/steps/stepEligibilite.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

Function StepEligibilite has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
Open

export default function StepEligibilite() {
  const { young, isCLE } = useAuth();
  function isInFranceOrOut(young) {
    if (young.schoolCountry !== "FRANCE") {
      return true;
Severity: Minor
Found in app/src/scenes/inscription2023/steps/correction/stepEligibilite.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 create.jsx has 1226 lines of code (exceeds 700 allowed). Consider refactoring.
Open

import React, { useState } from "react";
import validator from "validator";

import { translate } from "@/utils";
import api from "@/services/api";
Severity: Major
Found in admin/src/scenes/volontaires/create.jsx - About 1 day to fix

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

    export default function Index() {
      const young = useSelector((state) => state.Auth.young);
      const [data, setData] = useState({
        domains: young?.domains || [],
        missionFormat: young?.missionFormat,

    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 Create has a Cognitive Complexity of 90 (exceeds 5 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: Minor
    Found in admin/src/scenes/missions/create.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

    Function CenterYoungIndex has 523 lines of code (exceeds 200 allowed). Consider refactoring.
    Open

    export default function CenterYoungIndex() {
      const [modalExportMail, setModalExportMail] = useState({ isOpen: false });
      const [filter, setFilter] = useState({});
      const [urlParams, setUrlParams] = useState("");
      const user = useSelector((state) => state.Auth.user);
    Severity: Major
    Found in admin/src/scenes/centersV2/youngs/index.jsx - About 1 day to fix

      Function Preferences has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function Preferences({
        young,
        data,
        setData,
        editPreference,
      Severity: Minor
      Found in admin/src/scenes/volontaires/view/phase2bis/preferences.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

      Function List has 517 lines of code (exceeds 200 allowed). Consider refactoring.
      Open

      export default function List() {
        const user = useSelector((state) => state.Auth.user);
        const [missions, setMissions] = useState();
        const [panel, setPanel] = useState(null);
      
      
      Severity: Major
      Found in admin/src/scenes/volontaires-responsible/listV2.jsx - About 1 day to fix

        Function DesignSystemPage has 509 lines of code (exceeds 200 allowed). Consider refactoring.
        Open

        export default function DesignSystemPage() {
          const [values, setValues] = React.useState({
            input1: "",
            input1Phone: "",
            input1PhoneZone: "",
        Severity: Major
        Found in admin/src/scenes/develop/DesignSystemPage.jsx - About 1 day to fix

          Function EditEquivalence has 509 lines of code (exceeds 200 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: Major
          Found in app/src/scenes/phase2/scenes/MonEquivalence/EditEquivalence.jsx - About 1 day to fix

            Function List has 503 lines of code (exceeds 200 allowed). Consider refactoring.
            Open

            export default function List() {
              const [mission, setMission] = useState(null);
              const [structure, setStructure] = useState();
              const user = useSelector((state) => state.Auth.user);
            
            
            Severity: Major
            Found in admin/src/scenes/missions/list.jsx - About 1 day to fix

              Function ConsentementForm has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
              Open

              function ConsentementForm({ young, token, step, parentId, cohort, classe }) {
                const history = useHistory();
                const [errors, setErrors] = useState({});
                const [saving, setSaving] = React.useState(false);
                const [imageRightsExplanationShown, setImageRightsExplanationShown] = useState(false);
              Severity: Minor
              Found in app/src/scenes/representants-legaux/mobile/consentement.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

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

                const setStatus = async (status, message, duration) => {
                  try {
                    const { ok, code, data } = await api.put("/application", { _id: application._id, status, missionDuration: duration });
                    if (!ok) return toastr.error("Une erreur s'est produite :", translate(code));
                    setApplication(data);
              Severity: Major
              Found in admin/src/components/selectStatusApplication.jsx and 1 other location - About 1 day to fix
              admin/src/scenes/volontaires/view/phase2bis/components/SelectStatusApplicationPhase2.jsx on lines 92..111

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

              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 setStatus = async (status, message, duration) => {
                  try {
                    const { ok, code, data } = await api.put("/application", { _id: application._id, status, missionDuration: duration });
                    if (!ok) return toastr.error("Une erreur s'est produite :", translate(code));
                    setApplication(data);
              admin/src/components/selectStatusApplication.jsx on lines 85..104

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

              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

                            {context.isYoungAdult !== "true" ? (
                              <>
                                <h2>Représenté par ses représentant légaux</h2>
                                <div>
                                  1) Le représentant légal du volontaire n°1 :
              Severity: Major
              Found in app/src/scenes/contract/index.jsx and 1 other location - About 1 day to fix
              app/src/scenes/contract/index.jsx on lines 113..149

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

              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

                              {context.isYoungAdult !== "true" ? (
                                <>
                                  <h2>Représenté par ses représentant légaux</h2>
                                  <div>
                                    1) Le représentant légal du volontaire n°1 :
              Severity: Major
              Found in app/src/scenes/contract/index.jsx and 1 other location - About 1 day to fix
              app/src/scenes/contract/index.jsx on lines 573..609

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

              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

                              {context.isYoungAdult !== "true" ? (
                                <>
                                  <div>
                                    Le volontaire, <ContractField name="youngFirstName" placeholder="Prénom" context={context} />
                                    <ContractField name="youngLastName" placeholder="Nom" context={context} />
              Severity: Major
              Found in app/src/scenes/contract/index.jsx and 1 other location - About 1 day to fix
              app/src/scenes/contract/index.jsx on lines 775..833

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

              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

                            {context.isYoungAdult !== "true" ? (
                              <>
                                <div>
                                  Le volontaire, <ContractField name="youngFirstName" placeholder="Prénom" context={context} />
                                  <ContractField name="youngLastName" placeholder="Nom" context={context} />
              Severity: Major
              Found in app/src/scenes/contract/index.jsx and 1 other location - About 1 day to fix
              app/src/scenes/contract/index.jsx on lines 316..374

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

              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 View has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function View() {
                const [classe, setClasse] = useState<ClassesRoutes["GetOne"]["response"]["data"]>();
                const [url, setUrl] = useState("");
                const [studentStatus, setStudentStatus] = useState<{ [key: string]: number }>({});
                const [showModaleCohort, setShowModaleCohort] = useState(false);
              Severity: Minor
              Found in admin/src/scenes/classe/view.tsx - 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

              Severity
              Category
              Status
              Source
              Language