jquery/jquery — pull request #1437 by dmethvin (2013-11-15 21:33:06+00:00)
Title: Use JSHint for complexity metrics.

This is really more of a proof-of-concept and conversation starter than something to land.

Following up on our discussion Monday, this uses the complexity measures from JSHint and sets default limits that just about all the code currently passes. For the exceptions I've wrapped them in jshint directives that turn off the warnings. There's also a max line length check, but when set to our style guide's recommended max of 100 it is quite noisy. :smile:

Pros:
* The comments lay out where the hot spots are, so we can have a better idea of where to be careful and spend extra time in reviewing patches or refactoring.
* Only the people who read the code need to be concerned with these comments, so they're not drawing a bunch of attention from people who'd naively recommend we rewrite them just to get better metrics.

Cons:
* In jshint you can't restore a setting back to its original default or previous value. So if you want to avoid a warning you have to turn it off completely, then back on. That means subsequent editing in the complex areas may make things worse and nobody will notice it. What I want to do is bump the limit up around these just enough to avoid the warning.
* There's some bug in JSHint where the warning in effects has to be in a much larger block of code to be effectve, rather than being tightly around the offending function (`defaultPrefilter`).

I think the inability to push/pop temporary limits to specific metrics is a deal-killer for this idea. It might be worth looking into ESHint, seems like it could potentially do the job of both JSHint and jscs.