betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function VolontairesStatutsDivers has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export default function VolontairesStatutsDivers({ filters, className = "" }) {
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);
  const [selectedTab, setSelectedTab] = useState("phase2");
  const [statuses, setStatuses] = useState({});

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

export function OutTable({ cohort, region, user }) {
  const history = useHistory();
  const [loadingQuery, setLoadingQuery] = React.useState(false);

  //info

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

function computeMissionFilter(filters, user) {
  let matchs = {};

  if (filters && filters.start) {
    matchs.endAt = { $gte: filters.start };
Severity: Minor
Found in api/src/controllers/dashboard/engagement.js - About 2 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 CreateContactForm has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export default function CreateContactForm({ data, setState, setStateRelatedMessage }) {
  const [email, setEmail] = useState("");
  const [birthdate, setBirthdate] = useState(data.birthDate);
  const [emailError, setEmailError] = useState("");
  const [birthdateError, setBirthdateError] = useState("");
Severity: Minor
Found in app/src/scenes/preinscription/components/CreateContactForm.tsx - About 2 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 245 lines of code (exceeds 200 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: Major
Found in admin/src/scenes/plan-transport/ligne-bus/View/View.jsx - About 2 hrs to fix

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

                <div className="relative" ref={refAttestationButton}>
                  <button
                    disabled={loading}
                    className="flex w-full items-center justify-between gap-3 rounded-full border-[1px] border-blue-600 bg-blue-600 px-3 py-2 disabled:cursor-wait disabled:opacity-50"
                    onClick={() => setOpenAttestationButton((e) => !e)}>
    Severity: Major
    Found in app/src/scenes/phase1/scenes/done/index.jsx and 1 other location - About 2 hrs to fix
    app/src/scenes/phase1/components/modals/InfoConvocation.jsx on lines 92..127

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

    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 mt-4" ref={refSelect}>
              <button
                disabled={loadingConvocation}
                className="flex w-full items-center justify-between gap-3 rounded-full border-[1px] border-blue-600 bg-blue-600 px-4 py-2 disabled:cursor-wait disabled:opacity-50"
                onClick={() => setSelectOpen((e) => !e)}>
    Severity: Major
    Found in app/src/scenes/phase1/components/modals/InfoConvocation.jsx and 1 other location - About 2 hrs to fix
    app/src/scenes/phase1/scenes/done/index.jsx on lines 204..242

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

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

    export default function Signin() {
      const dispatch = useDispatch();
      const user = useSelector((state) => state.Auth.user);
      const params = queryString.parse(location.search);
      const { redirect, unauthorized, email } = params;
    Severity: Minor
    Found in admin/src/scenes/auth/signin2FA.jsx - About 2 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 ModalButton has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function ModalButton({ primary, newPrimary, secondary, loading, children, disabled, ...rest }) {
      const getBackgroundColor = () => {
        if (disabled) return colors.grey;
        if (primary) return colors.purple;
        if (newPrimary) return colors.blue;
    Severity: Minor
    Found in admin/src/components/buttons/ModalButton.jsx - About 2 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 Action has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    const Action = ({ hit, structure }) => {
      const user = useSelector((state) => state.Auth.user);
      const dispatch = useDispatch();
      const history = useHistory();
      const [modal, setModal] = useState({ isOpen: false, onConfirm: null });
    Severity: Minor
    Found in admin/src/scenes/utilisateur/list.jsx - About 2 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 Line has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    const Line = ({ hit }) => {
      const [copiedElements, setCopiedElements] = React.useState({});
      const parent2 = hit.parent2FirstName && hit.parent2LastName && hit.parent2Status && hit.parent2Email && hit.parent2Phone;
    
      useEffect(() => {
    Severity: Minor
    Found in admin/src/scenes/session-phase1/view/List.jsx - About 2 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 DndFileInput has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function DndFileInput({ optional, value, name, errorMessage = requiredMessage, placeholder = "votre fichier", download, path, onChange, ...props }) {
      const [filesList, setFilesList] = useState(value);
      const [modal, setModal] = useState({ isOpen: false, onConfirm: null });
    
      useEffect(() => {
    Severity: Minor
    Found in app/src/components/dndFileInputV2.jsx - About 2 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 reindexESAllModels has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    async function reindexESAllModels() {
      try {
        const all_models = [
          ApplicationModel,
          // BusModel,
    Severity: Minor
    Found in api/src/scripts/reindex_es_all_models/index.js - About 2 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 canSearchInElasticSearch has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    function canSearchInElasticSearch(actor, index) {
      if (index === "mission") {
        return [ROLES.ADMIN, ROLES.REFERENT_REGION, ROLES.REFERENT_DEPARTMENT, ROLES.RESPONSIBLE, ROLES.SUPERVISOR].includes(actor.role);
      } else if (index === "school" || index === "schoolramses") {
        return [ROLES.ADMIN, ROLES.REFERENT_REGION, ROLES.REFERENT_DEPARTMENT, ROLES.RESPONSIBLE, ROLES.SUPERVISOR, ROLES.HEAD_CENTER, ROLES.VISITOR].includes(actor.role);
    Severity: Minor
    Found in packages/lib/src/roles.ts - About 2 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

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

    function SendContractLink({ contract, target }) {
      const [modal, setModal] = React.useState({ isOpen: false, onConfirm: null });
    
      return (
        <>
    Severity: Major
    Found in admin/src/scenes/volontaires/view/phase2bis/application.jsx and 1 other location - About 2 hrs to fix
    admin/src/scenes/volontaires-responsible/view/application.jsx on lines 531..569

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

    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

    function SendContractLink({ contract, target }) {
      const [modal, setModal] = React.useState({ isOpen: false, onConfirm: null });
    
      return (
        <>
    admin/src/scenes/volontaires/view/phase2bis/application.jsx on lines 500..538

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

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

    export async function sync(obj, type, { force } = { force: false }) {
      if (config.ENVIRONMENT !== "production" && !force) {
        logger.debug("no sync brevo");
        return;
      }
    Severity: Minor
    Found in api/src/brevo.ts - About 2 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 young.test.ts has 731 lines of code (exceeds 700 allowed). Consider refactoring.
    Open

    import fetch from "node-fetch";
    
    import request from "supertest";
    import jwt from "jsonwebtoken";
    import { ROLES, COHORTS, YOUNG_SOURCE, SENDINBLUE_TEMPLATES } from "snu-lib";
    Severity: Major
    Found in api/src/__tests__/young.test.ts - About 2 hrs to fix

      Function View has 243 lines of code (exceeds 200 allowed). Consider refactoring.
      Open

      export default function View() {
        const [classe, setClasse] = useState<ClassesRoutes["GetOne"]["response"]["data"]>();
        const [url, setUrl] = useState("");
        const [studentStatus, setStudentStatus] = useState<{ [key: string]: number }>({});
        const [showModaleCohort, setShowModaleCohort] = useState(false);
      Severity: Major
      Found in admin/src/scenes/classe/view.tsx - About 2 hrs to fix

        File viewMobile.jsx has 729 lines of code (exceeds 700 allowed). Consider refactoring.
        Open

        import React, { useEffect, useRef, useState } from "react";
        import { AiFillClockCircle, AiOutlineClockCircle } from "react-icons/ai";
        import { BsChevronDown } from "react-icons/bs";
        import { HiChevronDown, HiOutlineMail, HiPlus } from "react-icons/hi";
        import { IoMdInformationCircleOutline } from "react-icons/io";
        Severity: Major
        Found in app/src/scenes/missions/viewMobile.jsx - About 2 hrs to fix
          Severity
          Category
          Status
          Source
          Language