Showing 923 of 941 total issues
Function capture
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function capture(err, contexte) {
if (!err) {
const msg = "Error not defined (Change to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause#examples)";
logger.error(`capture: ${msg}`);
return sentryCaptureMessage(msg);
- Read upRead up
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 NavigationArticle
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const NavigationArticle = ({ item }) => {
const [emoji, text] = separateEmojiAndText(item.title);
const { restriction } = useUser();
const router = useRouter();
const { cache } = useSWRConfig();
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (filterOpFunction(op) && !HIDDEN_FIELDS.includes(op.path) && !IGNORED_VALUES.includes(op.value) && !IGNORED_VALUES.includes(op.originalValue)) {
patches.push({
modelName: doc.modelName,
date: doc.date,
ref: bus?._id,
Function getToken
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getToken(req) {
let token = ExtractJwt.fromAuthHeaderWithScheme("JWT")(req);
// * On first call after refresh, the token is only in the cookie
if (!token) {
- Read upRead up
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 validateUser
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async function validateUser(Model, jwtPayload, done, role) {
try {
const { error, value } = Joi.object({
__v: Joi.string().required(),
_id: Joi.string().required(),
- Read upRead up
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 execute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async execute({ origin = supportApiUrl, method, path = "", body = null, query = {}, headers = {}, credentials = null } = {}) {
try {
const options = {
method,
credentials: "include",
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (filterOpFunction(op) && !HIDDEN_FIELDS.includes(op.path) && !IGNORED_VALUES.includes(op.value) && !IGNORED_VALUES.includes(op.originalValue)) {
patches.push({
modelName: doc.modelName,
date: doc.date,
ref: bus?._id.toString(),
Function putLocation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const putLocation = async (city, zip) => {
try {
if (!city && !zip) return;
// try with municipality = city + zip
const resMunicipality = await apiAdress(`${encodeURIComponent(city + " " + zip)}&type=municipality`);
- Read upRead up
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 validateEmail
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async validateEmail(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;
- Read upRead up
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 getFilteredSessions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async function getFilteredSessions(young, timeZoneOffset = "") {
const cohorts = await CohortModel.find({});
const region = getRegionForEligibility(young);
const department = getDepartmentForEligibility(young);
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (contract && application.status === APPLICATION_STATUS.VALIDATED) {
const statusContract = checkStatusContract(contract);
if (statusContract === CONTRACT_STATUS.DRAFT) data.actions.contractToBeFilled += 1;
if (statusContract === CONTRACT_STATUS.SENT && contract.structureManagerStatus === "WAITING_VALIDATION") data.actions.contractToBeSigned += 1;
if (statusContract === CONTRACT_STATUS.VALIDATED && young.status === YOUNG_STATUS.VALIDATED) data.actions.volunteerToHost += 1;
Function renderStep
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function renderStep(step) {
if (step === STEPS.COORDONNEES) return <StepCoordonnees />;
if (step === STEPS.REPRESENTANTS) return <StepRepresentants />;
if (step === STEPS.CONSENTEMENTS) return <StepConsentements />;
if (step === STEPS.DOCUMENTS) return <StepDocuments />;
- Read upRead up
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 buildYoungCleContext
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async function buildYoungCleContext(user) {
const contextFilters = [];
if (user.role === ROLES.ADMINISTRATEUR_CLE) {
const etablissement = await EtablissementModel.findOne({ $or: [{ coordinateurIds: user._id }, { referentEtablissementIds: user._id }] });
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (application.status === APPLICATION_STATUS.WAITING_VALIDATION) data.actions.applicationWaitingValidation += 1;
Function DetailTable
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export default function DetailTable({ rows, className, loading, isNational, onGoToRow, onExportDetail, cohort, user }: Props) {
const [isUserAuthorizedToExportData, setIsUserAuthorizedToExportData] = useState(false);
const [exportLoading, setExportLoading] = useState(false);
function goToRow(row) {
onGoToRow && onGoToRow(row);
- Read upRead up
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 ButtonDownloadEmptyFile
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export default function ButtonDownloadEmptyFile({ title, type, setIsLoading }) {
const getFile = async (type) => {
plausibleEvent(`Téléchargement Formulaire classe - Formulaire ${type}`);
try {
setIsLoading(true);
- Read upRead up
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 getMailParams
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getMailParams(type: string, template: string, young: YoungDto, contract?: ContractDto | null) {
if (type === "certificate" && template === "1")
return {
object: `Attestation de fin de phase 1 de ${young.firstName}`,
message: `Vous trouverez en pièce-jointe de ce mail l'attestation de réalisation de phase 1 du SNU.`,
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (!result[youngLigneBus.busId]) {
result[youngLigneBus.busId] = {};
result[youngLigneBus.busId]["youngs"] = [];
result[youngLigneBus.busId]["ligneBus"] = [];
result[youngLigneBus.busId]["meetingPoint"] = [];
Avoid deeply nested control flow statements. Open
if (!result[youngLigneBus.busId]["ligneBus"].find((ligne) => ligne._id.toString() === young.ligneId)) {
result[youngLigneBus.busId]["ligneBus"].push(youngLigneBus);
}
Avoid deeply nested control flow statements. Open
} else if (!["correspondance aller", "correspondance retour", "correspondance"].includes(line[`ID PDR ${pdrNumber}`]?.toLowerCase())) {
errors[`ID PDR ${pdrNumber}`].push({ line: index, error: PDT_IMPORT_ERRORS.BAD_PDR_ID, extra: line[`ID PDR ${pdrNumber}`] });
}