betagouv/service-national-universel

View on GitHub

Showing 730 of 941 total issues

File material-icons.js has 3657 lines of code (exceeds 700 allowed). Consider refactoring.
Open

export const list = [
  "abc",
  "ac_unit",
  "access_alarm",
  "access_alarms",
Severity: Major
Found in knowledge-base-public/src/utils/material-icons.js - About 1 wk to fix

    Function up has 1827 lines of code (exceeds 200 allowed). Consider refactoring.
    Open

      async up(db, client) {
        const youngIds = [
          "5ff4c48891eee307c6e53374",
          "601489d9f8309807d83fe6ed",
          "60193ccf25755907d83f85fe",

      Function validatePdtFile has a Cognitive Complexity of 220 (exceeds 5 allowed). Consider refactoring.
      Open

      export const validatePdtFile = async (
        filePath: string,
        cohortName: string,
        isCle: boolean,
      ): Promise<{
      Severity: Minor
      Found in api/src/pdt/import/pdtImportService.ts - About 4 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 young.ts has 1952 lines of code (exceeds 700 allowed). Consider refactoring.
      Open

      import mongoose, { Schema, InferSchemaType } from "mongoose";
      
      import { YOUNG_SOURCE_LIST, YOUNG_SOURCE } from "../constants/constants";
      import { PHONE_ZONES_NAMES_ARR } from "../phone-number";
      import { ROLES_LIST } from "../roles";
      Severity: Major
      Found in packages/lib/src/mongoSchema/young.ts - About 4 days to fix

        Function Index has 914 lines of code (exceeds 200 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: Major
        Found in app/src/scenes/contract/index.jsx - About 3 days to fix

          File 20240919125411-young-add-missing-inprogress-status.js has 1836 lines of code (exceeds 700 allowed). Consider refactoring.
          Open

          const { addSeconds } = require("date-fns");
          const { YoungModel } = require("../src/models");
          const { logger } = require("../src/logger");
          const { YOUNG_STATUS } = require("snu-lib");
          
          
          Severity: Major
          Found in api/migrations/20240919125411-young-add-missing-inprogress-status.js - About 3 days to fix

            Function Settings has 906 lines of code (exceeds 200 allowed). Consider refactoring.
            Open

            export default function Settings() {
              const { user } = useSelector((state) => state.Auth);
            
              const urlParams = new URLSearchParams(window.location.search);
            
            
            Severity: Major
            Found in admin/src/scenes/settings/index.jsx - About 3 days to fix

              Function AssetsPresentationPage has 729 lines of code (exceeds 200 allowed). Consider refactoring.
              Open

              export default function AssetsPresentationPage() {
                const [filter, setFilter] = useState("");
                useEffect(() => {
                  const filterText = filter && filter.trim().length > 0 ? filter.trim().toLowerCase() : "";
                  if (filterText && filterText.length > 0) {
              Severity: Major
              Found in admin/src/scenes/develop/AssetsPresentationPage.jsx - About 2 days to fix

                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

                  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

                      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
                        Severity
                        Category
                        Status
                        Source
                        Language