betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function VolontairePhase0View has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

export default function VolontairePhase0View({ young, onChange, globalMode }) {
  const user = useSelector((state: AuthState) => state.Auth.user);
  const cohorts = useSelector((state: CohortState) => state.Cohorts);
  const [currentCorrectionRequestField, setCurrentCorrectionRequestField] = useState("");
  const [requests, setRequests] = useState<NonNullable<YoungDto["correctionRequests"]>>([]);
Severity: Minor
Found in admin/src/scenes/phase0/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

File index.js has 964 lines of code (exceeds 700 allowed). Consider refactoring.
Open

const express = require("express");
const passport = require("passport");
const fetch = require("node-fetch");
const queryString = require("querystring");
const crypto = require("crypto");
Severity: Major
Found in api/src/controllers/young/index.js - About 1 day to fix

    Function SessionList has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function SessionList({ center, setCenter, sessions, setSessions }: Props) {
      const history = useHistory();
      const cohorts = useSelector((state: CohortState) => state.Cohorts);
      const user = useSelector((state: AuthState) => state.Auth.user);
    
    
    Severity: Minor
    Found in admin/src/scenes/centersV2/components/sessions/SessionList.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

    Function ViewMobile has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function ViewMobile() {
      const [mission, setMission] = useState();
      const [modal, setModal] = useState(null);
      const [loading, setLoading] = useState(false);
      const [currentTab, setCurrentTab] = useState("mots");
    Severity: Minor
    Found in app/src/scenes/missions/viewMobile.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 Details has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function Details({ center, setCenter, sessions, setSessions }) {
      const history = useHistory();
    
      const user = useSelector((state: AuthState) => state.Auth.user);
      const [modalVisible, setModalVisible] = useState(false);
    Severity: Minor
    Found in admin/src/scenes/centersV2/view/CenterInformations.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

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

    export default function Create() {
      const history = useHistory();
    
      const user = useSelector((state: AuthState) => state.Auth.user);
      const cohorts = useSelector((state: CohortState) => state.Cohorts).filter((cohort) => cohort.type === COHORT_TYPE.CLE && canUpdateCohort(cohort, user));
    Severity: Minor
    Found in admin/src/scenes/classe/create.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

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

                    <ModalPJ
                      isOpen={modalDocument?.isOpen}
                      name={modalDocument?.name}
                      defaultOption={modalDocument?.defaultOption}
                      young={young}
    Severity: Major
    Found in admin/src/scenes/volontaires/view/phase2bis/application.jsx and 1 other location - About 1 day to fix
    admin/src/scenes/volontaires-responsible/view/application.jsx on lines 430..460

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

    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

                    <ModalPJ
                      isOpen={modalDocument?.isOpen}
                      name={modalDocument?.name}
                      defaultOption={modalDocument?.defaultOption}
                      young={young}
    admin/src/scenes/volontaires/view/phase2bis/application.jsx on lines 397..427

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

    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 Signup has 373 lines of code (exceeds 200 allowed). Consider refactoring.
    Open

    export default function Signup() {
      const dispatch = useDispatch();
      const [newUser, setNewUser] = React.useState(null);
    
      const user = useSelector((state) => state.Auth.user);
    Severity: Major
    Found in admin/src/scenes/auth/signup.jsx - About 7 hrs to fix

      Function translate has 372 lines of code (exceeds 200 allowed). Consider refactoring.
      Open

      const translate = (value) => {
        switch (value) {
          case "WAITING_REALISATION":
            return "En attente de réalisation";
          case "NONE":
      Severity: Major
      Found in packages/lib/src/translation.ts - About 7 hrs to fix

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

            if (ownAddress) {
              address = {
                [`parent${parentId}OwnAddress`]: "true",
                [`parent${parentId}Address`]: data.address.trim(),
                [`parent${parentId}ComplementAddress`]: data.addressComplement.trim(),
        Severity: Major
        Found in app/src/scenes/representants-legaux/mobile/consentement.jsx and 1 other location - About 7 hrs to fix
        app/src/scenes/representants-legaux/mobile/image-rights.jsx on lines 198..214

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

        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

            if (ownAddress) {
              address = {
                [`parent${parentId}OwnAddress`]: "true",
                [`parent${parentId}Address`]: data.address.trim(),
                [`parent${parentId}ComplementAddress`]: data.addressComplement.trim(),
        Severity: Major
        Found in app/src/scenes/representants-legaux/mobile/image-rights.jsx and 1 other location - About 7 hrs to fix
        app/src/scenes/representants-legaux/mobile/consentement.jsx on lines 176..192

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

        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

                {loading ? (
                  <Loading />
                ) : error ? (
                  <div className="text-[#DC5318]">{error}</div>
                ) : (
        admin/src/scenes/plan-transport/schema-repartition/group/GroupModificationEnhanced.jsx on lines 44..83

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

        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

                {loading ? (
                  <Loading />
                ) : error ? (
                  <div className="text-[#DC5318]">{error}</div>
                ) : (
        admin/src/scenes/plan-transport/schema-repartition/group/GroupAffectationSummary.jsx on lines 49..88

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

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

                    <div className="mt-2 flex flex-col gap-3">
                      <div className="flex items-center gap-2">
                        <p className="text-xs  font-medium text-gray-900">Affichage des centres </p>
                      </div>
                      <ToggleDate
        Severity: Major
        Found in admin/src/scenes/settings/CleSettings.tsx and 4 other locations - About 7 hrs to fix
        admin/src/scenes/settings/CleSettings.tsx on lines 24..66
        admin/src/scenes/settings/CleSettings.tsx on lines 67..109
        admin/src/scenes/settings/CleSettings.tsx on lines 116..158
        admin/src/scenes/settings/CleSettings.tsx on lines 202..244

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

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

                    <div className="flex flex-col gap-3">
                      <div className="flex items-center gap-2">
                        <p className="text-xs  font-medium text-gray-900">Modification des centres </p>
                      </div>
                      <ToggleDate
        Severity: Major
        Found in admin/src/scenes/settings/CleSettings.tsx and 4 other locations - About 7 hrs to fix
        admin/src/scenes/settings/CleSettings.tsx on lines 24..66
        admin/src/scenes/settings/CleSettings.tsx on lines 67..109
        admin/src/scenes/settings/CleSettings.tsx on lines 159..201
        admin/src/scenes/settings/CleSettings.tsx on lines 202..244

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

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

                    <div className="mt-2 flex flex-col gap-3">
                      <div className="flex items-center gap-2">
                        <p className="text-xs  font-medium text-gray-900">Affichage des points de rassemblement </p>
                      </div>
                      <ToggleDate
        Severity: Major
        Found in admin/src/scenes/settings/CleSettings.tsx and 4 other locations - About 7 hrs to fix
        admin/src/scenes/settings/CleSettings.tsx on lines 24..66
        admin/src/scenes/settings/CleSettings.tsx on lines 67..109
        admin/src/scenes/settings/CleSettings.tsx on lines 116..158
        admin/src/scenes/settings/CleSettings.tsx on lines 159..201

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

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

                  <div className="mt-2 flex flex-col gap-3">
                    <div className="flex items-center gap-2">
                      <p className="text-xs  font-medium text-gray-900">Affichage des cohortes </p>
                    </div>
                    <ToggleDate
        Severity: Major
        Found in admin/src/scenes/settings/CleSettings.tsx and 4 other locations - About 7 hrs to fix
        admin/src/scenes/settings/CleSettings.tsx on lines 24..66
        admin/src/scenes/settings/CleSettings.tsx on lines 116..158
        admin/src/scenes/settings/CleSettings.tsx on lines 159..201
        admin/src/scenes/settings/CleSettings.tsx on lines 202..244

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

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

                  <div className="flex flex-col gap-3">
                    <div className="flex items-center gap-2">
                      <p className="text-xs  font-medium text-gray-900">Modification des cohortes </p>
                    </div>
                    <ToggleDate
        Severity: Major
        Found in admin/src/scenes/settings/CleSettings.tsx and 4 other locations - About 7 hrs to fix
        admin/src/scenes/settings/CleSettings.tsx on lines 67..109
        admin/src/scenes/settings/CleSettings.tsx on lines 116..158
        admin/src/scenes/settings/CleSettings.tsx on lines 159..201
        admin/src/scenes/settings/CleSettings.tsx on lines 202..244

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

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

        export default function Phase2({ young, onChange }) {
          const [equivalences, setEquivalences] = React.useState([]);
          const [blocOpened, setBlocOpened] = useState("missions");
          const [editPreference, setEditPreference] = useState(false);
          const [savePreference, setSavePreference] = useState(false);
        Severity: Minor
        Found in admin/src/scenes/volontaires/view/phase2bis/view.jsx - About 7 hrs 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