How To Install rubocop on Ubuntu 18.04

In this tutorial we learn how to install rubocop on Ubuntu 18.04. rubocop is Ruby static code analyzer

Introduction

In this tutorial we learn how to install rubocop on Ubuntu 18.04.

What is rubocop

rubocop is:

rubocop is a static code analyzer for Ruby, out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide.

Most aspects of its behavior can be tweaked via various configuration options.

Apart from reporting problems in your code, RuboCop can also automatically fix some of the problems for you.

There are three methods to install rubocop on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install rubocop Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install rubocop using apt-get by running the following command:

sudo apt-get -y install rubocop

Install rubocop Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install rubocop using apt by running the following command:

sudo apt -y install rubocop

Install rubocop Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install rubocop using aptitude by running the following command:

sudo aptitude -y install rubocop

How To Uninstall rubocop on Ubuntu 18.04

To uninstall only the rubocop package we can use the following command:

sudo apt-get remove rubocop

Uninstall rubocop And Its Dependencies

To uninstall rubocop and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove rubocop

Remove rubocop Configurations and Data

To remove rubocop configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge rubocop

Remove rubocop configuration, data, and all of its dependencies

We can use the following command to remove rubocop configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge rubocop

References

Summary

In this tutorial we learn how to install rubocop package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.