godaddy / node-cluster-service

Turn your single process code into a fault-resilient, multi-process service with built-in REST & CLI support. Restart or hot upgrade your web servers with zero downtime or impact to clients.

Home Page:https://www.npmjs.org/package/cluster-service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contributing - code style

jsdevel opened this issue · comments

@asilvas This is a really cool module, and the slides really helped! Completely sold here and I may use it for personal projects.

The main issue I have with the source code is it's code style. I dove into the source to get acquainted with it and I had trouble.

The main issues I have with the code style are:

  1. Funky variable declaration blocks
  2. 8 spaces for tabs
  3. var hoisting

I'd be more than happy to issue a pull request in the next couple of days if you're ok with that.

Observe

Funky variable declaration blocks

var
    boo,
    coo
;

Should be:

var boo;
var coo;

8 spaces for tabs

(function(){
        (function(){

        })();
})();

Should be:

(function(){
  (function(){

  })();
})();

var hoisting

var something = true;
(function(){
        if(something){
                var something = false;//very dangerous!  This line is never reached
        }
})();

Should be:

var something = true;
(function(){
  var something;
  if(something){
    something = false;//Still not reached, but it's clearer now.
  }
})();

Thanks!

Not a big fan of non-functional commits, but I'll take it as a one-time. No redundant variable declares please, that is a personal preference and is just as easy to read either way. In addition to some of the features listed, there's also room for improvement on code coverage. With multi-process, it's a bit trickier to get full coverage, but worth while.

Regarding spacing, looks like the project uses tabs, not spaces, so it might be your editor that is converting those to 8 spaces. Unless it's a mix of the two.

Awesome.

Yea, I think github converts tabs to spaces so that's probably why it was showing up like that.

I'll be working with cluster service today. Looking forward to diving in!