betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

Function up has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async up() {
    const cohorts = await CohortModel.find({}, { name: 1 }).lean();
    const cohortsMap = new Map();
    for (const cohort of cohorts) {
      cohortsMap.set(cohort.name, cohort._id?.toString());
Severity: Minor
Found in api/migrations/20240822101008-add-cohortIds-into-collection.js - About 35 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 pathToKey has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function pathToKey(path) {
  if (path && path.length > 0) {
    let key = path[0] === "/" ? path.substring(1) : path;
    const idx = key.indexOf("/");
    if (idx >= 0) {
Severity: Minor
Found in api/src/controllers/planDeTransport/ligne-de-bus.js - About 35 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 getTransportCorrectionRequests has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function getTransportCorrectionRequests(startDate, endDate, user) {
  // ref reg and admin
  let body = {
    query: {
      bool: {
Severity: Minor
Found in api/src/services/stats.service/sejour.js - About 35 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 ExpirationDate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function ExpirationDate({ date, setDate, onChange, corrections, category }) {
  const young = useSelector((state) => state.Auth.young);
  const [error, setError] = useState(false);

  const handleChange = (date) => {
Severity: Minor
Found in app/src/scenes/inscription2023/components/StepUploadDesktop.jsx - About 35 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 handler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

exports.handler = async () => {
  try {
    let countReferents = 0;
    // liste des cohortes pour lesquelles on est la veille de la fin de l'instruction
    const cohorts = await getCohortsEndingTomorrow();
Severity: Minor
Found in api/src/crons/clotureInscriptionReminder.js - About 35 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 ExpirationDate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function ExpirationDate({ corrections, category, young, date, setDate, setHasChanged }) {
  const [error, setError] = useState(false);
  const handleChange = (date) => {
    setDate(date);
    setHasChanged(true);
Severity: Minor
Found in app/src/scenes/inscription2023/components/StepUploadMobile.jsx - About 35 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 getCcOfYoung has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const getCcOfYoung = ({ template, young }) => {
  if (!young || !template) return [];
  let cc = [];
  if (Object.values(SENDINBLUE_TEMPLATES.young).includes(template)) {
    if (young.parent1Email && young.parent1FirstName && young.parent1LastName) cc.push({ name: `${young.parent1FirstName} ${young.parent1LastName}`, email: young.parent1Email });
Severity: Minor
Found in api/src/utils/index.js - About 35 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 getYoungRegisteredWithParticularSituation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function getYoungRegisteredWithParticularSituation(startDate, endDate, user) {
  // ref reg only
  let body = {
    query: {
      bool: {
Severity: Minor
Found in api/src/services/stats.service/inscription.js - About 35 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 validateEmailUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

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

async function getRegionTableDeRepartition(cohort) {
  const repartitions = await TableDeRepartitionModel.find({ cohort });
  let regions = {};
  for (const repartition of repartitions) {
    if (regions[repartition.fromRegion] === undefined) {
Severity: Minor
Found in api/src/controllers/planDeTransport/schema-de-repartition.js - About 35 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 forgotPasswordReset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async forgotPasswordReset(req, res) {
    const { error, value } = Joi.object({ password: Joi.string().required(), token: Joi.string().min(16).required() })
      .unknown()
      .validate(req.body);

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

async function getTimeScheduleAndPedagoProject(startDate, endDate, user) {
  // ref dep and ref reg
  let body = {
    query: {
      bool: {
Severity: Minor
Found in api/src/services/stats.service/sejour.js - About 35 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 getDepartmentTableDeRepartition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function getDepartmentTableDeRepartition(cohort, region) {
  const repartitions = await TableDeRepartitionModel.find({ cohort, fromRegion: region });
  let departments = {};
  for (const repartition of repartitions) {
    if (departments[repartition.fromDepartment] === undefined) {
Severity: Minor
Found in api/src/controllers/planDeTransport/schema-de-repartition.js - About 35 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 getProposedMissionsAcceptedOrRefusedByYoung has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function getProposedMissionsAcceptedOrRefusedByYoung(startDate, endDate, user) {
  // ref dep only
  const token = await getAccessToken(config.API_ANALYTICS_ENDPOINT, config.API_ANALYTICS_API_KEY);
  let body = {
    startDate: formatDateForPostGre(startDate),
Severity: Minor
Found in api/src/services/stats.service/engagement.js - About 35 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 buildFilterContext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

helpers.buildFilterContext = async (user, cohorts, index) => {
  // Adding context filter for a special user role :
  // 1. create a function which return filter depending index
  // 2. add your user role in the first switch case

Severity: Minor
Found in api/src/services/dashboard/todo.helper.js - About 35 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 StatusTable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export default function StatusTable({ statuses, className = "", onStatusClicked = () => {}, loading = false, nocols = false, colWidth = "w-[45%]" }: Props) {
  const columns = nocols
    ? { left: statuses || [], right: [] }
    : statuses
      ? {
Severity: Minor
Found in admin/src/scenes/dashboardV2/components/ui/StatusTable.tsx - About 35 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 getCohortPeriod has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const getCohortPeriod = (cohort, withBold = false) => {
  if (!cohort.dateStart || !cohort.dateEnd) return cohort.name || cohort;

  if(!shouldDisplayDateByCohortName(cohort.name)) {
    return "à venir";
Severity: Minor
Found in packages/lib/src/sessions.ts - About 35 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 api has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const api = async (path, options: any = {}, force?: boolean) => {
  try {
    if (!config.ENABLE_SENDINBLUE && !force) {
      logger.warn("Not possible to use BREVO api as ENABLE_SENDINBLUE is disabled");
      return;
Severity: Minor
Found in api/src/brevo.ts - About 35 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 getCohesionCenter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const getCohesionCenter = async (young) => {
  let cohesionCenter;

  let session = await SessionPhase1Model.findById(young.sessionPhase1Id);
  let cohesionId = session?.cohesionCenterId || young?.cohesionCenterId;
Severity: Minor
Found in api/src/templates/certificate/phase1.ts - About 35 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 updateReferentsForMultipleClasses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export async function updateReferentsForMultipleClasses(
  referentsClassesToUpdate: (UpdateReferentClasse & {
    classeId: string;
  })[],
  user: UserDto,
Severity: Minor
Found in api/src/cle/classes/classesService.ts - About 35 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