betagouv/service-national-universel

View on GitHub

Showing 927 of 945 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",

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

      export default function Index() {
        return (
          <Container>
            <Header>
              <Logos>
      Severity: Major
      Found in app/src/scenes/CGU/index.jsx and 1 other location - About 5 days to fix
      admin/src/scenes/CGU/index.jsx on lines 6..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 1212.

      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

      export default function CGU() {
        return (
          <Container>
            <Header>
              <Logos>
      Severity: Major
      Found in admin/src/scenes/CGU/index.jsx and 1 other location - About 5 days to fix
      app/src/scenes/CGU/index.jsx on lines 6..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 1212.

      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

      export default function DeletedVolontairePanel({ onChange, value }) {
        const [young, setYoung] = useState(null);
      
        useEffect(() => {
          (async () => {
      Severity: Major
      Found in admin/src/scenes/volontaires/deletedPanel.jsx and 1 other location - About 4 days to fix
      admin/src/scenes/inscription/deletedPanel.jsx on lines 14..81

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

      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

      export default function DeletedInscriptionPanel({ onChange, value }) {
        const [young, setYoung] = useState(null);
      
        useEffect(() => {
          (async () => {
      Severity: Major
      Found in admin/src/scenes/inscription/deletedPanel.jsx and 1 other location - About 4 days to fix
      admin/src/scenes/volontaires/deletedPanel.jsx on lines 14..81

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

      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 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/planDeTransport/planDeTransport/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

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

            router.put("/:id/export-injep/:exportDateKey", passport.authenticate(ROLES.ADMIN, { session: false, failWithError: true }), async (req: UserRequest, res: Response) => {
              try {
                const { error: exportDateKeyError, value: exportDateKey } = Joi.string()
                  .valid(...exportDateKeys)
                  .required()
            Severity: Major
            Found in api/src/cohort/cohortController.ts and 1 other location - About 3 days to fix
            api/src/cohort/cohortController.ts on lines 25..97

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

            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

            router.put("/:id/export-dsnj/:exportDateKey", passport.authenticate(ROLES.ADMIN, { session: false, failWithError: true }), async (req: UserRequest, res: Response) => {
              try {
                const { error: exportDateKeyError, value: exportDateKey } = Joi.string()
                  .valid(...exportDateKeys)
                  .required()
            Severity: Major
            Found in api/src/cohort/cohortController.ts and 1 other location - About 3 days to fix
            api/src/cohort/cohortController.ts on lines 99..171

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

            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 default function ExportBox({ title, availableFrom, availableUntil, onClick, onDownload, isDownloading = false }: Props) {
              const user = useSelector((state: AuthState) => state.Auth.user);
            
              const now = dayjs().startOf("day");
              const exportAvailableFrom = availableFrom ? dayjs(availableFrom).startOf("day") : null;
            Severity: Major
            Found in admin/src/scenes/dsnj-export/components/ExportBox.tsx and 1 other location - About 3 days to fix
            admin/src/scenes/injep-export/components/ExportBox.tsx on lines 20..66

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

            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 default function ExportBox({ title, availableFrom, availableUntil, onClick, onDownload, isDownloading = false }: Props) {
              const user = useSelector((state: AuthState) => state.Auth.user);
            
              const now = dayjs().startOf("day");
              const exportAvailableFrom = availableFrom ? dayjs(availableFrom).startOf("day") : null;
            Severity: Major
            Found in admin/src/scenes/injep-export/components/ExportBox.tsx and 1 other location - About 3 days to fix
            admin/src/scenes/dsnj-export/components/ExportBox.tsx on lines 20..66

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

            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

            export default function ModalPointagePresenceJDM({ isOpen, onSubmit, onCancel, values, value }) {
              const [isLoading, setIsLoading] = React.useState(false);
              const [viewList, setViewList] = React.useState(false);
              const isPlural = values?.length > 1;
            
            
            admin/src/scenes/centersV2/components/modals/ModalMultiPointagePresenceArrivee.jsx on lines 7..81

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

            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

            export default function ModalPointagePresenceJDM({ isOpen, onSubmit, onCancel, values, value }) {
              const [isLoading, setIsLoading] = React.useState(false);
              const [viewList, setViewList] = React.useState(false);
              const isPlural = values?.length > 1;
            
            
            admin/src/scenes/centersV2/components/modals/ModalMultiPointagePresenceJDM.jsx on lines 7..81

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

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

            export default function StepCoordonnees() {
              const [data, setData] = useState(defaultState);
              const [errors, setErrors] = useState({});
              const [corrections, setCorrections] = useState({});
              const [situationOptions, setSituationOptions] = 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

            File referentController.ts has 1553 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 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
                  Severity
                  Category
                  Status
                  Source
                  Language