betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

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

export default function IconDomain({ domain, bgStyle = null, iconStyle = "text-white h-8 w-8" }) {
  const [icon, setIcon] = React.useState(null);

  React.useEffect(() => {
    switch (domain) {
Severity: Major
Found in admin/src/components/IconDomain.jsx and 1 other location - About 7 hrs to fix
admin/src/components/IconDomainRounded.jsx on lines 14..59

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

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

  const handleUpload = (event) => {
    const files = event.target.files;
    for (let index = 0; index < Object.keys(files).length; index++) {
      let i = Object.keys(files)[index];
      if (!isFileSupported(files[i].name)) return toastr.error(`Le type du fichier ${files[i].name} n'est pas supporté.`);
admin/src/scenes/volontaires/components/ModalFilesEquivalence.jsx on lines 41..55
admin/src/scenes/volontaires/view/FormEquivalence.jsx on lines 44..58

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

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

export default function SchemaRepartition({ region, department }) {
  const regOrDep = region || department || "";
  useDocumentTitle(`Schéma de répartition${regOrDep ? ` - ${regOrDep}` : ""}`);

  const history = useHistory();

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

export default function Home() {
  useDocumentTitle("Accueil");
  const { young, isCLE } = useAuth();
  const cohort = getCohort(young.cohort);

Severity: Minor
Found in app/src/scenes/home/index.jsx - About 6 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 AlerteMessageForm has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

export default function AlerteMessageForm({ message, isNew, onIsNewChange, onMessagesChange }: Props) {
  const [editInfo, setEditInfo] = React.useState(isNew);
  const [isLoading, setIsLoading] = React.useState(false);
  const [errors, setErrors] = React.useState<ErrorForm>({});
  const [data, setData] = React.useState<Partial<AlerteMessageDto>>(message || {});
Severity: Minor
Found in admin/src/scenes/alerte/AlerteMessageForm.tsx - About 6 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

      const { error: filesError, value: files } = Joi.array()
        .items(
          Joi.alternatives().try(
            Joi.object({
              name: Joi.string().required(),
Severity: Major
Found in api/src/controllers/young/documents.js and 1 other location - About 6 hrs to fix
api/src/controllers/SNUpport.js on lines 416..436

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

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

    const { error: filesError, value: files } = Joi.array()
      .items(
        Joi.alternatives().try(
          Joi.object({
            name: Joi.string().required(),
Severity: Major
Found in api/src/controllers/SNUpport.js and 1 other location - About 6 hrs to fix
api/src/controllers/young/documents.js on lines 118..138

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

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 index.js has 903 lines of code (exceeds 700 allowed). Consider refactoring.
Open

const AWS = require("aws-sdk");
const https = require("https");
const http = require("http");
const passwordValidator = require("password-validator");
const sanitizeHtml = require("sanitize-html");
Severity: Major
Found in api/src/utils/index.js - About 6 hrs to fix

    File classe.test.ts has 899 lines of code (exceeds 700 allowed). Consider refactoring.
    Open

    import request from "supertest";
    import passport from "passport";
    import { Types } from "mongoose";
    const { ObjectId } = Types;
    import emailsEmitter from "../../emails";
    Severity: Major
    Found in api/src/__tests__/cle/classe.test.ts - About 6 hrs to fix

      Function AddressInput has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function AddressInput({
        keys,
        values,
        handleChange,
        errors,
      Severity: Minor
      Found in admin/src/components/addressInput.jsx - About 6 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 View has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function View(props) {
        const [data, setData] = React.useState(null);
        const [dataForCheck, setDataForCheck] = React.useState(null);
        const [demandeDeModification, setDemandeDeModification] = React.useState(null);
        const [panelOpen, setPanelOpen] = React.useState(false);
      Severity: Minor
      Found in admin/src/scenes/plan-transport/ligne-bus/View/View.jsx - About 6 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 AssetsPresentationPage.jsx has 896 lines of code (exceeds 700 allowed). Consider refactoring.
      Open

      /* eslint-disable prettier/prettier */
      /* ------------------------------------------------------
         Cette Page est générée automatiquement par le script /utils/generate-assets-presentation-page.js
         ------------------------------------------------------ */
      
      
      Severity: Major
      Found in admin/src/scenes/develop/AssetsPresentationPage.jsx - About 6 hrs to fix

        Function Phase1 has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function Phase1(props) {
          const user = useSelector((state) => state.Auth.user);
          const [meetingPoint, setMeetingPoint] = useState();
          const [young, setYoung] = useState(props.young);
          const [cohesionCenter, setCohesionCenter] = useState();
        Severity: Minor
        Found in admin/src/scenes/volontaires/view/phase1.jsx - About 6 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 TicketView has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function TicketView(props) {
          const [ticket, setTicket] = useState();
          const [sending, setSending] = useState(false);
          const [message, setMessage] = useState();
          const [messages, setMessages] = useState([]);
        Severity: Minor
        Found in app/src/scenes/echanges/View.jsx - About 6 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 MissionFilters has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function MissionFilters({ filters, setFilters }) {
          const { young } = useAuth();
          const [cityFilter, setCityFilter] = useState({ zip: young.zip, city: young.city, location: young.location });
          const [query, setQuery] = useState("");
          const [referentManagerPhase2, setReferentManagerPhase2] = useState();
        Severity: Minor
        Found in app/src/scenes/missions/list/components/MissionFilters.jsx - About 6 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 ligne-de-bus.js has 888 lines of code (exceeds 700 allowed). Consider refactoring.
        Open

        const express = require("express");
        const router = express.Router();
        const passport = require("passport");
        const { LigneBusModel } = require("../../models");
        const { LigneToPointModel } = require("../../models");
        Severity: Major
        Found in api/src/controllers/planDeTransport/ligne-de-bus.js - About 6 hrs to fix

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

              <div className="relative h-full w-full" style={{ fontFamily: "Marianne" }} ref={ref}>
                {/* select item */}
                <button
                  className="flex w-full h-full cursor-pointer items-center justify-between gap-3 bg-transparent px-3 py-1 disabled:cursor-wait disabled:opacity-50"
                  style={{ fontFamily: "Marianne" }}
          admin/src/scenes/edit-transport/components/Select.jsx on lines 28..63

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                        <ModalPJ
                          isOpen={modalDocument?.isOpen}
                          name={modalDocument?.name}
                          young={young}
                          application={mission.application}
          Severity: Major
          Found in app/src/scenes/missions/viewMobile.jsx and 1 other location - About 6 hrs to fix
          app/src/scenes/missions/viewDesktop.jsx on lines 411..438

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

          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

                <div className="relative">
                  {/* select item */}
                  <button
                    className="flex min-w-[100px] h-8 cursor-pointer items-center justify-between gap-3 rounded-lg border border-gray-300 bg-white px-3 py-3 disabled:cursor-wait disabled:opacity-50"
                    style={{ fontFamily: "Marianne" }}
          Severity: Major
          Found in admin/src/scenes/edit-transport/components/Select.jsx and 1 other location - About 6 hrs to fix
          admin/src/scenes/edit-transport/list/components/SelectTable.jsx on lines 27..63

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                        <ModalPJ
                          isOpen={modalDocument?.isOpen}
                          name={modalDocument?.name}
                          young={young}
                          application={mission.application}
          Severity: Major
          Found in app/src/scenes/missions/viewDesktop.jsx and 1 other location - About 6 hrs to fix
          app/src/scenes/missions/viewMobile.jsx on lines 411..438

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

          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