lib/cluster.js

Summary

Maintainability
F
5 days
Test Coverage

Function masterInit has 228 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function masterInit() {
  cluster.workers = {};

  var intercom = new EventEmitter;
  cluster.settings = {};
Severity: Major
Found in lib/cluster.js - About 1 day to fix

    Function masterInit has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

    function masterInit() {
      cluster.workers = {};
    
      var intercom = new EventEmitter;
      cluster.settings = {};
    Severity: Minor
    Found in lib/cluster.js - About 1 day 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 cluster.js has 519 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Copyright Joyent, Inc. and other Node contributors.
    //
    // Permission is hereby granted, free of charge, to any person obtaining a
    // copy of this software and associated documentation files (the
    // "Software"), to deal in the Software without restriction, including
    Severity: Major
    Found in lib/cluster.js - About 1 day to fix

      Function workerInit has 113 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function workerInit() {
        var handles = {};
      
        // Called from src/node.js
        cluster._setupWorker = function() {
      Severity: Major
      Found in lib/cluster.js - About 4 hrs to fix

        Function workerInit has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        function workerInit() {
          var handles = {};
        
          // Called from src/node.js
          cluster._setupWorker = function() {
        Severity: Minor
        Found in lib/cluster.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

        Function setupMaster has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          cluster.setupMaster = function(options) {
            var settings = {
              args: process.argv.slice(2),
              exec: process.argv[1],
              execArgv: process.execArgv,
        Severity: Minor
        Found in lib/cluster.js - About 1 hr to fix

          Function fork has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            cluster.fork = function(env) {
              cluster.setupMaster();
              var id = ++ids;
              var workerProcess = createWorkerProcess(id, env);
              var worker = new Worker({
          Severity: Minor
          Found in lib/cluster.js - About 1 hr to fix

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

              function queryServer(worker, message) {
                var args = [message.address,
                            message.port,
                            message.addressType,
                            message.fd];
            Severity: Minor
            Found in lib/cluster.js - About 1 hr to fix

              Function rr has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function rr(message, cb) {
                  if (message.errno)
                    return cb(message.errno, null);
              
                  var key = message.key;
              Severity: Minor
              Found in lib/cluster.js - About 1 hr to fix

                Function SharedHandle has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function SharedHandle(key, address, port, addressType, backlog, fd) {
                Severity: Minor
                Found in lib/cluster.js - About 45 mins to fix

                  Function _getServer has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    cluster._getServer = function(obj, address, port, addressType, fd, cb) {
                  Severity: Minor
                  Found in lib/cluster.js - About 45 mins to fix

                    Function RoundRobinHandle has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function RoundRobinHandle(key, address, port, addressType, backlog, fd) {
                    Severity: Minor
                    Found in lib/cluster.js - About 45 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status