bbatsov/rubocop — pull request #590 by jonas054 (2013-10-28 18:19:30+00:00)
Title: Add CyclomaticComplexity cop.

Fixes #579.

The specs are more or less "stolen" from https://github.com/roodi/roodi/blob/master/spec/roodi/checks/cyclomatic_complexity_method_check_spec.rb. Roodi is a tool that RuboCop already has a bit of overlap with. Their definition of cyclomatic complexity seems sound. I've only changed one thing. In a `case`/`when`, only `when` should add to the complexity number, I think. So a `case` with two `when`s adds 2, not 3, to the complexity number.

I've chosen `6` as the default `Max`. Accoring to a comment in https://github.com/roodi/roodi/blob/master/lib/roodi/checks/cyclomatic_complexity_method_check.rb 1-4 is considered good, 5-8 ok. Note that RuboCop itself has some way to go before coming down to that number.

Only methods are checked for cyclomatic complexity. Code outside of methods are not checked.