msimerson/Haraka

View on GitHub
logger.js

Summary

Maintainability
D
1 day
Test Coverage

Function log_if_level has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

logger.log_if_level = (level, key, plugin) => function () {
    if (logger.loglevel < logger[key]) { return; }
    let logobj = {
        level,
        uuid: '-',
Severity: Minor
Found in logger.js - About 7 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

Function log_if_level has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

logger.log_if_level = (level, key, plugin) => function () {
    if (logger.loglevel < logger[key]) { return; }
    let logobj = {
        level,
        uuid: '-',
Severity: Major
Found in logger.js - About 2 hrs to fix

    File logger.js has 276 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    // Log class
    
    const util      = require('util');
    const tty       = require('tty');
    Severity: Minor
    Found in logger.js - About 2 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                      if (data.todo.client_uuid) {    // dirty hack
                          logobj.origin = `outbound] [${data.todo.client_uuid}`;
                      }
      Severity: Major
      Found in logger.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if (data.todo.uuid) logobj.uuid = data.todo.uuid;
        Severity: Major
        Found in logger.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if (!logobj.message.endsWith(' ')) logobj.message += ' ';
          Severity: Major
          Found in logger.js - About 45 mins to fix

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

            function stringify (obj) {
                let str = '';
                let key;
                for (key in obj) {
                    let v = obj[key];
            Severity: Minor
            Found in logger.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