msimerson/log-ship-elastic-postfix

View on GitHub

Showing 12 of 12 total issues

File logship.js has 321 lines of code (exceeds 250 allowed). Consider refactoring.
Open

if (process.env.COVERAGE) require('blanket');

// node built-ins
var path      = require('path');
var util      = require('util');
Severity: Minor
Found in lib/logship.js - About 3 hrs to fix

    Function populatePfdocsFromEs has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    PostfixToElastic.prototype.populatePfdocsFromEs = function(done) {
      var p2e = this;
      var pfQids = {};
    
      // get a (likely short) list of elastic time series indexes in which these
    Severity: Minor
    Found in lib/logship.js - About 1 hr to fix

      Function saveResultsToEs has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      PostfixToElastic.prototype.saveResultsToEs = function(done) {
        var p2e = this;
        // create/update 'em all to ES
        // logger.debug(util.inspect(this.pfDocs, {depth: null}));
        var esBulk = [];  // index, create, update
      Severity: Minor
      Found in lib/logship.js - About 1 hr to fix

        Function doQueue has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        PostfixToElastic.prototype.doQueue = function(done) {
          var p2e = this;
        
          if (this.queue.length === 0) {
            if (this.reader && this.reader.watcher) {
        Severity: Minor
        Found in lib/logship.js - About 1 hr to fix

          Function update has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          PostfixDoc.prototype.update = function(doc, lo) {
            switch (lo.prog) {
              case 'postfix/qmgr':    // a queue event (1+ per msg)
                return this.addToPostfixDocQmgr(doc, lo);
              case 'postfix/smtp':    // a delivery attempt
          Severity: Minor
          Found in lib/postfix-doc.js - About 1 hr to fix

            Function addEvent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            PostfixDoc.prototype.addEvent = function(doc, e) {
            
              if (e.action && e.action === 'queued') {
                // when postfix touches a message, it emits a qmgr. The first
                // informs us when a message enters the queue, subsequent are useless.
            Severity: Minor
            Found in lib/postfix-doc.js - About 1 hr 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 isValidDir has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.isValidDir = function(dir, done) {
            
              if (!done) {
                if (this.isDirectory(dir) && this.isWritable(dir)) {
                  return true;
            Severity: Minor
            Found in lib/spool.js - About 55 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

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

            exports.isWritable = function(dir, done) {
              if (!fs.access) { return this.isWritablePreV12(dir, done); }
              if (!done) {
                try {
                  fs.accessSync(dir, fs.W_OK);
            Severity: Minor
            Found in lib/spool.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

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

            function loadConfig (etcDir) {
              var file = 'log-ship-elastic-postfix.ini';
              var candidates = [];
              if (etcDir) candidates.push(path.resolve(etcDir, file));
              if (etcDir !== '/etc') {
            Severity: Minor
            Found in lib/config.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

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

            PostfixDoc.prototype.update = function(doc, lo) {
              switch (lo.prog) {
                case 'postfix/qmgr':    // a queue event (1+ per msg)
                  return this.addToPostfixDocQmgr(doc, lo);
                case 'postfix/smtp':    // a delivery attempt
            Severity: Minor
            Found in lib/postfix-doc.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

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

            PostfixToElastic.prototype.tryLoadingRedis = function() {
              if (!this.cfg.redis) return;
              if (!this.cfg.redis.module) return;
              try {
                var redis = require(this.cfg.redis.module);
            Severity: Minor
            Found in lib/logship.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

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

            PostfixToElastic.prototype.doQueue = function(done) {
              var p2e = this;
            
              if (this.queue.length === 0) {
                if (this.reader && this.reader.watcher) {
            Severity: Minor
            Found in lib/logship.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

            Severity
            Category
            Status
            Source
            Language