betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function GroupAffectationSummary has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function GroupAffectationSummary({ group, className = "", onChange, onChangeStep, isUserAuthorizedToCreateGroup }) {
  const { user } = useSelector((state) => state.Auth);
  const [loading, setLoading] = useState(true);
  const [detail, setDetail] = useState(null);
  const [error, setError] = useState(null);

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

export async function exportLigneBusJeune(cohort, ligne, travel, team) {
  try {
    const youngs = await API.post(`/elasticsearch/young/in-bus/${String(ligne._id)}/export`, {
      filters: {},
      exportFields: "*",
Severity: Minor
Found in admin/src/scenes/plan-transport/util.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 CorrectedRequest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function CorrectedRequest({ young, correctionRequest, className, reasons }) {
  const [correctionView, setCorrectionView] = useState(false);

  function toggleCorrectionView() {
    setCorrectionView(!correctionView);
Severity: Minor
Found in admin/src/scenes/phase0/components/CorrectedRequest.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 AccountPasswordPage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const AccountPasswordPage = () => {
  const dispatch = useDispatch();

  const [formValues, setFormValues] = useState(INITIAL_FORM_VALUES);

Severity: Minor
Found in app/src/scenes/account/scenes/password/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 ModalPointagePresenceJDM has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function ModalPointagePresenceJDM({ isOpen, onSubmit, onCancel, values }) {
  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 InscriptionClosed has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function InscriptionClosed({ young, isCLE }) {
  const statusWording = (young, isCLE) => {
    if (isCLE) {
      if ([YOUNG_STATUS.REINSCRIPTION, YOUNG_STATUS.IN_PROGRESS].includes(young.status)) {
        return "Votre inscription n'a pas été complétée à temps.";
Severity: Minor
Found in app/src/scenes/inscription2023/InscriptionClosed.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 MissionList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function MissionList({ publisherName }) {
  const young = useSelector((state) => state.Auth.young);
  const history = useHistory();

  const params = new URLSearchParams(window.location.search);
Severity: Minor
Found in app/src/scenes/phase2/scenes/Program/MissionList.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 View has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function View({ young, onSave, saving, onToggleDomain, hasDomainSelected, onChange, mobile, errors }) {
  return (
    <div className="pb-24">
      {Object.values(errors).length ? <div className="text-center mt-6 text-sm text-[#F71701]">Il y a des erreurs ou des données manquantes dans le formulaire.</div> : null}
      <Section>

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

export default function StepMedicalField({ data }) {
  const index = 4;
  const young = useSelector((state) => state.Auth.young);
  const isEnabled = isStepDone(STEPS.CONVOCATION, young);
  const isDone = isStepDone(STEPS.MEDICAL_FILE, young);

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

export default function mission({ mission: missionProp, location }) {
  const mission = missionProp._source;
  const tags = [];
  mission.city && tags.push(mission.city + (mission.zip ? ` - ${mission.zip}` : ""));
  mission.domains.forEach((d) => tags.push(translate(d)));
Severity: Minor
Found in app/src/scenes/missions/list/components/CardMission.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 handler has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

exports.handler = async () => {
  try {
    const processContacts = async (Model, type) => {
      const cursor = Model.find({ updatedAt: { $gte: new Date(new Date() - 24 * 60 * 60 * 1000) } }).cursor();
      let contactsWithAttributes = [];
Severity: Minor
Found in api/src/crons/syncContactSupport.js - 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 ModalPJ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function ModalPJ({ isOpen, onCancel, onSave, onSend, name, young, application, optionsType, typeChose }) {
  const [type, setType] = useState();
  const [stepOne, setStepOne] = useState();
  const [disabledSave, setDisabledSave] = useState(true);
  const [newFilesList, setNewFilesList] = useState([]);
Severity: Minor
Found in app/src/scenes/missions/components/ModalPJ.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 checkStatusContract has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const checkStatusContract = (contract) => {
  if (!contract.invitationSent || contract.invitationSent === "false") return "DRAFT";
  // To find if everybody has validated we count actual tokens and number of validated. It should be improved later.
  const tokenKeys = ["projectManagerToken", "structureManagerToken"];
  const validateKeys = ["projectManagerStatus", "structureManagerStatus"];
Severity: Minor
Found in api/src/utils/index.js - 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 YoungRowImageRight has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function YoungRowImageRight({ young, selectedYoungs, onYoungSelected, onChange }: Props) {
  const history = useHistory();
  const [showModale, setShowModale] = useState(false);
  const [authorized, setAuthorized] = useState(false);

Severity: Minor
Found in admin/src/scenes/volontaire-cle/imageRight/YoungRowImageRight.tsx - 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 YoungRowConsent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function YoungRowConsent({ young, selectedYoungs, onYoungSelected, onChange }: Props) {
  const history = useHistory();
  const [showModale, setShowModale] = useState(false);
  const [authorized, setAuthorized] = useState(false);

Severity: Minor
Found in admin/src/scenes/volontaire-cle/consent/YoungRowConsent.tsx - 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 205 lines of code (exceeds 200 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: Major
Found in admin/src/scenes/plan-transport/ligne-bus/ListBus.jsx - About 1 hr to fix

    Function transformVolontairesCLE has 205 lines of code (exceeds 200 allowed). Consider refactoring.
    Open

    export async function transformVolontairesCLE(data, values) {
      const all = data;
    
      interface Center {
        _id?: string;
    Severity: Major
    Found in admin/src/scenes/volontaire-cle/utils/list.ts - About 1 hr to fix

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

        return (
          <div className={`items-center justify-center ${className}`}>
            <div className="flex items-center rounded-lg bg-gray-50 p-9">
              {hasTimeSchedule ? <UploadedFileIcon /> : <EmptyFileIcon />}
              <div className="grow-1 mx-7">
      Severity: Major
      Found in admin/src/scenes/centersV2/components/TimeSchedule.jsx and 1 other location - About 1 hr to fix
      admin/src/scenes/centersV2/components/PedagoProject.jsx on lines 38..61

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

      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

        return (
          <div className={`items-center justify-center ${className}`}>
            <div className="flex items-center rounded-lg bg-gray-50 p-9">
              {hasPedagoProject ? <UploadedFileIcon /> : <EmptyFileIcon />}
              <div className="grow-1 mx-7">
      Severity: Major
      Found in admin/src/scenes/centersV2/components/PedagoProject.jsx and 1 other location - About 1 hr to fix
      admin/src/scenes/centersV2/components/TimeSchedule.jsx on lines 37..60

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

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

      export async function transformVolontaires(data, values) {
        let all = data;
      
        return all.map((data) => {
          let center = {};
      Severity: Major
      Found in admin/src/scenes/volontaires/utils/index.js - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language