What’s Mining: New Ruby Inspections for Better Code
Writing a code that smells isn’t as terrible as it seems to be. But leaving an ugly code without changing it is much worse. Refactoring is one of the bases of development, and Ruby development is not an exception. RubyMine has a very powerful tool that can help a lot with making your code smell good. I’m talking about ‘Code Inspection’ mechanism. We are tuning it all the time and now it’s time for some Ruby code inspection improvements.
The list of ‘bad code’ metrics for Ruby code inspection is based on Ruby style guide and such tools as Roodi, Reek, Saikuro, Flog, Flay e.t.c. Today I’ll show you some examples how different code checks are performed by RubyMine. Lets take a look at some new code inspections coming in RubyMine 4.
Empty rescue block
This check goes from Roodi and allows to find all rescue blocks without any content. You can decide whether to consider comments as a content and also whether to ignore empty catch blocks when the parameter is named ‘_’. The warning is shown directly in a code that can be rewritten immediately with a help of intention actions.
‘Then’ identifier in multi-line if/unless block
According to Syntax section of the Ruby style guide, you should never use ‘then’ for multi-line if/unless blocks. RubyMine reminds you about it.
If you’re a newcomer to Ruby or develop with many different languages you might not remember all naming conventions by heart. And it can be really annoying to look after all the names in your code. RubyMine follows Naming section of the style guide by default for Ruby code, but you also can set your own pattern and length as a convention for names.
The list of inspection results is also shown at the ‘Code Inspection’ panel.
The full list of checks with short descriptions is placed in the IDE Settings | Inspections section where every check can switched on or off or configured.
Check out the full list of Ruby code inspection checks available in RubyMine.
Subscribe to Blog updates
Thanks, we've got you!
RubyMine 2023.3 EAP Update
Hello everyone! We’re back with an update on the state of the 2023.3 Early Access Program. You can download the latest EAP build from our website, via the free Toolbox App, or by using snaps for Ubuntu. Here are the biggest highlights of this release: Performance improvements As we me…
The RubyMine 2023.3 Early Access Program Is Open!
Hello everyone, The third RubyMine Early Access Program of 2023 is underway! The key change in the first EAP build is an important indexing optimization. By refactoring our code base, we’ve doubled RubyMine’s indexing speed compared to v2023.1. This is particularly noticeable when working…
Performance Improvements in RubyMine 2023.1
Hello everybody, The new release is fast approaching, so it’s time to unveil the performance enhancements you can expect from RubyMine 2023.1. Faster code completion When developing and supporting RubyMine, we analyze a great load of anonymized usage data. A lot of recent data pointed to the fact t…
RubyMine 2023.1 EAP5 Is Out!
Hello everyone, RubyMine 2023.1 EAP5 is now available! Below you can find the most notable features in this build. We encourage you to try them out and share your feedback in the comments or in our issue tracker. Migration of Ruby code to the Symbol API In order to improve code insight actions such…