betagouv/service-national-universel

View on GitHub
admin/src/components/Contract.jsx

Summary

Maintainability
F
1 wk
Test Coverage

File Contract.jsx has 1500 lines of code (exceeds 700 allowed). Consider refactoring.
Open

import Img from "../assets/logo-snu.png";
import React, { useEffect, useState } from "react";
import { Row } from "reactstrap";
import styled from "styled-components";
import { Formik, Field } from "formik";
Severity: Major
Found in admin/src/components/Contract.jsx - About 2 days to fix

    Function Contract has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function Contract({ young }) {
      const history = useHistory();
      const user = useSelector((state) => state.Auth.user);
      const [modal, setModal] = useState({ isOpen: false, onConfirm: null });
    
    
    Severity: Minor
    Found in admin/src/components/Contract.jsx - About 1 day 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

    Consider simplifying this complex logical expression.
    Open

      if (contract) {
        initialValues = { ...contract, sendMessage: false };
      } else {
        initialValues = {
          youngFirstName: young.firstName,
    Severity: Critical
    Found in admin/src/components/Contract.jsx - About 5 hrs to fix

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

                          {!isYoungAdult ? (
                            <>
                              <div>
                                Le volontaire, <ContractField name="youngFirstName" placeholder="Prénom" context={context} />
                                <ContractField name="youngLastName" placeholder="Nom" context={context} />
      Severity: Major
      Found in admin/src/components/Contract.jsx and 1 other location - About 1 day to fix
      admin/src/components/Contract.jsx on lines 605..663

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

      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

                              {!isYoungAdult ? (
                                <>
                                  <div>
                                    Le volontaire, <ContractField name="youngFirstName" placeholder="Prénom" context={context} />
                                    <ContractField name="youngLastName" placeholder="Nom" context={context} />
      Severity: Major
      Found in admin/src/components/Contract.jsx and 1 other location - About 1 day to fix
      admin/src/components/Contract.jsx on lines 1337..1395

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

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

                            <div>
                              <h2>CHARTE DE LA RÉSERVE CIVIQUE</h2>
                              <h3>1° Principes directeurs</h3>
                              <p>
                                La réserve civique permet à toute personne qui le souhaite de s&apos;engager à servir les valeurs de la République en participant à des missions
      Severity: Major
      Found in admin/src/components/Contract.jsx and 3 other locations - About 1 day to fix
      admin/src/components/Contract.jsx on lines 1397..1482
      app/src/scenes/contract/index.jsx on lines 376..459
      app/src/scenes/contract/index.jsx on lines 835..918

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

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

                        <div>
                          <h2>CHARTE DE LA RÉSERVE CIVIQUE</h2>
                          <h3>1° Principes directeurs</h3>
                          <p>
                            La réserve civique permet à toute personne qui le souhaite de s&apos;engager à servir les valeurs de la République en participant à des missions
      Severity: Major
      Found in admin/src/components/Contract.jsx and 3 other locations - About 1 day to fix
      admin/src/components/Contract.jsx on lines 665..755
      app/src/scenes/contract/index.jsx on lines 376..459
      app/src/scenes/contract/index.jsx on lines 835..918

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

      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 style={{ display: "flex", justifyContent: "center", marginBottom: 20 }}>
                        <LoadingButton
                          onClick={async () => {
                            if (contract?.invitationSent === "true") {
                              const confirmText =
      Severity: Major
      Found in admin/src/components/Contract.jsx and 1 other location - About 5 hrs to fix
      admin/src/components/Contract.jsx on lines 1486..1530

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

      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 style={{ display: "flex", justifyContent: "center", marginBottom: 20 }}>
                    <LoadingButton
                      onClick={async () => {
                        if (contract?.invitationSent === "true") {
                          const confirmText =
      Severity: Major
      Found in admin/src/components/Contract.jsx and 1 other location - About 5 hrs to fix
      admin/src/components/Contract.jsx on lines 759..803

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

      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

      There are no issues that match your filters.

      Category
      Status