BerniWittmann/spielplanismaning

View on GitHub
src/routes/spielplanGenerator/helper.js

Summary

Maintainability
F
3 days
Test Coverage

File helper.js has 821 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const _ = require('lodash');
const logger = require('winston').loggers.get('spielplanGenerator');
const mongoose = require('mongoose');
const async = require('async');
const moment = require('moment');
Severity: Major
Found in src/routes/spielplanGenerator/helper.js - About 1 day to fix

    Function generateZwischenGruppen has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function generateZwischenGruppen(gruppen, jugendid, maxTeamsAdvance, callback) {
        const gruppenLength = gruppen.length;
        const relevantGruppen = [];
        if (gruppenLength <= 2) {
            return callback(null, []);
    Severity: Major
    Found in src/routes/spielplanGenerator/helper.js - About 3 hrs to fix

      Function removeZwischenRundenGruppe has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function removeZwischenRundenGruppe(callback) {
          const beachEventID = cls.getBeachEventID();
          const clsSession = cls.getNamespace();
          return clsSession.run(function () {
              clsSession.set('beachEventID', beachEventID);
      Severity: Major
      Found in src/routes/spielplanGenerator/helper.js - About 2 hrs to fix

        Function generateZwischenGruppenHelper has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function generateZwischenGruppenHelper(gruppen, maxTeamsAdvance, zeiten, cb) {
            let relevantGruppen = [];
            const beachEventID = cls.getBeachEventID();
            const clsSession = cls.getNamespace();
        
        
        Severity: Minor
        Found in src/routes/spielplanGenerator/helper.js - About 1 hr to fix

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

          function calculatePresetSpielplanData(data) {
              let teams = [];
          
              data.gruppen.forEach(function (gruppe) {
                  teams = teams.concat(gruppe.teams);
          Severity: Minor
          Found in src/routes/spielplanGenerator/helper.js - About 1 hr to fix

            Function configureProperties has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function configureProperties(payload) {
                logger.silly('Running with Payload', payload);
                const plaetze = getPlaetze();
                logger.verbose('Using %d Plätze', plaetze);
                const gruppen = payload.gruppen;
            Severity: Minor
            Found in src/routes/spielplanGenerator/helper.js - About 1 hr to fix

              Function getTeam has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function getTeam(gruppe, gegner, geradeSpielendeTeams, lastPlayingTeams, spiele, name, i) {
              Severity: Major
              Found in src/routes/spielplanGenerator/helper.js - About 50 mins to fix

                Function createSpielFromSpiel has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function createSpielFromSpiel(spielA, spielB, rankA, rankB, jugendid, label) {
                Severity: Minor
                Found in src/routes/spielplanGenerator/helper.js - About 45 mins to fix

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

                  function getPossibleGegner(gruppe, team, geradeSpielendeTeams, lastPlayingTeams, games) {
                  Severity: Minor
                  Found in src/routes/spielplanGenerator/helper.js - About 35 mins to fix

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

                    function createSpiel(gruppen, rankA, rankB, jugendid, label) {
                    Severity: Minor
                    Found in src/routes/spielplanGenerator/helper.js - About 35 mins to fix

                      Function fillBeendeteSpieleWithEmpty has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function fillBeendeteSpieleWithEmpty(beendeteSpiele) {
                          const maxNr = _.maxBy(beendeteSpiele, 'nummer');
                          if (maxNr && maxNr.nummer !== beendeteSpiele.length) {
                              const arr = [];
                              for (let i = 1; i <= maxNr.nummer; i++) {
                      Severity: Minor
                      Found in src/routes/spielplanGenerator/helper.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

                      Avoid too many return statements within this function.
                      Open

                          return 0;
                      Severity: Major
                      Found in src/routes/spielplanGenerator/helper.js - About 30 mins to fix

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

                        function sortEndrundeSpiele(a, b) {
                            if (a.label === spielLabels.ZWISCHENRUNDENSPIEL || b.label === spielLabels.ZWISCHENRUNDENSPIEL) {
                                return calcSortForZwischenrunde(a, b);
                            }
                            if (a.label === spielLabels.FINALE || b.label === spielLabels.FINALE) {
                        Severity: Minor
                        Found in src/routes/spielplanGenerator/helper.js - 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 calcSortForHalbFinale has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function calcSortForHalbFinale(a, b) {
                            if (a.label === spielLabels.HALBFINALE && a.label !== b.label) {
                                return b.rankA >= 3 ? 1 : -1;
                            } else if (b.label === spielLabels.HALBFINALE && a.label !== b.label) {
                                return a.rankA >= 3 ? -1 : 1;
                        Severity: Minor
                        Found in src/routes/spielplanGenerator/helper.js - 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

                        There are no issues that match your filters.

                        Category
                        Status