File index.js
has 903 lines of code (exceeds 700 allowed). Consider refactoring. Open
const AWS = require("aws-sdk");
const https = require("https");
const http = require("http");
const passwordValidator = require("password-validator");
const sanitizeHtml = require("sanitize-html");
Function updateStatusPhase1WithOldRules
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
async function updateStatusPhase1WithOldRules(young, validationDate, isTerminale, user) {
try {
const now = new Date();
// Cette constante nous permet de vérifier si un jeune a passé sa date de validation (basé sur son grade)
const isValidationDatePassed = now >= validationDate;
- 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 updateStatusPhase1WithSpecificCase
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
async function updateStatusPhase1WithSpecificCase(young, validationDate, user) {
try {
const now = new Date();
// Cette constante nous permet de vérifier si un jeune a passé sa date de validation (basé sur son grade)
const isValidationDatePassed = now >= validationDate;
- 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 updateStatusPhase1
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
async function updateStatusPhase1(young, validationDateWithDays, user) {
const initialState = young.statusPhase1;
try {
const now = new Date();
const validationDate = new Date(validationDateWithDays);
- 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 checkStatusContract
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const checkStatusContract = (contract) => {
if (!contract.invitationSent || contract.invitationSent === "false") return "DRAFT";
// To find if everybody has validated we count actual tokens and number of validated. It should be improved later.
const tokenKeys = ["projectManagerToken", "structureManagerToken"];
const validateKeys = ["projectManagerStatus", "structureManagerStatus"];
- 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 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 });
- 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"