File saveAbsence.js
has 372 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const util = require('util');
Function getElementIgniter
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getElementIgniter(service, collection, user, checkRight)
{
const RightModel = service.app.db.models.Right;
const gt = service.app.utility.gettext;
Function setElemProperties
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function setElemProperties(element, elem) {
let elemPeriod = getElemPeriod(elem);
let rightDocument, renewalDocument;
Function createEvents
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createEvents(service, user, elem, events)
{
let EventModel = service.app.db.models.CalendarEvent;
/**
Function createEvents
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function createEvents(service, user, elem, events)
{
let EventModel = service.app.db.models.CalendarEvent;
/**
- 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 saveAbsenceDistribution
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function saveAbsenceDistribution(service, user, params, collection) {
if (params.absence.distribution === undefined || params.absence.distribution.length === 0) {
return Promise.reject(new Error('Right distribution is mandatory to save an absence request'));
Function checkElement
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function checkElement(service, contain, moment)
{
const gt = service.app.utility.gettext;
let rightDocument = contain.right;
Function saveEmbedEvents
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function saveEmbedEvents(requestDoc)
{
let elem, events;
let AbsenceElemModel = requestDoc.model('AbsenceElem');
Function createElement
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createElement(service, user, elem, collection, setElemProperties)
{
if (undefined === elem.right) {
throw new Error('element must contain a right property');
Function createElement
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function createElement(service, user, elem, collection, setElemProperties)
Function saveAbsenceDistribution
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function saveAbsenceDistribution(service, user, params, collection) {
if (params.absence.distribution === undefined || params.absence.distribution.length === 0) {
return Promise.reject(new Error('Right distribution is mandatory to save an absence request'));
- 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 createElement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function createElement(service, user, elem, collection, setElemProperties)
{
if (undefined === elem.right) {
throw new Error('element must contain a right property');
- 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"