betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function ModalConvocation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function ModalConvocation({ open, setOpen }) {
  const young = useSelector((state) => state.Auth.young);
  const dispatch = useDispatch();
  const [modal, setModal] = useState({ isOpen: false, onConfirm: null });

Severity: Minor
Found in app/src/scenes/phase1/scenes/affected/components/ModalConvocation.jsx - About 25 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 InputPassword has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const InputPassword = ({ label = "", className = "", name = "", value = "", onChange = () => null, error = null, ...rest }) => {
  const [inputType, setInputType] = useState("password");

  if ("type" in rest) {
    throw new Error(`InputPassword component cannot handle a custom type.`);
Severity: Minor
Found in app/src/components/forms/inputs/InputPassword.jsx - About 25 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 renderStepResponsive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function renderStepResponsive(step) {
  if (step === STEPS.ELIGIBILITE) return <StepEligibilite />;
  if (step === STEPS.INELIGIBLE) return <StepNonEligible />;
  if (step === STEPS.SEJOUR) return <StepSejour />;
  if (step === STEPS.PROFIL) return <StepProfil />;
Severity: Minor
Found in app/src/scenes/preinscription/index.jsx - About 25 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 FranceConnectCallback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function FranceConnectCallback() {
  // Update from France Connect.
  async function fetchData(code, id, token, state) {
    const { data, tokenId } = await api.post("/young/france-connect/user-info", { code, callback: getFranceConnectCallback(id, token), state });
    if (data && data["email"]) {
Severity: Minor
Found in app/src/scenes/representants-legaux/components/FranceConnectCallback.jsx - About 25 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 anonymize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function anonymize(item) {
  item.email && (item.email = generateRandomEmail());
  item.newEmail && (item.newEmail = generateRandomEmail());
  item.parent1Email && (item.parent1Email = generateRandomEmail());
  item.parent2Email && (item.parent2Email = generateRandomEmail());
Severity: Minor
Found in api/src/anonymization/young.js - About 25 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 SchoolOutOfFrance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function SchoolOutOfFrance({ school, onSelectSchool, toggleVerify, corrections = null }) {
  const [countries, setCountries] = useState([]);
  const [country, setCountry] = useState(school?.country);
  const [schools, setSchools] = useState([]);
  const [manualFilling, setManualFilling] = useState(school?.fullName && !school?.city && school?.country != "FRANCE");
Severity: Minor
Found in app/src/scenes/inscription2023/components/ShoolOutOfFrance.jsx - About 25 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 Recto has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function Recto({ corrections, category, setRecto, setStep, setHasChanged, setError }) {
  async function handleChange(e) {
    const image = await resizeImage(e.target.files[0]);
    if (image.size > 5000000) return setError({ text: "Ce fichier est trop volumineux." });

Severity: Minor
Found in app/src/scenes/inscription2023/components/StepUploadMobile.jsx - About 25 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 updateMission has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function updateMission(app, fromUser) {
  try {
    const mission = await MissionModel.findById(app.missionId);

    // Get all applications for the mission
Severity: Minor
Found in api/src/controllers/application.js - About 25 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 scrollSearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function* scrollSearch(params, client) {
  let response = await client.search(params);
  let scrollId = response.body._scroll_id; // Capture the initial scroll ID

  try {
Severity: Minor
Found in api/src/es/utils.js - About 25 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 buildTreeRecursive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const buildTreeRecursive = (item, flattenedData, { addParents = true, debug } = {}) => {
  const populatedSection = item;
  if (["root", "section"].includes(item.type)) {
    const children = flattenedData.filter((i) => i.parentId === item._id).sort(sortItemsInSection);
    for (const child of children) {
Severity: Minor
Found in knowledge-base-public/src/utils/knowledgeBaseTree.js - About 25 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 renderStepCorrection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function renderStepCorrection(step) {
  if (step === CORRECTION_STEPS.ELIGIBILITE) return <MobileCorrectionEligibilite />;
  if (step === CORRECTION_STEPS.PROFIL) return <MobileCorrectionProfil />;
  if (step === CORRECTION_STEPS.COORDONNEES) return <StepCoordonnees />;
  if (step === CORRECTION_STEPS.REPRESENTANTS) return <StepRepresentants />;
Severity: Minor
Found in app/src/scenes/inscription2023/index.jsx - About 25 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 updateNetworkName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function updateNetworkName(structure, fromUser) {
  if (structure.networkId) {
    // When the structure is a child (part of a network), get the network
    const network = await StructureModel.findById(structure.networkId);
    // then update networkName thanks to its name.
Severity: Minor
Found in api/src/controllers/structure.js - About 25 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 KnowledgeBasePublicContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const KnowledgeBasePublicContent = ({ item, isLoading }) => {
  const router = useRouter();

  const [loadingType, setType] = useState(router?.query?.loadingType);

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

function filterPatchWithQuery(p, query) {
  return (
    // bus
    p.refName?.toLowerCase()?.includes(query) ||
    // field
Severity: Minor
Found in api/src/controllers/planDeTransport/ligne-de-bus.js - About 25 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 requestEmailUpdate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async requestEmailUpdate(req, res) {
    try {
      const { error, value } = Joi.object({ email: Joi.string().lowercase().trim().email().required(), password: Joi.string().required() }).unknown().validate(req.body);
      if (error) {
        capture(error);
Severity: Minor
Found in api/src/auth.js - About 25 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 scanFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function scanFile(tempFilePath, name, userId = "anonymous") {
  if (!config.get("ENABLE_ANTIVIRUS")) {
    return { infected: false };
  }

Severity: Minor
Found in api/src/utils/virusScanner.js - About 25 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 deleteSensitiveData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function deleteSensitiveData(youngId, mode = "save") {
  const young = await YoungModel.findById(youngId);
  let fileStatus = "";

  try {
Severity: Minor
Found in api/src/services/gdpr.js - About 25 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 KnowledgeBasePublicArticle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const KnowledgeBasePublicArticle = ({ item, isLoading }) => {
  const group = useMemo(() => {
    return item?.group || item?.parents?.[0]?.group;
  }, [item]);

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

export const Accordion = ({ title, list = [], className = "", path, isOpen = false, slug: slugTheme }) => {
  const [active, setActive] = useState(false);
  const [height, setHeight] = useState("0px");
  const [rotate, setRotate] = useState("transform duration-700 ease");

Severity: Minor
Found in knowledge-base-public/src/components/Accordion.js - About 25 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 canDeleteReferent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function canDeleteReferent({ actor, originalTarget, structure }) {
  // TODO: we must handle rights more precisely.
  // See: https://trello.com/c/Wv2TrQnQ/383-admin-ajouter-onglet-utilisateurs-pour-les-r%C3%A9f%C3%A9rents
  const isMe = actor._id === originalTarget._id;

Severity: Minor
Found in packages/lib/src/roles.ts - About 25 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

Severity
Category
Status
Source
Language