betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function checkBox has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

export function checkBox(doc, x, y, fillColor, checked = false) {
Severity: Minor
Found in api/src/templates/templateService.ts - About 35 mins to fix

    Function render has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function render(doc: typeof PDFDocument, young, session, cohort, cohesionCenter) {
    Severity: Minor
    Found in api/src/templates/certificate/phase1.ts - About 35 mins to fix

      Function generateBatchCertifPhase1 has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function generateBatchCertifPhase1(outStream, youngs, session, cohort, cohesionCenter) {
      Severity: Minor
      Found in api/src/templates/certificate/phase1.ts - About 35 mins to fix

        Function initDocument has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        export function initDocument(top, bottom, left, right, options = {}) {
        Severity: Minor
        Found in api/src/templates/templateService.ts - About 35 mins to fix

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

                        <div className="relative w-1/6" ref={refContractButton}>
                          <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 hover:border-blue-500 hover:bg-blue-500 disabled:cursor-wait disabled:opacity-50"
                            onClick={() => setOpenContractButton((e) => !e)}>
          Severity: Minor
          Found in app/src/scenes/missions/viewDesktop.jsx and 1 other location - About 35 mins to fix
          app/src/scenes/missions/viewMobile.jsx on lines 534..564

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

          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

                                        {
                                          key: "item1",
                                          action: async () => {
                                            try {
                                              if (youngSelected.length === 0) return;
          Severity: Minor
          Found in admin/src/scenes/centersV2/youngs/pointage.jsx and 1 other location - About 35 mins to fix
          admin/src/scenes/centersV2/youngs/pointage.jsx on lines 243..275

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

          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" ref={refContractButton}>
                        <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={() => setOpenContractButton((e) => !e)}>
          Severity: Minor
          Found in app/src/scenes/missions/viewMobile.jsx and 1 other location - About 35 mins to fix
          app/src/scenes/missions/viewDesktop.jsx on lines 210..240

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

          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 optionsScolarite = [
              { value: "NOT_SCOLARISE", label: "Non scolarisé(e)" },
              { value: "4eme", label: "4ème" },
              { value: "3eme", label: "3ème" },
              { value: "2ndePro", label: "2de professionnelle" },
          app/src/scenes/preinscription/steps/stepEligibilite.jsx on lines 40..53

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

          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 optionsScolarite = [
              { value: "NOT_SCOLARISE", label: "Non scolarisé(e)" },
              { value: "4eme", label: "4ème" },
              { value: "3eme", label: "3ème" },
              { value: "2ndePro", label: "2de professionnelle" },
          Severity: Minor
          Found in app/src/scenes/preinscription/steps/stepEligibilite.jsx and 1 other location - About 35 mins to fix
          app/src/scenes/inscription2023/steps/correction/stepEligibilite.jsx on lines 72..85

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

          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

                                        {
                                          key: "item2",
                                          action: async () => {
                                            try {
                                              if (youngSelected.length === 0) return;
          Severity: Minor
          Found in admin/src/scenes/centersV2/youngs/pointage.jsx and 1 other location - About 35 mins to fix
          admin/src/scenes/centersV2/youngs/pointage.jsx on lines 210..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 302.

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

          function createFolderView(context, imports) {
            // --- prepare elements
            const components = [];
            const title = `<div className="${titleClass}">${context.title}</div>`;
            for (const item of context.components) {
          Severity: Minor
          Found in admin/src/utils/generate-assets-presentation-page.js - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function Field({
            // Common
            type = "text",
            name,
            label,
          Severity: Minor
          Found in admin/src/components/ui/forms/Field.jsx - About 35 mins 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 SelectAction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function SelectAction({
            optionsGroup,
            title,
            Icon,
            disabled = false,
          Severity: Minor
          Found in admin/src/components/SelectAction.jsx - About 35 mins 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 Phase1PresenceFormBlock has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          const Phase1PresenceFormBlock = ({ className = "", young = null, values = null, setValues, setYoung, editing = false, setLoading, isYoungCheckinOpen }) => {
            const [isPresenceOnArrivalModalOpen, setIsPresenceOnArrivalModalOpen] = useState(false);
            const [isPresenceJDMModalOpen, setIsPresenceJDMModalOpen] = useState(false);
            const [isDepartureModalOpen, setIsDepartureModalOpen] = useState(false);
          
          

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

          const EditContact = ({ team, responsible, setResponsible, isLoading, handleSubmit, handleChange, handleDelete, onChange, errors, structure }) => {
            const user = useSelector((state) => state.Auth.user);
          
            const disabled = isLoading || !responsible.firstName || !responsible.lastName || !responsible.email;
          
          
          Severity: Minor
          Found in admin/src/scenes/structure/components/modals/TeamModal.jsx - About 35 mins 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 Note has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          const Note = ({ value }) => {
            const [expandNote, setExpandNote] = useState(false);
            const preview = value.substring(0, 100);
            const rest = value.substring(100);
          
          
          Severity: Minor
          Found in admin/src/components/views/PatchHistoric.jsx - About 35 mins 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 ModalDispense has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function ModalDispense({ isOpen, onCancel, youngId, onSuccess }) {
            const [valueDispense, setValueDispence] = useState("");
            const [text, setText] = useState("");
            const [disabled, setDisabled] = useState(true);
          
          
          Severity: Minor
          Found in admin/src/scenes/volontaires/components/ModalDispense.jsx - About 35 mins 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 Phase1ConfirmationFormBlock has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          const Phase1ConfirmationFormBlock = ({ className = "", young = null, values = null, setValues, setYoung, editing = false, setLoading }) => {
            const [isYoungModalAgreementOpen, setIsYoungModalAgreementOpen] = useState(false);
            const [isYoungTravelingByPlaneModalOpen, setIsYoungTravelingByPlaneModalOpen] = useState(false);
          
            const handleChangeYoungAgreement = ({ value }) => {

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

          const Note = ({ value }) => {
            const [expandNote, setExpandNote] = useState(false);
            const preview = value.substring(0, 100);
            const rest = value.substring(100);
          
          
          Severity: Minor
          Found in admin/src/components/historic.jsx - About 35 mins 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 downloadPDF has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          export default async function downloadPDF({ url, body, fileName, redirectUrl = "/auth/login?disconnected=1", errorTitle = "Une erreur est survenue lors du téléchargement" }) {
            try {
              const file = await api.openpdf(url, body);
              download(file, fileName);
            } catch (e) {
          Severity: Minor
          Found in admin/src/utils/download-pdf.js - About 35 mins 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

          Severity
          Category
          Status
          Source
          Language