From c9a4d88558f8b4168ade1cabed9f9a978e42ad6c Mon Sep 17 00:00:00 2001 From: Matthieu Ciappara Date: Mon, 10 Feb 2020 17:19:50 +0100 Subject: [PATCH] Replace rubocop to comply with latest version of the gem - Current versions of: - rubocop: 0.79.0 - rubocop-rails: 2.4.2 --- README.md | 15 ++++++++++++++- config_files/rubocop.yml | 23 +++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a74b862..bed653b 100644 --- a/README.md +++ b/README.md @@ -262,12 +262,24 @@ Default whitelist is: Best solution would be integrating check script to dev pipeline's CI/CD. +# Rubocop + +Rubocop is a linter for ruby. It can be extended for Ruby on Rails using the gem rubocop-rails. Add the following lines in your Gemfile to begin using Rubocop. + +```ruby +group :development do + gem 'rubocop', '~> 0.79.0' + gem 'rubocop-rails', '~> 2.4', '>= 2.4.2' +end +``` + +A configuration file compliant with those versions can be found in the `config_files` directory. + # To-dos List here all the section and stuff you would like or wish someone could to talk about in a next PR * moduloTech gem -* Rubocop and rubocop-rails * CI/CD * use [Licensed](https://github.com/github/licensed) script to check new/updated dependencies' licenses * use rubocop as part of CI pipeline @@ -279,6 +291,7 @@ List here all the section and stuff you would like or wish someone could to talk # Changes * ... +* ciappa_m - Add section about Rubocop * philib_j - Added information about r.sh * varaby_m - Add section about dependencies' licenses * ciappa_m - Add a section about commit messages diff --git a/config_files/rubocop.yml b/config_files/rubocop.yml index 0aec381..bc13bb7 100644 --- a/config_files/rubocop.yml +++ b/config_files/rubocop.yml @@ -1,4 +1,9 @@ +# Enabling Rails-specific cops +require: rubocop-rails + AllCops: + + # Excluding most directories with generated files and directories with configuration files Exclude: - 'vendor/**/*' - 'db/*' @@ -18,9 +23,7 @@ AllCops: - 'spec/spec_helper.rb' - 'node_modules/**/*' -Rails: - Enabled: true - +# Instructing rubocop about all non-standard environments Rails/UnknownEnv: Environments: - production @@ -29,7 +32,7 @@ Rails/UnknownEnv: - staging # Commonly used screens these days easily fit more than 80 characters. -Metrics/LineLength: +Layout/LineLength: Max: 100 Exclude: - 'config/*' @@ -53,7 +56,7 @@ Style/SymbolArray: Enabled: true # Most readable form. -Layout/AlignHash: +Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table @@ -69,6 +72,10 @@ Style/PreferredHashMethods: Style/FormatString: EnforcedStyle: percent +# Annotated or template are too verbose and rarely needed. +Style/FormatStringToken: + EnforcedStyle: unannotated + Style/CollectionMethods: Enabled: true PreferredMethods: @@ -102,7 +109,7 @@ Style/SignalException: # Suppressing exceptions can be perfectly fine, and be it to avoid to # explicitly type nil into the rescue since that's what you want to return, # or suppressing LoadError for optional dependencies -Lint/HandleExceptions: +Lint/SuppressedException: Enabled: false # { ... } for multi-line blocks is okay, follow Weirichs rule instead: @@ -210,3 +217,7 @@ Style/PercentLiteralDelimiters: Rails/Output: Exclude: - 'config/deploy.rb' + +# It brings pain for no real benefits +Metrics/ModuleLength: + Enabled: false