File helpers.js
has 1079 lines of code (exceeds 250 allowed). Consider refactoring. Open
const logger = require('winston').loggers.get('apiHelper');
const async = require('async');
const messages = require('./messages/messages.js')();
const _ = require('lodash');
const handler = require('./handler.js');
Function fillSpiele
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fillSpiele(callback) {
logger.verbose('Filling Spiele with Team Infos');
const beachEventID = cls.getBeachEventID();
const clsSession = cls.getNamespace();
return clsSession.run(function () {
Function fillSpielFromGruppe
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fillSpielFromGruppe(spiel, cb) {
logger.verbose('Filling Spiel Nummer %d from Gruppe', spiel.nummer);
const calculatedTeams = {
A: undefined,
B: undefined
Function fillSpielFromSpiel
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fillSpielFromSpiel(spiel, cb) {
logger.verbose('Filling Spiel Nummer %d from Spiel', spiel.nummer);
const calculatedTeams = {
A: undefined,
B: undefined
Function fillTeamFromGruppe
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fillTeamFromGruppe(team, cb) {
logger.verbose('Filling Team %s from Gruppe', team._id);
const beachEventID = cls.getBeachEventID();
const clsSession = cls.getNamespace();
return clsSession.run(function () {
Function calcSpielDateTimePresets
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function calcSpielDateTimePresets(spielplan, nr, plaetze, delays) {
const startDatum = moment(spielplan.startdatum, 'DD.MM.YYYY');
const dailyStartTime = moment(spielplan.startzeit, 'HH:mm');
const dailyEndTime = moment(spielplan.endzeit, 'HH:mm');
let spielzeit, pausenzeit;
Function reloadAnmeldeObjects
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function reloadAnmeldeObjects(cb) {
const beachEventID = cls.getBeachEventID();
const clsSession = cls.getNamespace();
return clsSession.run(function () {
clsSession.set('beachEventID', beachEventID);
Function createGruppeWithTeams
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createGruppeWithTeams(jugendid, data, cb) {
const beachEventID = cls.getBeachEventID();
const clsSession = cls.getNamespace();
return clsSession.run(function () {
clsSession.set('beachEventID', beachEventID);
Function checkSpielOrderChangeAllowed
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function checkSpielOrderChangeAllowed(spiele) {
logger.verbose('Check Spiel Order Allowed');
const plaetze = parseInt(process.env.PLAETZE, 10);
logger.verbose('Calculated %d Plätze', plaetze);
let teamsParallel = [];
- 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 teamCalcErgebnisse
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function teamCalcErgebnisse(team, gruppe, cb) {
const query = {
beendet: true
};
if (gruppe) {
Function calcSpielDateTime
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function calcSpielDateTime(nr, spielplan, delays) {
delays = delays || {};
logger.silly('Calculate Date and Time for a Spiel');
if (!checkSpielplanZeitenValid(spielplan)) {
return undefined;
Function getEntity
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getEntity(model, population, notFoundMessage, res, req) {
const queryData = getEntityQuery(model, req);
const query = queryData.query;
const searchById = queryData.searchById;
const beachEventID = cls.getBeachEventID();
Function fill
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fill(entity, cb) {
const beachEventID = cls.getBeachEventID();
const clsSession = cls.getNamespace();
return clsSession.run(function () {
clsSession.set('beachEventID', beachEventID);
Function checkSpielChangeable
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function checkSpielChangeable(spielid, cb) {
const beachEventID = cls.getBeachEventID();
const clsSession = cls.getNamespace();
return clsSession.run(function () {
clsSession.set('beachEventID', beachEventID);
Function getRequiredRouteConfig
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getRequiredRouteConfig(routes, path, method, configKey) {
logger.silly('Getting Route Config');
path = removeLastSlashFromPath(path);
let route = routes[path];
Function getRequiredRouteConfig
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getRequiredRouteConfig(routes, path, method, configKey) {
logger.silly('Getting Route Config');
path = removeLastSlashFromPath(path);
let route = routes[path];
- 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
Consider simplifying this complex logical expression. Open
if (foundSpiel.teamA && foundSpiel.teamA._id &&
foundSpiel.teamB && foundSpiel.teamB._id &&
foundSpiel.gewinner && foundSpiel.gewinner._id) {
if (foundSpiel.teamA._id.toString() === foundSpiel.gewinner._id.toString()) {
calculatedTeams[letter] = foundSpiel.teamB;
Function gruppeFindPlace
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function gruppeFindPlace(teams, spieleDerGruppe, platz, gruppe, callback) {
Function findEntityAndPushTeam
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function findEntityAndPushTeam(model, id, team, res, callback) {
Function getEntity
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function getEntity(model, population, notFoundMessage, res, req) {
Function getEntityQuery
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function getEntityQuery(model, req) {
logger.silly('Getting Entity Query');
if (req.query.id) {
return queryId(model, req.query.id);
} else if (req.query.team) {
- 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 routeconfig;
Avoid too many return
statements within this function. Open
return routeconfig.split(' ');
Avoid too many return
statements within this function. Open
return queryIdentifier(model, req.query.identifier);
Avoid too many return
statements within this function. Open
return {
dailyStartTime: dailyStartTime,
dailyEndTime: dailyEndTime,
spielePerDay: spielePerDay,
offsetDays: offsetDays,
Avoid too many return
statements within this function. Open
return undefined;
Avoid too many return
statements within this function. Open
return queryDate(model, req.query.date);
Avoid too many return
statements within this function. Open
return querySlug(model, req.query.slug);
Avoid too many return
statements within this function. Open
return {
searchById: false,
query: model.find({})
}