betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

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

function canAssignManually(actor, young, cohort) {
  if (!cohort) return false;
  return (
    (actor.role === ROLES.ADMIN && cohort.manualAffectionOpenForAdmin) ||
    (actor.role === ROLES.REFERENT_REGION && actor.region === young.region && cohort.manualAffectionOpenForReferentRegion) ||
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

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

export const doInviteMultipleChefsEtablissements = async (user: UserDto) => {
  const chefsEtablissementsToSendInvitation = await ReferentModel.find({
    "metadata.isFirstInvitationPending": true,
    role: ROLES.ADMINISTRATEUR_CLE,
    subRole: SUB_ROLES.referent_etablissement,
Severity: Minor
Found in api/src/services/cle/referent.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

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

export default function Goal() {
  useDocumentTitle("Objectifs");

  const [inscriptionGoals, setInscriptionGoals] = useState<{ department: string; region: string; max: null | number }[]>();
  const [loading, setLoading] = useState(false);
Severity: Minor
Found in admin/src/scenes/goal/index.tsx - 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 ReferentInfos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function ReferentInfos({ classe, setClasse, editRef, setEditRef, errors, rights, isLoading, onCancel, onCheckInfo }: 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/ReferentInfos.tsx - 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 findOrCreateReferent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const findOrCreateReferent = async (referent, { etablissement, role, subRole }: { etablissement: EtablissementType; role: string; subRole?: string }) => {
  try {
    // Return if already exists
    if (referent._id) return referent;

Severity: Minor
Found in api/src/services/cle/referent.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

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

export const canUpdateCenter = (cohort: CohortDto | undefined, user: ReferentDto | undefined): boolean => {
  if (!user) return false;
  if (!cohort) return true;

  return (
Severity: Minor
Found in packages/lib/src/cohort/cohortService.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

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

const getCohortPeriodTemp = (young) => {
  const { cohort, region } = young;
  const cohortName = cohort.name || cohort;
  if (cohortName === "Juillet 2023" && [...regionsListDROMS, "Polynésie française"].includes(region)) {
    return "du 4 au 16 Juillet 2023";
Severity: Minor
Found in packages/lib/src/sessions.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

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

export default function ModalConfirmation({
  isOpen,
  onClose,
  actions,
  className,
Severity: Minor
Found in packages/ds/src/admin/ui/ModalConfirmation.tsx - 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 deleteClasse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const deleteClasse = async (_id: string, fromUser: object) => {
  let classe = await ClasseModel.findById(_id);
  if (!classe) throw new Error("Classe not found");
  if (classe.deletedAt) throw new Error("Classe already deleted");
  if (classe.cohesionCenterId) throw new Error("Classe already linked to a cohesion center");
Severity: Minor
Found in api/src/cle/classe/classeService.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

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

export default function reducer(state = INITIAL_STATE, action) {
  switch (action.type) {
    case authActions.SETUSER:
      // eslint-disable-next-line no-case-declarations
      const previousSigninToken = state.previousSigninToken || sessionStorage.getItem(SS_KEY_PREVIOUS_SIGNIN);
Severity: Minor
Found in admin/src/redux/auth/reducer.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

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

export const doInviteMultipleReferentClasseVerifiee = async (user: UserDto) => {
  const referentsClasseToSendInvitation = await findReferentsClasseToSendInvitationByClasseStatus(STATUS_CLASSE.VERIFIED);
  const invitations: InvitationResult[] = [];
  let processCounter = 1;
  for (const referentClasse of referentsClasseToSendInvitation) {
Severity: Minor
Found in api/src/services/cle/referent.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

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

export const getCohortGroups = (parentFilterKey: string = "cohort"): IIntermediateFilter => {
  return {
    key: parentFilterKey,
    filters: [
      {
Severity: Minor
Found in admin/src/services/cohort.service.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

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

export default function Button({
  title,
  type = "primary",
  className = "",
  leftIcon,
Severity: Minor
Found in packages/ds/src/admin/ui/Button.tsx - 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 Badge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function Badge({
  title,
  status = "none",
  mode = "default",
  leftIcon,
Severity: Minor
Found in packages/ds/src/admin/ui/Badge.tsx - 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 StatsInfos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function StatsInfos({ classe, user, studentStatus, validatedYoung }: Props) {
  const isUserCLE = [ROLES.ADMINISTRATEUR_CLE, ROLES.REFERENT_CLASSE].includes(user.role);
  const isUserAdminOrReferent = [ROLES.ADMIN, ROLES.REFERENT_REGION, ROLES.REFERENT_DEPARTMENT].includes(user.role);

  const linkPath = isUserCLE ? "/mes-eleves" : "/inscription";
Severity: Minor
Found in admin/src/scenes/classe/components/StatsInfos.tsx - 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 youngCanChangeSession has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const youngCanChangeSession = ({ statusPhase1, status, sessionPhase1Id, source, departSejourMotif }) => {
  if (source === YOUNG_SOURCE.CLE) return false;
  if ([YOUNG_STATUS.IN_PROGRESS, YOUNG_STATUS.WAITING_LIST, YOUNG_STATUS.WAITING_VALIDATION, YOUNG_STATUS.WAITING_CORRECTION].includes(status)) return true;
  if ([YOUNG_STATUS_PHASE1.AFFECTED, YOUNG_STATUS_PHASE1.WAITING_AFFECTATION].includes(statusPhase1) && status === YOUNG_STATUS.VALIDATED) {
    return true;
Severity: Minor
Found in packages/lib/src/common.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

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

export function formatParams(filters: { key: string; value: string | string[] }[], page: number, size?: number): string {
  const type = filters.find((filter) => filter.key === "type")?.value ?? [];
  size = size ?? 20;

  let where = "";
Severity: Minor
Found in api/src/services/gouv.fr/api-education.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

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

export const syncRootFilter = (intermediateFilter: IIntermediateFilter, newSelectedFilters: { [key: string]: { filter: string[] } }) => {
  if (!intermediateFilter) return;
  newSelectedFilters[intermediateFilter.key].filter = [];
  for (const filter of intermediateFilter.filters) {
    if (newSelectedFilters[filter.name] && newSelectedFilters[intermediateFilter.key]) {

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

export default function Index() {
  const user = useSelector((state: AuthState) => state.Auth.user);

  const { data: messages } = useQuery<AlerteMessageDto[]>({
    queryKey: ["alerte-messages", "user"],
Severity: Minor
Found in admin/src/scenes/dashboardV2/components/General.tsx - 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 ToggleBloc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function ToggleBloc({ children, title, borderBottom, borderRight, borderLeft, disabled, onClick, visible }: Props) {
  return (
    <Row
      style={{
        borderBottom: borderBottom ? "2px solid #f4f5f7" : 0,
Severity: Minor
Found in admin/src/scenes/goal/ToggleBloc.tsx - 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