gadael/gadael

View on GitHub
api/services/user/requests/saveAbsence.js

Summary

Maintainability
D
2 days
Test Coverage

File saveAbsence.js has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const util = require('util');


Severity: Minor
Found in api/services/user/requests/saveAbsence.js - About 4 hrs to fix

    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;
    
    
    Severity: Major
    Found in api/services/user/requests/saveAbsence.js - About 2 hrs to fix

      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;
      
      
      Severity: Major
      Found in api/services/user/requests/saveAbsence.js - About 2 hrs to fix

        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;
        
            /**
        Severity: Major
        Found in api/services/user/requests/saveAbsence.js - About 2 hrs to fix

          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;
          
              /**
          Severity: Minor
          Found in api/services/user/requests/saveAbsence.js - About 1 hr 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 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'));
          Severity: Minor
          Found in api/services/user/requests/saveAbsence.js - About 1 hr to fix

            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;
            Severity: Minor
            Found in api/services/user/requests/saveAbsence.js - About 1 hr to fix

              Function saveEmbedEvents has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function saveEmbedEvents(requestDoc)
              {
                  let elem, events;
                  let AbsenceElemModel = requestDoc.model('AbsenceElem');
              
              
              Severity: Minor
              Found in api/services/user/requests/saveAbsence.js - About 1 hr to fix

                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');
                Severity: Minor
                Found in api/services/user/requests/saveAbsence.js - About 1 hr to fix

                  Function createElement has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function createElement(service, user, elem, collection, setElemProperties)
                  Severity: Minor
                  Found in api/services/user/requests/saveAbsence.js - About 35 mins to fix

                    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'));
                    Severity: Minor
                    Found in api/services/user/requests/saveAbsence.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 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');
                    Severity: Minor
                    Found in api/services/user/requests/saveAbsence.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

                    There are no issues that match your filters.

                    Category
                    Status