encharm/http-master

View on GitHub

Showing 71 of 71 total issues

Function serviceFunction has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var serviceFunction = function(logFile) {
      if(logFileHandlers[logFile])
        return logFileHandlers[logFile];

      var watch;
Severity: Minor
Found in modules/services/logFile.js - About 1 hr to fix

    Function serverForPortConfig has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function serverForPortConfig(host, portNumber, portConfig) {
      var self = this;
      var server;
    
      self.cachedServers = self.cachedServers || {};
    Severity: Minor
    Found in src/HttpMasterWorker.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 checkPathForReq has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    DispatchTable.prototype.checkPathForReq = function(req, entry) {
      if(!entry.path)
        return true;
      var m;
    
    
    Severity: Minor
    Found in src/DispatchTable.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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        entryParser: function(config) {
          if(!config.match(/\s*=\s*/)) {
            throw new Error('Bad format, should be key=value');
          }
          var m = config.match(/^(.*?)\s*=\s*(.*$)/);
    Severity: Major
    Found in modules/middleware/addHeaderToResponse.js and 1 other location - About 1 hr to fix
    modules/middleware/addHeader.js on lines 9..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 63.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        entryParser: function(config) {
          if(!config.match(/\s*=\s*/)) {
            throw new Error('Bad format, should be key=value');
          }
          var m = config.match(/^(.*?)\s*=\s*(.*$)/);
    Severity: Major
    Found in modules/middleware/addHeader.js and 1 other location - About 1 hr to fix
    modules/middleware/addHeaderToResponse.js on lines 9..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 63.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function bindTypeGeneric has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function bindTypeGeneric(doCache, name, type) {
      // implicit name from function name
      if(typeof name === 'function') {
        type = name;
        var constructorName = functionName(type);
    Severity: Minor
    Found in src/di.js - About 1 hr to fix

      Function processDirectory has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              let processDirectory = (dirName, cb) => {
                fs.readdir(dirName, (err, files) => {
      
                  if(err) return cb(err);
      
      
      Severity: Minor
      Found in src/certScanner.js - About 1 hr to fix

        Function createHandlers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        function createHandlers(portNumber, portConfig) {
          var self = this;
        
          var di = this.di.makeChild();
          di.bindInstance('di', di);
        Severity: Minor
        Found in src/HttpMasterWorker.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 dropPrivileges has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        function dropPrivileges() {
          var strInfo;
          if (process.setgid) {
            var group = config.group;
            if (typeof group === 'string') {
        Severity: Minor
        Found in src/worker.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 WebsockifyMiddleware has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function WebsockifyMiddleware() {
          return {
            requestHandler: function(req, res, next, parsedEntry) {
              if(req.upgrade) {
                var socket = new net.Socket();
        Severity: Minor
        Found in modules/middleware/websockify.js - About 1 hr to fix

          Function Logging has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function Logging(logFileService, master, moduleConfig) {
            var appStream;
            if(!master)
              return;
          
          
          Severity: Minor
          Found in modules/appLog.js - About 1 hr to fix

            Function requestHandler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                requestHandler: function(req, res, next, dispatchTarget) {
                  req.next = next;
                  // workaround for node-http-proxy/#591
                  if(!req.headers.host) {
                    req.headers.host = '';
            Severity: Minor
            Found in modules/middleware/proxy.js - About 1 hr to fix

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

              function patchSslConfig(portEntrySslConfig) {
                if (nodeVersion >= 0.11) { // use fancy cipher settings only for 0.11
                  if (portEntrySslConfig.honorCipherOrder !== false) {
                    // prefer server ciphers over clients - prevents BEAST attack
                    portEntrySslConfig.honorCipherOrder = true;
              Severity: Minor
              Found in src/HttpMasterWorker.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 lazyGetTcpServer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function lazyGetTcpServer(port, host, cb) {
                var tcpServers = this.tcpServers;
              
                var entry = (host ? host + ':' + port : port);
                if (tcpServers[entry]) {
              Severity: Minor
              Found in src/HttpMasterWorker.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 resolve has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              DI.prototype.resolve = function(obj, overrides) {
                var dependencyMap = extend({}, this.mapping, overrides);
                var args;
                var resolved;
              
              
              Severity: Minor
              Found in src/di.js - About 1 hr to fix

                Function processMatch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function processMatch(target, m) {
                  var keyWithOffset;
                  if (m) {
                    for(var key in m) {
                      var replaceFrom = key;
                Severity: Minor
                Found in src/regexpHelper.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 WebsockifyMiddleware has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = function WebsockifyMiddleware() {
                  return {
                    requestHandler: function(req, res, next, parsedEntry) {
                      if(req.upgrade) {
                        var socket = new net.Socket();
                Severity: Minor
                Found in modules/middleware/websockify.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 loadConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                HttpMasterWorker.prototype.loadConfig = function(config, configLoaded) {
                  var self = this;
                
                  var events = new EventEmitter();
                
                
                Severity: Minor
                Found in src/HttpMasterWorker.js - About 45 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 exports has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = function(argv, data, cb) {
                
                  var oldWarn = console.warn;
                  console.warn = function() {};
                
                
                Severity: Minor
                Found in migrateV1Config.js - About 45 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 reload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                HttpMaster.prototype.reload = function(config, reloadDone) {
                  var self = this;
                  this.emit('reload');
                
                  function actualReload(config) {
                Severity: Minor
                Found in src/HttpMaster.js - About 45 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