betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function PhaseStatusSelector has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export default function PhaseStatusSelector({ young, onChange }) {
  const [phaseChoiceOpened, setPhaseChoiceOpened] = useState(false);
  const [statusOpened, setStatusOpened] = useState(0);
  const [phaseStatuses, setPhaseStatuses] = useState([]);
  const [confirmChangeModal, setConfirmChangeModal] = useState(null);
Severity: Minor
Found in admin/src/scenes/phase0/components/PhaseStatusSelector.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 CustomSelect has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

const CustomSelect = ({
  ref = null,
  onChange,
  readOnly,
  options,
Severity: Minor
Found in admin/src/scenes/utilisateur/composants/CustomSelect.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 ProgramCard has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export default function ProgramCard({ program, image, enableToggle = true, onDelete }) {
  const [expandDetails, setExpandDetails] = useState(false);
  const preview = program.description.substring(0, 130);

  const toggleDetails = () => {
Severity: Minor
Found in admin/src/scenes/content/components/programCard.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 ExportReport has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export default async function ExportReport({ filter, user, setLoading, setLoadingText }) {
  if (!filter?.cohort?.length) return toastr.error("Merci de selectionner au moins une cohorte ");
  if (user.role === REFERENT_ROLES.REFERENT_REGION) {
    if (!filter?.region?.length) {
      filter.region = [user.region];

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

export default function VolontairesEquivalenceMig({ filters }) {
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);
  const [statuses, setStatuses] = useState(null);
  const [types, setTypes] = 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 GroupCenter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export default function GroupCenter({ group, className = "", onChangeStep, onChange }) {
  const [filter, setFilter] = useState("");
  const [type, setType] = useState("all");
  const [list, setList] = useState([]);
  const [loading, setLoading] = useState(true);

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

const Actions = ({ program, onDelete }) => {
  const user = useSelector((state) => state.Auth.user);
  const id = program._id;
  const [modal, setModal] = useState({ isOpen: false, onConfirm: null });

Severity: Minor
Found in admin/src/scenes/content/components/programCard.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 Select has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export default function Select({
  label,
  options,
  value,
  placeholder = "Sélectionner une option",
Severity: Minor
Found in app/src/components/dsfr/forms/Select.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 signin2FA has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  async signin2FA(req, res) {
    try {
      const { error, value } = Joi.object({
        email: Joi.string().lowercase().trim().email().required(),
        token_2fa: Joi.string().required(),
Severity: Minor
Found in api/src/auth.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 _signature has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function _signature(doc, contract) {
  doc.addPage();

  doc.fontSize(FONT_SIZE_H2).text("Réalisé le ", { continued: true });
  doc.font(FONT_BOLD).text(formatDateFRTimezoneUTC(contract.date));
Severity: Minor
Found in api/src/templates/contract/phase2.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 mergeArrayItems has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function mergeArrayItems(array, subProperty) {
  let set = {};
  for (const item of array) {
    if (subProperty) {
      if (item[subProperty]) {
Severity: Minor
Found in api/src/controllers/planDeTransport/ligne-de-bus.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 processPatch has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

async function processPatch(patch, count, total) {
  try {
    result.missionEquivalencePatchScanned = result.missionEquivalencePatchScanned + 1 || 1;
    if (count % 100 === 0) {
      logger.debug(`${count} / ${total}`);
Severity: Minor
Found in api/src/crons/patch/missionEquivalence.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 ConfirmationForm has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export default function ConfirmationForm({ referent, etablissement, invitationToken, reinscription }: Props) {
  const history = useHistory();
  const { search } = useLocation();

  const [cguChecked, setCguChecked] = useState(false);
Severity: Minor
Found in admin/src/scenes/signup/ConfirmationForm.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 computeImportSummary has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export const computeImportSummary = (lines: PdtLine[]) => {
  const countPdr = getLinePdrCount(lines[0]);
  let maxPdrOnLine = 0;
  for (const line of lines.entries()) {
    const currentLinePDRCount = getLinePdrIds(line).length;
Severity: Minor
Found in api/src/pdt/import/pdtImportService.ts - 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 SejourInfos has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export default function SejourInfos({ classe, setClasse, editStay, setEditStay, errors, rights, user, onCancel, infoBus, isLoading, onSendInfo }: Props) {
  const containerActionList = ({ edit, setEdit, canEdit }) => {
    if (edit) {
      return [
        <div key="actions" className="flex items-center justify-end ml-6">
Severity: Minor
Found in admin/src/scenes/classe/components/SejourInfos.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 filterAppelAProjetsSameUaiButDifferentEmailChefEtablissement has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  filterAppelAProjetsSameUaiButDifferentEmailChefEtablissement(
    appelAProjets: IAppelAProjet[],
    appelAProjetOptions: IAppelAProjetOptions,
  ): {
    retained: IAppelAProjet[];
Severity: Minor
Found in api/src/cle/appelAProjetCle/appelAProjetService.ts - 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

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

        <div className="flex flex-col items-center gap-2">
          <div className="flex w-full overflow-hidden rounded-lg border-[1px] border-gray-300">
            <input
              type="text"
              name="search"
Severity: Major
Found in admin/src/scenes/session-phase1/view/MobileList.jsx and 1 other location - About 1 hr to fix
admin/src/scenes/session-phase1/view/List.jsx on lines 101..135

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

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="m-3 flex flex-row items-center gap-x-4">
            <div className="flex w-1/3 overflow-hidden rounded-lg border-[1px] border-gray-300">
              <input
                type="text"
                name="search"
Severity: Major
Found in admin/src/scenes/session-phase1/view/List.jsx and 1 other location - About 1 hr to fix
admin/src/scenes/session-phase1/view/MobileList.jsx on lines 92..126

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

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 flex-col gap-3">
                    <div className="flex items-center gap-2">
                      <p className="text-xs  font-medium text-gray-900">Disponibilité des listes de transport par centre (envoi par email)</p>
                      <MdInfoOutline data-tip data-for="disponibilité_liste" className="h-5 w-5 cursor-pointer text-gray-400" />
                      <ReactTooltip id="disponibilité_liste" type="light" place="top" effect="solid" className="custom-tooltip-radius !opacity-100 !shadow-md" tooltipRadius="6">
Severity: Major
Found in admin/src/scenes/settings/index.jsx and 1 other location - About 1 hr to fix
admin/src/scenes/settings/index.jsx on lines 636..668

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

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 flex-col gap-3">
                    <div className="flex items-center gap-2">
                      <p className="text-xs  font-medium text-gray-900">Annonce et visibilité des affectations par les volontaires</p>
                      <MdInfoOutline data-tip data-for="annonce_affectation" className="h-5 w-5 cursor-pointer text-gray-400" />
                      <ReactTooltip id="annonce_affectation" type="light" place="top" effect="solid" className="custom-tooltip-radius !opacity-100 !shadow-md" tooltipRadius="6">
Severity: Major
Found in admin/src/scenes/settings/index.jsx and 1 other location - About 1 hr to fix
admin/src/scenes/settings/index.jsx on lines 801..836

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

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

Severity
Category
Status
Source
Language