CALL US ⁄ ⁄   +61 3 9995 0765



What is RUBOCOP gem?
Rubocop is a tool to check the code style based on ruby-style-guide, built to serve the developers. Rubocop uses predefined rules to compare them with your code and show the error messages. Rubocop is used in projects to help us save time for the review and ensure code coding convention, to make sure there are no error basic convention. Today, Texo Design - best web design digital agency will share you this topic “What is RUBOCOP gem?”

1. Setup rubocop
Option 1: Add Gemfile and bundle install


Option 2: Can be run directly on the terminal


2. Basic usage


Example result:


With this announcement you will easily detect and fix errors immediately.

3. Cops Documentation
In RuboCop lingo the various checks performed on the code are called cops. There are several cop departments. Cops includes Linting Cops, Metrics Cops, Performance Cops, Rails Cops, Security Cops, Style Cops and Bundler Cops.

Example for Linting Cops & Rails Cops
rubocop -l
rubocop -R

4. Formatters
You can change the output format of RuboCop by specifying formatters with the -f/–format option. RuboCop ships with several built-in formatters, and also you can create your custom formatter.

5. Configuration
The behaviour of RuboCop can be controlled via the .rubocop.yml configuration file. It makes it possible to enable/disable certain cops (checks) and to alter their behavior if they accept any parameters. The file can be placed either in your home directory or in some project directory.

RuboCop will start looking for the configuration file in the directory where the inspected file is and continue its way up to the root directory.

6. Caching
Large projects containing hundreds or even thousands of files can take a really long time to inspect, but RuboCop has functionality to mitigate this problem. There’s a caching mechanism that stores information about offenses found in inspected files.

7. Editor Integration
rubocop.el is a simple Emacs interface for RuboCop. It allows you to run RuboCop inside Emacs and quickly jump between problems in your code.

flycheck > 0.9 also supports RuboCop and uses it by default when available.

The vim-rubocop plugin runs RuboCop and displays the results in Vim.
There’s also a RuboCop checker in syntastic, neomake and ale.

Sublime Text
If you’re a ST user you might find the Sublime RuboCop plugin useful.

The brackets-rubocop extension displays RuboCop results in Brackets. It can be installed via the extension manager in Brackets.

The textmate2-rubocop bundle displays formatted RuboCop results in a new window. Installation instructions can be found here.

The linter-rubocop plugin for Atom’s linter runs RuboCop and highlights the offenses in Atom.

The lt-rubocop plugin provides LightTable integration.

The rubocop-for-rubymine plugin provides basic RuboCop integration for RubyMine/IntelliJ IDEA.

Texo Design is one of the renowned names in professional web design melbourne. We are the team of well – qualified and experienced staff as we deal with mobile apps, web development and social media campaign. We offer you the best tailor-made solution. Your success is our guarantee as we commit quality, professionalism and communication to our clients. These three pillars will help you in making your formal decision. We transform your ideas into reality with highly innovative technologies and experts mindset. Contact us +61 3 9995 0765 or for more information


Be the first to post on the blog

Leave a Reply


Back to blog