betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

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

      query: {
        bool: {
          must: [
            { match_all: {} },

Severity: Major
Found in api/src/controllers/elasticsearch/dashboard/inscription.js and 1 other location - About 1 day to fix
api/src/controllers/elasticsearch/dashboard/inscription.js on lines 494..525

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

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

      query: {
        bool: {
          must: [
            { match_all: {} },
            queryFilters?.cohort?.length ? { terms: { "cohort.keyword": queryFilters.cohort } } : null,
Severity: Major
Found in api/src/controllers/elasticsearch/dashboard/inscription.js and 1 other location - About 1 day to fix
api/src/controllers/elasticsearch/dashboard/inscription.js on lines 389..420

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

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 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 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 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 d&apos;intérêt
Severity: Major
Found in app/src/scenes/contract/index.jsx and 3 other locations - About 1 day to fix
admin/src/components/Contract.jsx on lines 665..755
admin/src/components/Contract.jsx on lines 1397..1482
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 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 d&apos;intérêt
Severity: Major
Found in app/src/scenes/contract/index.jsx and 3 other locations - About 1 day to fix
admin/src/components/Contract.jsx on lines 665..755
admin/src/components/Contract.jsx on lines 1397..1482
app/src/scenes/contract/index.jsx on lines 376..459

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

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

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

export default function SchoolEditor({ young, onChange, className, showBackgroundColor = true }) {
  const [schoolInFrance, setSchoolInFrance] = useState(true);
  const [countries, setCountries] = useState([]);
  const [cities, setCities] = useState([]);
  const [schools, setSchools] = useState([]);
Severity: Minor
Found in admin/src/scenes/phase0/components/SchoolEditor.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

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

export default function StepProfil() {
  const [data, setData] = React.useContext(PreInscriptionContext);
  const [error, setError] = React.useState({});
  const [loading, setLoading] = React.useState(false);
  const keyList = ["firstName", "lastName", "phone", "phoneZone", "email", "emailConfirm", "password", "confirmPassword"];
Severity: Minor
Found in app/src/scenes/preinscription/steps/stepProfil.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

File excelExports.ts has 1091 lines of code (exceeds 700 allowed). Consider refactoring.
Open

const translateIndexes = (index) => {
  switch (index) {
    case "young":
      return "volontaires";
    case "mission":
Severity: Major
Found in packages/lib/src/excelExports.ts - About 1 day to fix

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

            choices: {
              "Domaine de MIG 1": data.young.domains[0],
              "Domaine de MIG 2": data.young.domains[1],
              "Domaine de MIG 3": data.young.domains[2],
              "Projet professionnel": translate(data.young.professionnalProject),
    Severity: Major
    Found in admin/src/scenes/volontaires/view/phase2bis/view.jsx and 1 other location - About 1 day to fix
    admin/src/scenes/missions/view/youngs.jsx on lines 169..190

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

    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

            choices: {
              "Domaine de MIG 1": data.young.domains[0],
              "Domaine de MIG 2": data.young.domains[1],
              "Domaine de MIG 3": data.young.domains[2],
              "Projet professionnel": translate(data.young.professionnalProject),
    Severity: Major
    Found in admin/src/scenes/missions/view/youngs.jsx and 1 other location - About 1 day to fix
    admin/src/scenes/volontaires/view/phase2bis/view.jsx on lines 228..249

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

    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 Create has 439 lines of code (exceeds 200 allowed). Consider refactoring.
    Open

    export default function Create() {
      const history = useHistory();
      const location = useLocation();
      const [selectedRepresentant, setSelectedRepresentant] = useState(1);
      const [loading, setLoading] = useState(false);
    Severity: Major
    Found in admin/src/scenes/volontaires/create.jsx - About 1 day to fix

      Function YoungHeader has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function YoungHeader({ young, tab, onChange, phase = YOUNG_PHASE.INSCRIPTION, isStructure = false, applicationId = null }) {
        const user = useSelector((state) => state.Auth.user);
        const [isConfirmDeleteModalOpen, setIsConfirmDeleteModalOpen] = useState(false);
        const [confirmModal, setConfirmModal] = useState(null);
        const [viewedNotes, setVieweNotes] = useState([]);
      Severity: Minor
      Found in admin/src/scenes/phase0/components/YoungHeader.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

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

          return (
            <div className="relative flex w-full flex-col items-center">
              <div className="relative flex w-full items-center">
                <input
                  className={`w-full py-2.5 pl-10 pr-3 text-sm text-gray-500 transition-colors ${className}`}
      Severity: Major
      Found in admin/src/scenes/support-center/dashboard.jsx and 1 other location - About 1 day to fix
      admin/src/scenes/public-support-center/index.jsx on lines 104..144

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

      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

        return (
          <div className="relative flex w-full flex-col items-center">
            <div className="relative flex w-full items-center">
              <input
                className={`w-full py-2.5 pl-10 pr-3 text-sm text-gray-500 transition-colors ${className}`}
      Severity: Major
      Found in admin/src/scenes/public-support-center/index.jsx and 1 other location - About 1 day to fix
      admin/src/scenes/support-center/dashboard.jsx on lines 101..141

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

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

      export default function CenterYoungIndex() {
        const [modalExportMail, setModalExportMail] = useState({ isOpen: false });
        const [filter, setFilter] = useState({});
        const [urlParams, setUrlParams] = useState("");
        const user = useSelector((state) => state.Auth.user);
      Severity: Minor
      Found in admin/src/scenes/centersV2/youngs/index.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

      Function AssetsPresentationPage has 427 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 app/src/scenes/develop/AssetsPresentationPage.jsx - About 1 day to fix
        Severity
        Category
        Status
        Source
        Language