betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function View has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

export default function View(props) {
  const [ticket, setTicket] = useState();
  const [sending, setSending] = useState(false);
  const [message, setMessage] = useState();
  const [messages, setMessages] = useState([]);
Severity: Minor
Found in admin/src/scenes/support-center/ticket/view.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

Function Pagination has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

export default function Pagination({ currentPageNumber, setCurrentPageNumber, itemsCountTotal, itemsCountOnCurrentPage, size = 20, setSize }) {
  const displayedPages = 3;
  const pageCount = Math.ceil(itemsCountTotal / size);
  const lastDisplayPage = Math.min(pageCount - 1, Math.max(displayedPages, currentPageNumber));
  const firstDisplayPage = Math.max(lastDisplayPage - displayedPages + 1, 1);
Severity: Minor
Found in app/src/components/nav/Pagination.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

Function Signin has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

export default function Signin() {
  const [email, setEmail] = React.useState("");
  const [password, setPassword] = React.useState("");
  const [confirmPassword, setConfirmPassword] = React.useState("");
  const [showPassword, setShowPassword] = React.useState(false);
Severity: Minor
Found in app/src/scenes/auth/mobile/signupInvite.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

Function AccountRepresentantsPage has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

const AccountRepresentantsPage = () => {
  const young = useSelector((state) => state.Auth.young);
  const dispatch = useDispatch();

  const [formValues, setFormValues] = useState(getInitialFormValues(young));
Severity: Minor
Found in app/src/scenes/account/scenes/representants/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

Function signin has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

  async signin(req, res) {
    const { error, value } = Joi.object({ email: Joi.string().lowercase().trim().email().required(), password: Joi.string().required() }).unknown().validate(req.body);
    if (error) return res.status(400).send({ ok: false, code: ERRORS.EMAIL_AND_PASSWORD_REQUIRED });

    const { password, email } = value;
Severity: Minor
Found in api/src/auth.js - 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

Function StepProfil has 304 lines of code (exceeds 200 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: Major
Found in app/src/scenes/preinscription/steps/stepProfil.jsx - About 5 hrs to fix

    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

    Function Signin has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function Signin() {
      const [email, setEmail] = React.useState("");
      const [password, setPassword] = React.useState("");
      const [confirmPassword, setConfirmPassword] = React.useState("");
      const [showPassword, setShowPassword] = React.useState(false);
    Severity: Minor
    Found in app/src/scenes/auth/desktop/signupInvite.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

    Function List has 302 lines of code (exceeds 200 allowed). Consider refactoring.
    Open

    export default function List() {
      const [sessionsPhase1, setSessionsPhase1] = useState(null);
      const [bus, setBus] = useState(null);
      const [classes, setClasses] = useState(null);
      const [youngList, setYoungList] = useState([]);
    Severity: Major
    Found in admin/src/scenes/volontaire-cle/List.tsx - About 5 hrs to fix

      Function getFilterArray has 301 lines of code (exceeds 200 allowed). Consider refactoring.
      Open

      export const getFilterArray = (user, bus, session, classes, etablissements) => {
        return [
          { title: "Cohorte", name: "cohort", parentGroup: "Général", missingLabel: "Non renseigné", sort: (e) => orderCohort(e) },
          { title: "Cohorte d'origine", name: "originalCohort", parentGroup: "Général", missingLabel: "Non renseigné", sort: orderCohort },
          { title: "Statut", name: "status", parentGroup: "Général", missingLabel: "Non renseigné", translate: translateInscriptionStatus, defaultValue: ["VALIDATED"] },
      Severity: Major
      Found in admin/src/scenes/volontaires/utils/index.js - About 5 hrs to fix

        Function Create has 300 lines of code (exceeds 200 allowed). Consider refactoring.
        Open

        export default function Create() {
          const history = useHistory();
        
          const user = useSelector((state: AuthState) => state.Auth.user);
          const cohorts = useSelector((state: CohortState) => state.Cohorts).filter((cohort) => cohort.type === COHORT_TYPE.CLE && canUpdateCohort(cohort, user));
        Severity: Major
        Found in admin/src/scenes/classe/create.tsx - About 5 hrs to fix

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

            const updateApplicationStatus = (status) => {
              if (youngSelected.length === 0) return;
              const isPlural = youngSelected.length > 1;
              setModalMultiAction({
                isOpen: true,
          Severity: Major
          Found in admin/src/scenes/volontaires-responsible/listV2.jsx and 1 other location - About 5 hrs to fix
          admin/src/scenes/missions/view/youngs.jsx on lines 240..264

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

          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 updateApplicationStatus = (status) => {
              if (youngSelected.length === 0) return;
              const isPlural = youngSelected.length > 1;
              setModalMultiAction({
                isOpen: true,
          Severity: Major
          Found in admin/src/scenes/missions/view/youngs.jsx and 1 other location - About 5 hrs to fix
          admin/src/scenes/volontaires-responsible/listV2.jsx on lines 193..217

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

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

          export default function UserPanel({ onChange, value }) {
            const [structure, setStructure] = useState();
            const user = useSelector((state) => state.Auth.user);
            const dispatch = useDispatch();
            const history = useHistory();
          Severity: Minor
          Found in admin/src/scenes/utilisateur/panel.jsx - About 4 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 Done has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function Done() {
            const young = useSelector((state) => state.Auth.young) || {};
            const [openAttestationButton, setOpenAttestationButton] = React.useState(false);
            const [modalOpen, setModalOpen] = React.useState(false);
            const [loading, setLoading] = React.useState(false);
          Severity: Minor
          Found in app/src/scenes/phase1/scenes/done/index.jsx - About 4 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 StepWaitingConsent has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function StepWaitingConsent() {
            const { young, logout, isCLE } = useAuth();
            const [disabled, setDisabled] = React.useState(false);
            const [error, setError] = React.useState({});
            const notAuthorised = young?.parentAllowSNU === "false";
          Severity: Minor
          Found in app/src/scenes/inscription2023/steps/stepDone.jsx - About 4 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 Line has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

          const Line = ({ hit, onClick, selected }) => {
            const [copied, setCopied] = React.useState(false);
            const [copied1, setCopied1] = React.useState(false);
            const [copied2, setCopied2] = React.useState(false);
            const parent2 = hit.parent2FirstName && hit.parent2LastName && hit.parent2Status && hit.parent2Email && hit.parent2Phone;
          Severity: Minor
          Found in admin/src/scenes/session-phase1/view/MobileList.jsx - About 4 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 Step has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

          const Step = ({ step }) => {
            function renderStep(step) {
              if (step === STEPS.TOKEN_INVALIDE) return <MobileTokenInvalide step={step} />;
              if (step === STEPS.CNI_INVALIDE) return <MobileCniInvalide step={step} />;
              if (step === STEPS.CNI_INVALIDE_DONE) return <MobileCniInvalideDone step={step} />;
          Severity: Minor
          Found in app/src/scenes/representants-legaux/index.jsx - About 4 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 _page2 has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

          function _page2(doc, contract) {
            doc.addPage();
          
            doc.font(FONT_BOLD).fontSize(FONT_SIZE_H1).text(`Entre les soussignés,`, MARGIN);
            doc.moveDown(1);
          Severity: Minor
          Found in api/src/templates/contract/phase2.js - About 4 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

          Severity
          Category
          Status
          Source
          Language