What’s your name son? – Murph..ahem RuboCop 0.80

What’s your name son? – Murph..ahem RuboCop 0.80

RuboCop, a static code analyser and code formatter for the Ruby programming language, is now available in version 0.80, which fixes some issues and adds a new formatter to make it easier to integrate into complex workflows.

Amongst the features that made its way into the release is a new JUnit formatter, so that RuboCop can be used in concert with continuous integration services or IDEs that are only able to parse certain kinds of output. The project that took care of that earlier was deprecated, which made the addition necessary.

RuboCop 0.8 also comes with a configuration allowing the use of #ruby in comments, since this can be necessary when writing gemfiles for a number of tools. Other new additions include a “BracesRequiredMethods parameter to Style/BlockDelimiters to require braces for specific methods” and a mechanism to break up long lines.

Meanwhile NodePattern has been extended to allow searching for descendants by using ‘ while Steepfile is a new default entry in the project’s Include list.

A couple of new checks, or cops as the RuboCop team likes to call them, can also be found in v0.80. For one, the tool can now ensure that the code it analyses uses Hash#transform_keys and Hash#transform_values to transform a Hash’s keys or values. The methods were introduced to Ruby in v2.5 and should help with readability and execution speed. Another cop helps to reinforce style guide recommendations around hash-each.

Upgrading to the new version should be pretty straightforward – the project now even supports autocorrect for legacy cop names during migration. However, since curly brackets are now used to explicitly pass Hash objects in Ruby, Style/BracesAroundHashParameters cop has been removed, which could lead to breakage.

Ruby is a general-purpose programming language with a focus on simplicity and productivity, which made its public debut in 1995. Well-known users include Airbnb and GitHub.