BerniWittmann/spielplanismaning

View on GitHub
src/routes/mailGenerator/mailGenerator.js

Summary

Maintainability
F
3 days
Test Coverage

Function exports has 263 lines of code (exceeds 25 allowed). Consider refactoring.
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');
Severity: Major
Found in src/routes/mailGenerator/mailGenerator.js - About 1 day to fix

    Function exports has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    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');
    Severity: Minor
    Found in src/routes/mailGenerator/mailGenerator.js - About 3 hrs 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

    File mailGenerator.js has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    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');
    Severity: Minor
    Found in src/routes/mailGenerator/mailGenerator.js - About 2 hrs to fix

      Function sendErgebnisUpdate has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      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');
      Severity: Major
      Found in src/routes/mailGenerator/mailGenerator.js - About 2 hrs to fix

        Function sendSpielReminder has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        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');
        Severity: Minor
        Found in src/routes/mailGenerator/mailGenerator.js - About 1 hr to fix

          Function registerMail has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          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) {
          Severity: Minor
          Found in src/routes/mailGenerator/mailGenerator.js - About 1 hr to fix

            Function passwordForgotMail has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            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) {
            Severity: Minor
            Found in src/routes/mailGenerator/mailGenerator.js - About 1 hr to fix

              Function bugReportMail has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              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) {
              Severity: Minor
              Found in src/routes/mailGenerator/mailGenerator.js - About 1 hr to fix

                Function sendDefaultMail has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                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) {
                Severity: Minor
                Found in src/routes/mailGenerator/mailGenerator.js - About 1 hr to fix

                  There are no issues that match your filters.

                  Category
                  Status