<p>One thing I really miss about Java is the tool support.  FindBugs, Checkstyle and PMD made for a holy trinity of code quality metrics and automatic bug checking.  </p>

<p>Is there anything that will check for simple bugs and / or style violations of Ruby code?  Bonus points if I can adapt it for frameworks such as Rails so that Rails idioms are adhered to.</p>

[{'answer_id': 55357, 'author': 'Orion Edwards', 'author_id': 234, 'author_profile': 'https://Stackoverflow.com/users/234', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://github.com/kevinclark/dust/tree/master" rel="nofollow noreferrer">Dust</a> looks like it can help you find unused and useless code, which seems like it sort-of fits what you\'re after.</p>\n\n<p>I\'m not aware of any other such tools.<br>\nThis problem is vastly harder to address in ruby than it is in java - you\'ll note that all those java tools brand themselves as using \'static analysis\' of the code.<br>\nStatic analysis of ruby code often isn\'t possible, because there isn\'t anything static that you can analyze (methods often get created at runtime and so on)</p>\n\n<p>At any rate, some of these things are unneeded in ruby because the language builds them in.\nFor example, you don\'t need a coding standard to enforce that your classes are all <code>NamedLikeThis</code> because the code won\'t work if they aren\'t.</p>\n\n<p>P.S. I <em>have</em> to add the standard disclaimer that those kind of tools can often be a bit of a red herring. You can spend all day making your code adhere to what the tool thinks it should be, and end up with more bugs than you started with.<br>\nIMHO the best solution is to write your code fluently so you can read it more easily. No amount of static analysis is going to be as good as a human reading code which clearly states what it is meant to do. Being able to do this is where ruby is light-years ahead of many other languages. I personally would recommend you aim your efforts at learning how to write more fluently, and educating your team about such things, than spending time on static analysis.</p>\n'}, {'answer_id': 55712, 'author': 'Austin Moody', 'author_id': 1754676, 'author_profile': 'https://Stackoverflow.com/users/1754676', 'pm_score': 5, 'selected': True, 'text': '<p>I\'ve recently started looking for something like this for Ruby.  What I\'ve run across so far:</p>\n\n<ul>\n<li><a href="http://saikuro.rubyforge.org/" rel="noreferrer">Saikuro</a></li>\n<li><a href="http://www.martyandrews.net/blog/2008/09/first_official_release_of_rood.html" rel="noreferrer">Roodi</a></li>\n<li><a href="http://ruby.sadi.st/Flog.html" rel="noreferrer">Flog</a></li>\n</ul>\n\n<p>These might be places to start.  Unfortunately I haven\'t used any of the three enough yet to offer a good opinion.</p>\n'}, {'answer_id': 57217, 'author': 'scottd', 'author_id': 5935, 'author_profile': 'https://Stackoverflow.com/users/5935', 'pm_score': 3, 'selected': False, 'text': '<p>Saikuro and Flog can be good for getting a basic idea of code complexity.  You can also use a tool like rcov to look at your test coverage.<br>\nThere is a plugin for Rails projects that combine all those metrics into a single rake task.  It is called <a href="http://metric-fu.rubyforge.org/" rel="noreferrer">metric_fu</a>.</p>\n'}, {'answer_id': 321596, 'author': 'danmayer', 'author_id': 27738, 'author_profile': 'https://Stackoverflow.com/users/27738', 'pm_score': 1, 'selected': False, 'text': '<p>I didn\'t see this questions when asked, but a blog post I did might help as well. In it I cover a bunch of Ruby tools and specifically cover 4 code quality tools...</p>\n\n<ol>\n<li>Roodi</li>\n<li>Dust</li>\n<li>Flog</li>\n<li>Saikuro</li>\n</ol>\n\n<p>It might also be worth checking out Towelie and Flay</p>\n\n<p><a href="http://devver.wordpress.com/2008/10/03/ruby-tools-roundup/" rel="nofollow noreferrer">http://devver.wordpress.com/2008/10/03/ruby-tools-roundup/</a></p>\n\n<p>Now we have combined a lot of tools into an only Ruby code quality and metrics monitoring tool called Caliper. This might fit your needs well. It tracks various quality metrics over the life of a project.</p>\n\n<p><a href="http://getcaliper.com" rel="nofollow noreferrer">Caliper - improve your Ruby code</a> </p>\n'}, {'answer_id': 352815, 'author': 'krusty.ar', 'author_id': 43981, 'author_profile': 'https://Stackoverflow.com/users/43981', 'pm_score': 2, 'selected': False, 'text': '<p>Another nice tool, although in early stages according to the author is reek:</p>\n\n<p><a href="http://reek.rubyforge.org/" rel="nofollow noreferrer">http://reek.rubyforge.org/</a></p>\n\n<p>reek currently includes very naive checks for the following code smells:</p>\n\n<ul>\n<li>Long Method</li>\n<li>Large Class</li>\n<li>Feature Envy</li>\n<li>Uncommunicative Name</li>\n<li>Long Parameter List</li>\n<li>Utility Function</li>\n<li>Nested Iterators</li>\n<li>Control Couple</li>\n<li>Duplication</li>\n<li>List item</li>\n</ul>\n\n<p>Personally I think it still has too much false positives, but just looking at the output in some of my code helped me rethink some decisions about code style and architecture.</p>\n'}, {'answer_id': 4236030, 'author': 'disrvptor', 'author_id': 494307, 'author_profile': 'https://Stackoverflow.com/users/494307', 'pm_score': 0, 'selected': False, 'text': '<p>There is also <a href="https://github.com/simplabs/excellent" rel="nofollow">excellent</a>. I haven\'t tried it yet, but it too looks promising. </p>\n'}, {'answer_id': 12844756, 'author': 'Rich', 'author_id': 8261, 'author_profile': 'https://Stackoverflow.com/users/8261', 'pm_score': 3, 'selected': False, 'text': '<p>Projects I\'ve found and tested recently:</p>\n\n<ul>\n<li><a href="https://github.com/railsbp/rails_best_practices">https://github.com/railsbp/rails_best_practices</a>\n<ul>\n<li>Seems to work, and gives sensible warnings</li>\n</ul></li>\n<li><a href="https://github.com/simplabs/excellent">https://github.com/simplabs/excellent</a>\n<ul>\n<li>Works, but quite a few false positives</li>\n</ul></li>\n<li><a href="https://github.com/troessner/reek">https://github.com/troessner/reek</a>\n<ul>\n<li>I disagree with most of the warnings from this tool, but it works</li>\n</ul></li>\n<li><a href="http://www.cs.umd.edu/projects/PL/druby/">http://www.cs.umd.edu/projects/PL/druby/</a>\n<ul>\n<li>This requires ocaml; I haven\'t tried it, but it looks like it might be good</li>\n</ul></li>\n<li><a href="http://roodi.rubyforge.org/">http://roodi.rubyforge.org/</a>\n<ul>\n<li>does not appear to be Ruby 1.9 compatible</li>\n</ul></li>\n<li><a href="https://github.com/gdb/ruby-static-checker">https://github.com/gdb/ruby-static-checker</a>\n<ul>\n<li>Is broken for me, and only catches name errors, so unit tests should cover that.</li>\n</ul></li>\n<li><a href="https://github.com/michaeledgar/laser">https://github.com/michaeledgar/laser</a>\n<ul>\n<li>Doesn\'t compile for me</li>\n</ul></li>\n</ul>\n'}, {'answer_id': 15515563, 'author': 'Simon Woodside', 'author_id': 102675, 'author_profile': 'https://Stackoverflow.com/users/102675', 'pm_score': 2, 'selected': False, 'text': '<p><a href="https://codeclimate.com/" rel="nofollow">Code Climate</a> is a SaaS tool that integrates through git and automatically "grades" your code. It notifies you via various channels if there a sudden drop in quality. Nice UI as well.</p>\n'}, {'answer_id': 16063567, 'author': 'Bozhidar Batsov', 'author_id': 291550, 'author_profile': 'https://Stackoverflow.com/users/291550', 'pm_score': 3, 'selected': False, 'text': '<p>You might want to try out <a href="https://github.com/bbatsov/rubocop" rel="noreferrer">RuboCop</a>. It is a Ruby code style checker based on the <a href="https://github.com/bbatsov/rubocop" rel="noreferrer">Ruby Style Guide</a>. It\'s maintained pretty actively and it\'s based on standard Ruby tooling (like the <code>ripper</code> library). It works well with Ruby 1.9 and 2.0 and has great Emacs integration. I hope you\'ll find it useful!</p>\n'}]
['https://Stackoverflow.com/questions/55313', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5266/']