betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function UserHeader has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export default function UserHeader({ user, tab, currentUser }) {
  const history = useHistory();
  const dispatch = useDispatch();
  const [handleImpersonateLoading, setHandleImpersonateLoading] = useState(false);

Severity: Minor
Found in admin/src/scenes/utilisateur/composants/UserHeader.jsx - About 45 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 CniField has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function CniField({
  young,
  name,
  label,
  mode,
Severity: Minor
Found in admin/src/scenes/phase0/components/CniField.jsx - About 45 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

Avoid deeply nested control flow statements.
Open

        if (school) {
          changes.schoolName = school.fullName;
          changes.schoolType = school.type;
          changes.schoolAddress = school.adresse;
          changes.schoolZip = school.postcode ? school.postcode : school.codeCity;
Severity: Major
Found in admin/src/scenes/phase0/components/SchoolEditor.jsx - About 45 mins to fix

    Function Section has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function Section({ step, title, editable, collapsable, children, mode, onChangeMode, onSave, onCancel, saving = false, containerNoFlex = false }) {
      const [collapsed, setCollapsed] = useState(false);
    
      function startEdit() {
        // history.push(`/volontaire/${young._id}/edit`);
    Severity: Minor
    Found in admin/src/scenes/phase0/components/Section.jsx - About 45 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

    Avoid deeply nested control flow statements.
    Open

          if (onChange) {
            changes.schoolName = value;
            changes.schoolType = "";
            changes.schoolAddress = "";
            changes.schoolZip = "";
    Severity: Major
    Found in admin/src/scenes/phase0/components/SchoolEditor.jsx - About 45 mins to fix

      Function SimpleSelect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function SimpleSelect({ value, title, transformer, options, onChange, placeholder = "Choisissez une valeur", className = "" }) {
        const [selectOptionsOpened, setSelectOptionsOpened] = useState(false);
      
        const selectOptionsRef = useRef();
      
      

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

      export default function ModalPointageFicheSanitaire({ isOpen, onSubmit, onCancel, value, young }) {
        const [isLoading, setIsLoading] = React.useState(false);
      
        const getTitle = () => `Fiche sanitaire de ${young.firstName} ${value === "true" ? "réceptionnée" : "non réceptionnée"}`;
        const getMessage = () => `Vous êtes sur le point d'indiquer que vous ${value === "true" ? "avez reçu" : "n'avez pas reçu"} la fiche sanitaire de ${young.firstName}.`;

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

      function PedagoProjectFile({ session, setSession, file, className = "" }) {
        const [communicating, setCommunicating] = useState(false);
      
        async function deleteFile() {
          setCommunicating(true);
      Severity: Minor
      Found in admin/src/scenes/centersV2/components/modals/ModalPedagoProject.jsx - About 45 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 SemiCircleProgress has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const SemiCircleProgress = ({ current, total }) => {
        const progress = (Math.min(current, total) / total) * 100;
        return (
          <svg className="h-80 pb-8 mx-auto" viewBox="0 0 110 100">
            <linearGradient id="gradient" x1="0" y1="0" x2="100%" y2="0%">

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

      const MedicalFileModal = ({ isOpen, onClose, onClick, title = "Téléchargez votre fiche sanitaire", email }) => {
        const [open, setOpen] = useState(false);
        const [loading, setLoading] = useState(false);
        const young = useSelector((state) => state.Auth.young);
      
      
      Severity: Minor
      Found in app/src/scenes/phase1/components/MedicalFileModal.jsx - About 45 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 Affected has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function Affected() {
        const { young } = useAuth();
        const [center, setCenter] = useState();
        const [meetingPoint, setMeetingPoint] = useState();
        const [session, setSession] = useState();
      Severity: Minor
      Found in app/src/scenes/phase1/scenes/affected/index.jsx - About 45 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 TimeScheduleFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function TimeScheduleFile({ session, setSession, file, className = "" }) {
        const [communicating, setCommunicating] = useState(false);
      
        async function deleteFile() {
          setCommunicating(true);
      Severity: Minor
      Found in admin/src/scenes/centersV2/components/modals/ModalTimeSchedule.jsx - About 45 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 FileUpload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      const FileUpload = ({ className, files = [], addFiles, deleteFile, filesAccepted = ["jpeg", "png", "pdf"], disabled = false }) => {
        const inputRef = useRef(null);
        const accept = Object.keys(FILES_ACCEPTED).reduce((previous, current) => {
          if (filesAccepted.includes(current)) {
            return `${previous}${previous ? ", " : ""}${FILES_ACCEPTED[current].join(", ")}`;
      Severity: Minor
      Found in app/src/components/FileUpload.jsx - About 45 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 Forgot has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function Forgot() {
        const [done, setDone] = React.useState(false);
        const [email, setEmail] = React.useState("");
        const [loading, setLoading] = React.useState(false);
        const [disabled, setDisabled] = React.useState(true);
      Severity: Minor
      Found in app/src/scenes/auth/desktop/forgot.jsx - About 45 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 Contact has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function Contact() {
        useDocumentTitle("Formulaire de contact");
        const { isLoggedIn, young } = useAuth();
      
        const params = new URLSearchParams(window.location.search);
      Severity: Minor
      Found in app/src/scenes/contact/index.jsx - About 45 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 MultiGroup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function MultiGroup({ onChange = () => {}, className = "", value, options = [] }) {
        function onToggle(val) {
          if (value) {
            const idx = value.indexOf(val);
            let newVal = [...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 validateEmail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        async validateEmail(req, res) {
          try {
            const { error, value } = Joi.object({ token_email_validation: Joi.string().required() }).unknown().validate(req.body);
            if (error) return res.status(400).send({ ok: false, code: ERRORS.INVALID_BODY });
            const { token_email_validation } = value;
      Severity: Minor
      Found in api/src/auth.js - About 45 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 validateUser has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      async function validateUser(Model, jwtPayload, done, role) {
        try {
          const { error, value } = Joi.object({
            __v: Joi.string().required(),
            _id: Joi.string().required(),
      Severity: Minor
      Found in api/src/passport.js - About 45 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

      Avoid deeply nested control flow statements.
      Open

                  if (young.statusPhase2 === YOUNG_STATUS_PHASE2.IN_PROGRESS && application.status === APPLICATION_STATUS.VALIDATED) data.actions.missionInProgress += 1;
      Severity: Major
      Found in api/src/services/jeveuxaider.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (contract && application.status === APPLICATION_STATUS.VALIDATED) {
                      const statusContract = checkStatusContract(contract);
                      if (statusContract === CONTRACT_STATUS.DRAFT) data.actions.contractToBeFilled += 1;
                      if (statusContract === CONTRACT_STATUS.SENT && contract.structureManagerStatus === "WAITING_VALIDATION") data.actions.contractToBeSigned += 1;
                      if (statusContract === CONTRACT_STATUS.VALIDATED && young.status === YOUNG_STATUS.VALIDATED) data.actions.volunteerToHost += 1;
        Severity: Major
        Found in api/src/services/jeveuxaider.js - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language