betagouv/service-national-universel

View on GitHub

Showing 923 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",

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

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

              nodes: [
                {
                  __typename: "Dossier",
                  id: "dossierId",
                  number: 1000,
      Severity: Major
      Found in api/src/__tests__/fixtures/cle/appelAProjet.ts and 1 other location - About 4 days to fix
      api/src/providers/demarcheSimplifiee/demarcheSimplifieeProvider.test.ts on lines 97..365

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

      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

              nodes: [
                {
                  __typename: "Dossier",
                  id: "dossierId",
                  number: 1000,
      api/src/__tests__/fixtures/cle/appelAProjet.ts on lines 16..284

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

      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

      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

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

          describe("POST /young/forgot_password_reset", () => {
            it("should return return 400 when missing token or password", async () => {
              res = await request(getAppHelper()).post("/young/forgot_password_reset").send({ token: "foo" });
              expect(res.status).toBe(400);
        
        
        Severity: Major
        Found in api/src/__tests__/young-auth.test.ts and 1 other location - About 3 days to fix
        api/src/__tests__/referent-auth.test.ts on lines 256..316

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

        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

          describe("POST /referent/forgot_password_reset", () => {
            it("should return return 400 when missing token or password", async () => {
              res = await request(getAppHelper()).post("/referent/forgot_password_reset").send({ token: "foo" });
              expect(res.status).toBe(400);
        
        
        Severity: Major
        Found in api/src/__tests__/referent-auth.test.ts and 1 other location - About 3 days to fix
        api/src/__tests__/young-auth.test.ts on lines 295..355

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

        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

          describe("POST /referent/reset_password", () => {
            it("should return return 400 when missing password", async () => {
              res = await request(getAppHelper()).post("/referent/reset_password");
              expect(res.status).toBe(400);
        
        
        Severity: Major
        Found in api/src/__tests__/referent-auth.test.ts and 1 other location - About 3 days to fix
        api/src/__tests__/young-auth.test.ts on lines 215..276

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

        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

          describe("POST /young/reset_password", () => {
            it("should return return 400 when missing password", async () => {
              res = await request(getAppHelper()).post("/young/reset_password");
              expect(res.status).toBe(400);
        
        
        Severity: Major
        Found in api/src/__tests__/young-auth.test.ts and 1 other location - About 3 days to fix
        api/src/__tests__/referent-auth.test.ts on lines 176..237

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

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

              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

              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

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