Marty Andrews

artful code

Friday, September 19, 2008

Release of Roodi 1.3.0

I've just released version 1.3.0 of Roodi. It contains two new checks - a CaseMissingElse checks that ensures you have a default path through your case statements, and an AssignmentInConditional check that looks out for things like if foo = 1 which are likely to be mis-typed equality checks. I've also DRY'ed up the code a bit, but the major new feature is the ability to provide your own configuration file.

If a config file is not provided, Roodi now configures itself with via a YAML one that ships inside the gem which looks like this:

AssignmentInConditionalCheck:    { }CaseMissingElseCheck:            { }ClassLineCountCheck:             { line_count: 300 }ClassNameCheck:                  { pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/ }CyclomaticComplexityBlockCheck:  { complexity: 4 }CyclomaticComplexityMethodCheck: { complexity: 8 }EmptyRescueBodyCheck:            { }ForLoopCheck:                    { }MethodLineCountCheck:            { line_count: 20 }MethodNameCheck:                 { pattern: !ruby/regexp /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/ }ModuleLineCountCheck:            { line_count: 300 }ModuleNameCheck:                 { pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/ }ParameterNumberCheck:            { parameter_count: 5 }

It's basically a list of checks, each with a hash of options for that check. You can take this file as a starting point and remove existing check, add your own custom new checks, or change the default values on some of them. I've intentionally been strict on the values on some of the checks with thresholds, setting high standards that I'd expect to see on my own projects. If you're working through a long list of warnings and want to eliminate some of the noise, or if you decide the thresholds should be different, you can save this in your own config file and use it to configure roodi.

To use your own config file with roodi, pass it in as a value to the -config parameter on the command line like this:

roodi -config=my_roodi_config.yml "rails_app/**/*.rb"

No comments:

Post a Comment