betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function ListPDR has 242 lines of code (exceeds 200 allowed). Consider refactoring.
Open

export default function ListPDR(props) {
  const id = props.match && props.match.params && props.match.params.id;
  if (!id) return <div />;
  const cohort = new URLSearchParams(props.location.search).get("cohort");
  const [PDR, setPDR] = React.useState();
Severity: Major
Found in admin/src/scenes/plan-transport/ligne-bus/ListPDR.jsx - About 2 hrs to fix

    Function ModalRepresentant has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function ModalRepresentant({ isOpen, setIsOpen, onSubmit, onDelete, structure }) {
      const [isLoading, setIsLoading] = useState(false);
      const [data, setData] = useState(structure.structureManager || {});
      const [modalDelete, setModalDelete] = useState({ isOpen: false });
      const [errors, setErrors] = useState({});
    Severity: Minor
    Found in admin/src/scenes/structure/components/modals/ModalRepresentant.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 ModalCreation has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function ModalCreation({ isOpen, onCancel, defaultPDR = null, editable = true }) {
      const user = useSelector((state) => state.Auth.user);
      const history = useHistory();
      const [availableCohorts, setAvailableCohorts] = useState([]);
    
    
    Severity: Minor
    Found in admin/src/scenes/pointDeRassemblement/components/ModalCreation.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 PatchHistoric has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function PatchHistoric({ model, value, field, previewNumber = 1 }) {
      const [data, setData] = useState();
      const [isExpand, setIsExpand] = useState(false);
    
      const getPatches = async () => {
    Severity: Minor
    Found in admin/src/components/views/PatchHistoric.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 FieldSituationsParticulieres has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function FieldSituationsParticulieres({
      group = null,
      name,
      label,
      young,
    Severity: Minor
    Found in admin/src/scenes/phase0/components/FieldSituationsParticulieres.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 Field has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function Field({
      group = null,
      name,
      label,
      value,
    Severity: Minor
    Found in admin/src/scenes/phase0/components/Field.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 StepEmailValidation has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function StepEmailValidation() {
      const dispatch = useDispatch();
      const history = useHistory();
      const { search } = useLocation();
      const { token } = queryString.parse(search);
    Severity: Minor
    Found in app/src/scenes/preinscription/EmailValidation.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 StepConsentements has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function StepConsentements() {
      const { young, isCLE } = useAuth();
      const history = useHistory();
      const [disabled, setDisabled] = React.useState(true);
      const [loading, setLoading] = React.useState(false);
    Severity: Minor
    Found in app/src/scenes/inscription2023/steps/stepConsentements.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 updateStatusPhase1WithOldRules has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    async function updateStatusPhase1WithOldRules(young, validationDate, isTerminale, user) {
      try {
        const now = new Date();
        // Cette constante nous permet de vérifier si un jeune a passé sa date de validation (basé sur son grade)
        const isValidationDatePassed = now >= validationDate;
    Severity: Minor
    Found in api/src/utils/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 ButtonAddCoordinator has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function ButtonAddCoordinator({ etablissement, onChange }: Props) {
      const [modalAddCoordinator, setModalAddCoordinator] = useState(false);
      const [newCoordinator, setNewCoordinator] = useState<NewCoordinator>({ firstName: "", lastName: "", email: "" });
      const [errors, setErrors] = useState<Errors>({});
    
    
    Severity: Minor
    Found in admin/src/scenes/etablissement/components/ButtonAddCoordinator.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 ModalRattacherCentre has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function ModalRattacherCentre({ isOpen, onSuccess, onCancel, user, defaultCentre = null, editable = true }: Props) {
      const history = useHistory();
      const cohorts = useSelector((state: CohortState) => state.Cohorts);
      const availableCohorts = cohorts.filter((c) => isSessionEditionOpen(user, c)).map((c) => c.name);
    
    
    Severity: Minor
    Found in admin/src/scenes/centersV2/components/ModalRattacherCentre.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 GeneralInfos has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function GeneralInfos({ classe, setClasse, edit, setEdit, errors, rights, cohorts, user, isLoading, setIsLoading, onCancel, onCheckInfo, validatedYoung }: Props) {
      const containerActionList = ({ edit, setEdit, canEdit }) => {
        if (edit) {
          return [
            <div key="actions" className="flex items-center justify-end ml-6">
    Severity: Minor
    Found in admin/src/scenes/classe/components/GeneralInfos.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

    File translateFieldsModel.js has 724 lines of code (exceeds 700 allowed). Consider refactoring.
    Open

    const translateFieldStructure = (f) => {
      switch (f) {
        case "name":
          return "Nom";
        case "website":
    Severity: Major
    Found in admin/src/utils/translateFieldsModel.js - About 2 hrs to fix

      Function Profil has 239 lines of code (exceeds 200 allowed). Consider refactoring.
      Open

      export default function Profil() {
        useDocumentTitle("Mon profil");
      
        const user = useSelector((state) => state.Auth.user);
        const dispatch = useDispatch();
      Severity: Major
      Found in admin/src/scenes/profil/index.jsx - About 2 hrs to fix

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

        router.get("/toRegion/:cohort/:region", passport.authenticate("referent", { session: false, failWithError: true }), async (req, res) => {
          try {
            const { error, value } = Joi.object({
              cohort: Joi.string().required(),
              region: Joi.string().required(),
        Severity: Major
        Found in api/src/controllers/planDeTransport/table-de-repartition.js and 1 other location - About 2 hrs to fix
        api/src/controllers/planDeTransport/table-de-repartition.js on lines 162..180

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

        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

        router.get("/fromRegion/:cohort/:region", passport.authenticate("referent", { session: false, failWithError: true }), async (req, res) => {
          try {
            const { error, value } = Joi.object({
              cohort: Joi.string().required(),
              region: Joi.string().required(),
        Severity: Major
        Found in api/src/controllers/planDeTransport/table-de-repartition.js and 1 other location - About 2 hrs to fix
        api/src/controllers/planDeTransport/table-de-repartition.js on lines 182..200

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

        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 onSubmit = async () => {
            if (loading || disabled) return;
            setLoading(true);
            try {
              const { token } = queryString.parse(location.search);
        Severity: Major
        Found in app/src/scenes/auth/mobile/reset.jsx and 1 other location - About 2 hrs to fix
        app/src/scenes/auth/desktop/reset.jsx on lines 22..35

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

        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 onSubmit = async () => {
            if (loading || disabled) return;
            setLoading(true);
            try {
              const { token } = queryString.parse(location.search);
        Severity: Major
        Found in app/src/scenes/auth/desktop/reset.jsx and 1 other location - About 2 hrs to fix
        app/src/scenes/auth/mobile/reset.jsx on lines 22..35

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

        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

              <Popover.Group>
                <Popover className="relative flex grow-0 justify-end md:flex-none">
                  {({ open }) => (
                    <>
                      <Popover.Button className="flex h-10 w-10 items-center justify-center gap-3 rounded-full border-none bg-blue-50 p-0 text-sm font-bold uppercase tracking-tight text-[#32257F]">
        knowledge-base-public/src/components/navigation/YoungMenu.jsx on lines 21..68

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

        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

            <Popover.Group>
              <Popover className="relative flex grow-0 justify-end md:flex-none">
                {({ open }) => (
                  <>
                    <Popover.Button className="flex h-10 w-10 items-center justify-center gap-3 rounded-full border-none bg-blue-50 p-0 text-sm font-bold uppercase tracking-tight text-[#32257F]">
        knowledge-base-public/src/components/navigation/AdminMenu.jsx on lines 103..150

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

        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