betagouv/service-national-universel

View on GitHub
admin/src/scenes/settings/index.jsx

Summary

Maintainability
F
5 days
Test Coverage

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

    File index.jsx has 933 lines of code (exceeds 700 allowed). Consider refactoring.
    Open

    import React, { useState, useEffect } from "react";
    import { MdInfoOutline } from "react-icons/md";
    import { useSelector } from "react-redux";
    import { toastr } from "react-redux-toastr";
    import { useHistory } from "react-router-dom";
    Severity: Major
    Found in admin/src/scenes/settings/index.jsx - About 7 hrs to fix

      Function Settings has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function Settings() {
        const { user } = useSelector((state) => state.Auth);
      
        const urlParams = new URLSearchParams(window.location.search);
      
      
      Severity: Minor
      Found in admin/src/scenes/settings/index.jsx - About 5 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

                        <div className="flex flex-col gap-3">
                          <div className="flex items-center gap-2">
                            <p className="text-xs  font-medium text-gray-900">Annonce et visibilité des affectations par les volontaires</p>
                            <MdInfoOutline data-tip data-for="annonce_affectation" className="h-5 w-5 cursor-pointer text-gray-400" />
                            <ReactTooltip id="annonce_affectation" type="light" place="top" effect="solid" className="custom-tooltip-radius !opacity-100 !shadow-md" tooltipRadius="6">
      Severity: Major
      Found in admin/src/scenes/settings/index.jsx and 1 other location - About 1 hr to fix
      admin/src/scenes/settings/index.jsx on lines 801..836

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

      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="flex flex-col gap-3">
                          <div className="flex items-center gap-2">
                            <p className="text-xs  font-medium text-gray-900">Disponibilité des listes de transport par centre (envoi par email)</p>
                            <MdInfoOutline data-tip data-for="disponibilité_liste" className="h-5 w-5 cursor-pointer text-gray-400" />
                            <ReactTooltip id="disponibilité_liste" type="light" place="top" effect="solid" className="custom-tooltip-radius !opacity-100 !shadow-md" tooltipRadius="6">
      Severity: Major
      Found in admin/src/scenes/settings/index.jsx and 1 other location - About 1 hr to fix
      admin/src/scenes/settings/index.jsx on lines 636..668

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

      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