Ruby on Rails Code Quality

In this article, we will point out steps on what can you do in order to improve your code quality in Ruby on Rails apps that you are building.

Follow up Ruby style guide

Yes, let’s start with the basics. You can read community-driven Ruby style guide at https://github.com/bbatsov/ruby-style-guide.

Follow up Rails style guide

You might have guessed, next step is to read community driver Rails style guide. There are more than few tips which can make you improve the speed of your apps, and to make them smarter. https://github.com/bbatsov/rails-style-guide

Rubocop

In order to successfully follow Ruby styleguide, you can install a Rubocop gem, which can be run automatically. It will output all variations of Ruby code. Instructions on how to use it: https://github.com/bbatsov/rubocop.

If using Atom editor – you might try https://github.com/yujinakayama/atom-lint. It warns user inside the editor.

Rubycritics

This is a Rails gem, that can check all your code and point out code smells where you might think it doesn’t exist.

https://github.com/whitesmith/rubycritic

Rails best practices

There is a gem, that doesn’t just point out the code smell, but it also suggests a way how it should be written instead. Install the gem, and run it against your code.

https://github.com/railsbp/rails_bestpractices

How you should start improving your code

Here are some steps that can help you improve code:

  • First, read the documentation, and install all the gems.
  • Run each gem on your code that you are most familiar with.
  • Look through the results.
  • For each part that you learned something new, document it. Write a single sentence – for yourself on what you should do in similar situation. e.g. Don’t name variables with a single letter, or don’t make methods with ! at end – only in specific cases.
  • Share your findings.
  • Next time around, try to apply all learned lessons. If you don’t remember everything, check your document that you wrote for yourself.
  • It’s not competition, it’s a way to improve ourselves.

Ruby programming beginners guide

We are writing this brief tutorial on how to easily get into Ruby programming language and Ruby on Rails frame.