If had a Ruby linter or Ruby checkstyle program, I would want to configure it to detect the following things:
- Duplicate methods in the same class, module (this produces a warning at runtime if warnings are enabled)
- Parens in methods with no arguments
- Missing parens in methods with arguments (or check that there aren't parens, if you're into that)
- Method indentation is consistent
- Consistent block spacing (
.map{|ea| ea}
vs..map {|ea| ea}
vs..map { |ea| ea }
, etc.) private
,protected
are consistently indented (or outdented)do...end
blocks must be used beyond a certain line length- No semi-colons (possible exceptions for one-line exception classes)
There are a few libraries that will product an AST from Ruby source, though few that will provide a concrete syntax tree or parse tree (with lines, parens, etc.) intact. The ParseTree library appears to return ASTs.
Existing Options
- Roodi. Focuses on design issues like method length, number of method arguments, cyclomatic complexity.
- ruby-lint. Requires Ruby 1.9.
- Diamondback Ruby. "While DRuby is an ongoing research project, it already works quite well for small, self-contained Ruby scripts. Currently, it is unable to analyze much of the Ruby standard library 'out-of-the-box.'"
- pelusa. Requires rubinius to run. Focuses on design issues.