betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function SectionConsentements has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

export default function SectionConsentements({ young, onChange, readonly = false, cohort }) {
  const [confirmModal, setConfirmModal] = useState(null);
  const [pdfDownloading, setPdfDownloading] = useState("");

  const user = useSelector((state) => state.Auth.user);

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

export function FileField({ young, label, className = "", onChange, mode, statusField, fileType, updateYoung }) {
  const [opened, setOpened] = useState(false);
  const [file, setFile] = useState(null);
  const [confirmDeleteModal, setConfirmDeleteModal] = useState(false);

Severity: Minor
Found in admin/src/scenes/phase0/components/FileField.jsx - About 5 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

Function validatePdtFile has 318 lines of code (exceeds 200 allowed). Consider refactoring.
Open

export const validatePdtFile = async (
  filePath: string,
  cohortName: string,
  isCle: boolean,
): Promise<{
Severity: Major
Found in api/src/pdt/import/pdtImportService.ts - About 5 hrs to fix

    Consider simplifying this complex logical expression.
    Open

      if (contract) {
        initialValues = { ...contract, sendMessage: false };
      } else {
        initialValues = {
          youngFirstName: young.firstName,
    Severity: Critical
    Found in admin/src/components/Contract.jsx - About 5 hrs to fix

      Function Phase2Application has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function Phase2Application({ young, onChange }) {
        const [application, setApplication] = React.useState(null);
        const [mission, setMission] = React.useState();
        const [tags, setTags] = React.useState();
        const [contract, setContract] = React.useState(null);
      Severity: Minor
      Found in admin/src/scenes/volontaires/view/phase2bis/application.jsx - About 5 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

      Function Settings has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function Settings() {
        const { user } = useSelector((state) => state.Auth);
      
        const urlParams = new URLSearchParams(window.location.search);
      
      
      Severity: Minor
      Found in admin/src/scenes/settings/index.jsx - About 5 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

      Function Info has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function Info({ bus, setBus, dataForCheck, nbYoung, cohort }) {
        const user = useSelector((state) => state.Auth.user);
        const [editInfo, setEditInfo] = React.useState(false);
        const [isLoading, setIsLoading] = React.useState(false);
        const [errors, setErrors] = React.useState({});
      Severity: Minor
      Found in admin/src/scenes/plan-transport/ligne-bus/View/components/Info.jsx - About 5 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

      Function GroupGatheringPlaces has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function GroupGatheringPlaces({ group, className = "", onChangeStep, onChange, previousStep }) {
        const [filter, setFilter] = useState("");
        const [type, setType] = useState("department");
        const [list, setList] = useState([]);
        const [loading, setLoading] = useState(0);

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

      export default function StepConfirm() {
        const isLoggedIn = !!useSelector((state) => state?.Auth?.young);
        const [context, bdcURI] = isLoggedIn
          ? [ReinscriptionContext, "jetais-inscrit-en-2023-comment-me-reinscrire-en-2024"]
          : [PreInscriptionContext, "je-me-preinscris-et-cree-mon-compte-volontaire"];
      Severity: Minor
      Found in app/src/scenes/preinscription/steps/stepConfirm.jsx - About 5 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

      Function ChangeSejour has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function ChangeSejour() {
        const young = useSelector((state) => state.Auth.young);
        const [newSejour, setNewSejour] = useState("");
        const [motif, setMotif] = useState("");
        const [modalConfirmControlOk, setmodalConfirmControlOk] = useState(false);
      Severity: Minor
      Found in app/src/scenes/phase1/changeSejour.jsx - About 5 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

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

      export const useFileUpload = () => {
        const [files, setFiles] = useState([]);
        const [error, setError] = useState("");
      
        const addFiles = useCallback(
      Severity: Major
      Found in admin/src/components/FileUpload.jsx and 1 other location - About 5 hrs to fix
      app/src/components/FileUpload.jsx on lines 79..109

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

      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

      export const useFileUpload = () => {
        const [files, setFiles] = useState([]);
        const [error, setError] = useState("");
      
        const addFiles = useCallback(
      Severity: Major
      Found in app/src/components/FileUpload.jsx and 1 other location - About 5 hrs to fix
      admin/src/components/FileUpload.jsx on lines 77..107

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

      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

            try {
              const controller = new AbortController();
              const { signal } = controller;
      
              window.addEventListener("beforeunload", () => controller.abort());
      Severity: Major
      Found in app/src/services/api.js and 1 other location - About 5 hrs to fix
      admin/src/services/api.js on lines 168..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 250.

      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

            try {
              const controller = new AbortController();
              const { signal } = controller;
      
              window.addEventListener("beforeunload", () => controller.abort());
      Severity: Major
      Found in admin/src/services/api.js and 1 other location - About 5 hrs to fix
      app/src/services/api.js on lines 130..163

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

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

      export default function Index() {
        const user = useSelector((state) => state.Auth.user);
        const [isPrepaMilitary, setIsPrepaMilitary] = useState(false);
        const [structureId, setStructureId] = useState([]);
      
      

        Function Youngs has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function Youngs({ mission, applications, updateMission }) {
          const user = useSelector((state) => state.Auth.user);
          const history = useHistory();
          const [young, setYoung] = useState();
          const checkboxRef = React.useRef();
        Severity: Minor
        Found in admin/src/scenes/missions/view/youngs.jsx - About 5 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

        Function StepUpload has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function StepUpload() {
          const device = useDevice();
          let { category } = useParams();
          const young = useSelector((state) => state.Auth.young);
          if (!category) category = young.latestCNIFileCategory;
        Severity: Minor
        Found in app/src/scenes/inscription2023/steps/stepUpload.jsx - About 5 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

        File auth.js has 842 lines of code (exceeds 700 allowed). Consider refactoring.
        Open

        const jwt = require("jsonwebtoken");
        const crypto = require("crypto");
        const Joi = require("joi");
        const { getDb } = require("./mongo");
        
        
        Severity: Major
        Found in api/src/auth.js - About 5 hrs to fix

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

            return (
              <>
                <DropdownButton
                  key="edit"
                  type="secondary"
          admin/src/scenes/volontaire-cle/consent/ButtonActionGroupConsent.tsx on lines 45..120

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

          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

            return (
              <>
                <DropdownButton
                  key="edit"
                  type="secondary"
          admin/src/scenes/volontaire-cle/validation/ButtonActionGroupValidation.tsx on lines 44..117

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

          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