msimerson/log-ship-elastic-postfix

View on GitHub
lib/logship.js

Summary

Maintainability
C
1 day
Test Coverage

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 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

          There are no issues that match your filters.

          Category
          Status