betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function MissionsYoungPreferences has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export default function MissionsYoungPreferences({ filters, missionFilters, className = "" }) {
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);
  const [selectedTab, setSelectedTab] = useState("project");
  const [graphs, setGraphs] = useState([]);

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

export default function NationalView() {
  const history = useHistory();

  const cohorts = useSelector((state) => state.Cohorts);
  const user = useSelector((state) => state.Auth.user);
Severity: Minor
Found in admin/src/scenes/plan-transport/table-repartition/NationalView.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 Presentation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export default function Presentation({ step, parentId }) {
  const history = useHistory();
  const { young, token, cohort } = useContext(RepresentantsLegauxContext);

  if (!young) return <Loader />;
Severity: Minor
Found in app/src/scenes/representants-legaux/mobile/presentation.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 Reset has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export default function Reset() {
  const [loading, setLoading] = React.useState(false);
  const [disabled, setDisabled] = React.useState(true);
  const [password, setPassword] = React.useState("");
  const [passwordConfirm, setPasswordConfirm] = React.useState("");
Severity: Minor
Found in app/src/scenes/auth/mobile/reset.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 ActivationCodeModalContent has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

const ActivationCodeModalContent = ({ onSuccess, onCancel, newEmail, openDidNotReceiveCodeModal, validationToken = "" }) => {
  const dispatch = useDispatch();

  const [error, setError] = useState("");
  const [emailValidationToken, setEmailValidationToken] = useState(validationToken);

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

const deletePatches = async ({ id, model }) => {
  try {
    const { error, value: validatedId } = validateId(id);
    if (error) {
      capture(error);
Severity: Minor
Found in api/src/controllers/patches.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 ModalSejour has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export default function ModalSejour({ isOpen, onCancel }) {
  const young = useSelector((state) => state.Auth.young);
  const [loading, setLoading] = React.useState(false);
  const [cohorts, setCohorts] = React.useState([]);
  const [error, setError] = React.useState({});
Severity: Minor
Found in app/src/scenes/inscription2023/components/ModalSejour.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 updateStatusPhase1 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

async function updateStatusPhase1(young, validationDateWithDays, user) {
  const initialState = young.statusPhase1;
  try {
    const now = new Date();
    const validationDate = new Date(validationDateWithDays);
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

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

        <div className="flex basis-1/3 flex-col rounded-xl bg-white p-4 shadow-block">
          <div className="mb-4 flex flex-1 items-center gap-6">
            <AdjustableWrench />
            <div className="flex flex-1 flex-col gap-2">
              <div className="text-lg font-bold">Créer une mission personnalisée</div>
Severity: Major
Found in admin/src/scenes/volontaires/components/Toolbox.jsx and 1 other location - About 2 hrs to fix
admin/src/scenes/volontaires/components/Toolbox.jsx on lines 23..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 330.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        <div className="flex basis-1/3 flex-col rounded-xl bg-white p-4 shadow-block">
          <div className="mb-4 flex flex-1 items-center gap-6">
            <Hammer />
            <div className="flex flex-1 flex-col gap-2">
              <div className="text-lg font-bold">Proposer une mission existante</div>
Severity: Major
Found in admin/src/scenes/volontaires/components/Toolbox.jsx and 1 other location - About 2 hrs to fix
admin/src/scenes/volontaires/components/Toolbox.jsx on lines 75..105

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

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 StepEligibilite has 224 lines of code (exceeds 200 allowed). Consider refactoring.
Open

export default function StepEligibilite() {
  const { young, isCLE } = useAuth();
  function isInFranceOrOut(young) {
    if (young.schoolCountry !== "FRANCE") {
      return true;
Severity: Major
Found in app/src/scenes/inscription2023/steps/correction/stepEligibilite.jsx - About 1 hr to fix

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

            <div className="flex min-w-[30%] flex-col gap-2">
              <StatusText
                status="En cours"
                nb={values.IN_PROGRESS || 0}
                percentage={computePercentage(values.IN_PROGRESS)}
    admin/src/scenes/dashboardV2/components/inscription/StatutPhase.jsx on lines 58..91

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

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

            <div className="flex min-w-[30%] flex-col gap-2">
              <StatusText
                status="Validées sur liste complémentaire"
                nb={values.WAITING_LIST || 0}
                percentage={computePercentage(values.WAITING_LIST)}
    admin/src/scenes/dashboardV2/components/inscription/StatutPhase.jsx on lines 21..54

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

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

    const DSNJExport = () => {
      const dispatch = useDispatch();
      const cohortList = useSelector((state) => state.Cohorts);
    
      const [currentCohort, setCurrentCohort] = useState(cohortList[0]);
    Severity: Minor
    Found in admin/src/scenes/dsnj-export/index.jsx - About 1 hr 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 Phase3 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function Phase3({ young, onChange }) {
      const [edit, setEdit] = useState(false);
      const [information, setInformation] = useState({
        phase3StructureName: young.phase3StructureName,
        phase3MissionDescription: young.phase3MissionDescription,
    Severity: Minor
    Found in admin/src/scenes/volontaires/view/phase3.jsx - About 1 hr 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 Details has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function Details({ selectedFilters, role, sessionId, centerId }) {
      const [age, setAge] = useState({});
      const [sexe, setSexe] = useState({});
      const [grade, setGrade] = useState({});
      const [situation, setSituation] = useState({});
    Severity: Minor
    Found in admin/src/scenes/dashboardV2/components/inscription/Details.jsx - About 1 hr 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 ModalPointagePresenceJDM has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function ModalPointagePresenceJDM({ isOpen, onSubmit, onCancel, values, value }) {
      const [isLoading, setIsLoading] = React.useState(false);
      const [viewList, setViewList] = React.useState(false);
      const isPlural = values?.length > 1;
    
    

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

    export default function ListeDemandeModif() {
      const urlParams = new URLSearchParams(window.location.search);
      const [cohort, setCohort] = useState(urlParams.get("cohort"));
      const [tagsOptions, setTagsOptions] = useState([]);
      const [loading, setLoading] = useState(false);
    Severity: Minor
    Found in admin/src/scenes/plan-transport/ligne-bus/ListeDemandeModif.jsx - About 1 hr 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 ListBus has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function ListBus(props) {
      const id = props.match && props.match.params && props.match.params.id;
      if (!id) return <div />;
      const [bus, setBus] = React.useState();
      const [loading, setLoading] = React.useState(true);
    Severity: Minor
    Found in admin/src/scenes/plan-transport/ligne-bus/ListBus.jsx - About 1 hr 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 StepPDR has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function StepPDR({ data: { center, session, meetingPoint, departureDate, returnDate } }) {
      const index = 1;
      const { young } = useAuth();
      const [open, setOpen] = useState(false);
      const [meetingPoints, setMeetingPoints] = useState([]);
    Severity: Minor
    Found in app/src/scenes/phase1/scenes/affected/components/step/StepPDR.jsx - About 1 hr 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