src/routes/mailGenerator/mailGenerator.js
Function exports
has 263 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function (sendgrid, env, url, disableMails) {
const logger = require('winston').loggers.get('mailGenerator');
const _ = require('lodash');
const constants = require('./constants.js');
const ejs = require('ejs');
Function exports
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = function (sendgrid, env, url, disableMails) {
const logger = require('winston').loggers.get('mailGenerator');
const _ = require('lodash');
const constants = require('./constants.js');
const ejs = require('ejs');
- 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
File mailGenerator.js
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
module.exports = function (sendgrid, env, url, disableMails) {
const logger = require('winston').loggers.get('mailGenerator');
const _ = require('lodash');
const constants = require('./constants.js');
const ejs = require('ejs');
Function sendErgebnisUpdate
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mailGenerator.sendErgebnisUpdate = function (team, spiel, emails, cb) {
logger.verbose('Sending Ergebnis-Update to %d Subscribers', emails.length);
const beachEventID = cls.getBeachEventID();
if (emails.length > 0) {
const templatePath = path.join(__dirname, emailTemplatesFolderName, 'ergebnisUpdate.ejs');
Function sendSpielReminder
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mailGenerator.sendSpielReminder = function (team, spiel, emails, cb) {
logger.verbose('Sending Spiel-Reminder to %d Subscribers', emails.length);
const beachEventID = cls.getBeachEventID();
if (emails.length > 0) {
const templatePath = path.join(__dirname, emailTemplatesFolderName, 'spielReminder.ejs');
Function registerMail
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mailGenerator.registerMail = function (user, cb) {
logger.verbose('Sending Register-Mail');
if (user) {
const templatePath = path.join(__dirname, emailTemplatesFolderName, 'register.ejs');
return fs.readFile(templatePath, 'utf-8', function (err, template) {
Function passwordForgotMail
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mailGenerator.passwordForgotMail = function (user, cb) {
logger.verbose('Sending Password-Forgot-Email');
if (user) {
const templatePath = path.join(__dirname, emailTemplatesFolderName, 'passwordForgot.ejs');
return fs.readFile(templatePath, 'utf-8', function (err, template) {
Function bugReportMail
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mailGenerator.bugReportMail = function (data, cb) {
logger.verbose('Sending Bug-Report');
const beachEventID = cls.getBeachEventID();
const templatePath = path.join(__dirname, emailTemplatesFolderName, 'bugReport.ejs');
return fs.readFile(templatePath, 'utf-8', function (err, template) {
Function sendDefaultMail
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mailGenerator.sendDefaultMail = function (emails, subject, body, cb) {
logger.verbose('Sending Plain-Email to %d Subscribers', emails.length);
if (emails.length > 0) {
const templatePath = path.join(__dirname, emailTemplatesFolderName, 'default.ejs');
return fs.readFile(templatePath, 'utf-8', function (err, template) {