The latest and greatest additions to Reek

2015 has been an awesome year for Reek. With the release of Reek 3 we reached a level where I’d call Reek a stable, mature and - if used right - an incredibly useful library.

We have been quite busy since the Reek 3 release - here are my favourite features we have added to Reek since then:

 Unused private methods

Reek now detects unused private methods and warns you.
Code like this:

class Car
  def start


  def hyper_drive; end

would cause Reek to emit:

1 warning:
  [8]:UnusedPrivateMethod: Car has the unused private instance method `hyper_drive` []

Right now this smell detector can only recognise unused private instance methods - we plan to expand it to class methods as well in the future.

 Deactivate UtilityFunction for private methods

Quite some users complained about the UtilityFunction detector and I believe they rightfully did so.

In its old version it would warn on every method in question which was conflicting with a lot of users writing small, private methods for readability reasons. We added a configuration option so that you can now disable this smell detector for private methods like this:

  public_methods_only: true

 Making NestedIterators smell smarter

Conceptually, every method in Ruby that takes a block is called an iterator.
However it’s idiomatic Ruby to use blocks for a lot of different things and most of them have nothing to with “iterating” over anything.

For instance it’s quite common to have before and <after hooks in the test framework of your choice like this:

before do
  my_collection.each do |item|
    # do something with `item``

As a consequence, Reek would warn you about NestedIterators which really makes no sense whatsoever in this case.

We improved NestedIterators sensitivity so that it won’t count iterators without block arguments.

 Improved error messages

Unfortunately Reek never was the user friendliest library when it came to error messages.

Especially the warnings for complex smells like FeatureEnvy were not really helpful:

FeatureEnvy: "refers to `foobar` more than self"

After quite some back and forth we finally converged on far more helpful error message. For instance, the new and improved error message for FeatureEnvy is now:

FeatureEnvy: RedCloth#blocks refers to blk more than self (maybe move it to another class?)

Far more expressive and it includes a helpful link by default you just have to click to read up on what FeatureEnvy means and how you might be able to fix it.

 What’s next?


Now read this

The Rockstar-Ninja-Coder and you. A layman’s guide how to not hire them

Image source I have been doing tech recruiting for start-ups over the last 10 years and oh boy, did I fuck up a lot. On the plus side of things, I did also learn a lot about human behaviour, hiring bias and common misconceptions about... Continue →