3 Ruby Gems to Code Analysis

3 Ruby Gems to Code Analysis

Allan Porras
Allan Porras Jun 27 2017 • 2 min read
Share:
By using Rails We can explore an endless of tools that We can use a more efficient and quick code. Also, We can find tools that allow us to review our implementation. 
There is a lot to be listed and ready to go, but We want to show you which ones are vital for Us here in 4Geeks.

1. Rubycritic

This gem generates a full report about the current quality of our code, by using different gems of analysis like ReekFlog y Flay.

Installation

gem 'rubycritic', require: false

Execution

$ rubycritic
This will generate a HTMl document where We can find the state of our code and also be able to analyse all the smells returned. Here, in 4Geeks this gem is used often to check and confirm that the code written is using the Rails standards and quality. 

2. Rubocop

Rubocop is a gem very interesting, which is a static code analysis, totally based on the ruby style guide, who is the one that provides all the standards that ruby demands. This gem will show to us a detailed report  with all the rule violations that we have in our code, for example: useless variables, methods and arguments or redundant use of ruby methods. 

This gem allow us to check in different formats all the results. Starting by checking the code directly in the console, in a JSON file or a HTML document. Here in 4Geeks we enjoy using HTML format that way we can show in a good visual form to the clients or partners all the results of the analysis.

Also Rubocop, bring to us a configuration set, that way We can be able to modify some alerts if We think It’s not necessary to follow some ruby style guide rule, so, our teams follow their own rules in that scenario.

We highly recommend to run this gem before send you code to review, so, you can confirm that everything you wrote is under the standards of your team and ruby. 

Instalation

gem 'rubocop', require: false

Execution (recommended)

$ rubocop --format html -o rubocop.html

3. Brakeman

This gem is very important, because it show us a complete analysis of possible failures in our code security. It shows the results by classifying them by level: High, Medium, Low. Thanks to that we can decide where to check first. We have to take in consideration that by fixing this stuff won’t assure total security, but it will very helpful to determine certain errors.  

Installation

gem 'brakeman', require: false

Execution (recommended)

$ brakeman -o output.html

Conclusion

We went through the most known gems in code analysis, as we saw, We can use them to reduce code smells and increase code security. Now, We have to explore other options We can not delimited our selves and our projects to use only those tools, there are a lot of options around internet and also, We can think about build one, why not ? 

Request follow-up 🤙

About 4Geeks

Founded in 2012, 4Geeks is a global software engineering and revenue growth consulting firm for Fortune 500, Global 2000 and fast-growing SMBs. Provides top solutions to multiple industries including Retail, Healthcare, Banking & Financial Services, B2B SaaS, Manufacturing and Education. HQ in the USA, and delivery centers across Latin America.

Weekly Business Newsletter

Actionable Growth Hacks

Receive relevant news, advice, trends in your industry and invitations to exclusive events, direct to your inbox every week.