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');
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, []);
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);
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();
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);
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;
Function getTeam
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function getTeam(gruppe, gegner, geradeSpielendeTeams, lastPlayingTeams, spiele, name, i) {
Function createSpielFromSpiel
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function createSpielFromSpiel(spielA, spielB, rankA, rankB, jugendid, label) {
Function getPossibleGegner
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function getPossibleGegner(gruppe, team, geradeSpielendeTeams, lastPlayingTeams, games) {
Function createSpiel
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function createSpiel(gruppen, rankA, rankB, jugendid, label) {
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++) {
- 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 too many return
statements within this function. Open
return 0;
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) {
- 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 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;
- 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"