diff --git a/README.md b/README.md index aa2f1e4..ee7c3f7 100644 --- a/README.md +++ b/README.md @@ -266,12 +266,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 @@ -282,6 +294,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 b1dae4b..bc13bb7 100644 --- a/config_files/.rubocop.yml +++ b/config_files/.rubocop.yml @@ -1,6 +1,9 @@ -require: 'rubocop-rails' +# Enabling Rails-specific cops +require: rubocop-rails AllCops: + + # Excluding most directories with generated files and directories with configuration files Exclude: - 'vendor/**/*' - 'db/*' @@ -20,9 +23,7 @@ AllCops: - 'spec/spec_helper.rb' - 'node_modules/**/*' -Rails: - Enabled: true - +# Instructing rubocop about all non-standard environments Rails/UnknownEnv: Environments: - production @@ -31,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/*' @@ -55,7 +56,7 @@ Style/SymbolArray: Enabled: true # Most readable form. -Layout/AlignHash: +Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table @@ -71,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: @@ -104,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: @@ -212,3 +217,7 @@ Style/PercentLiteralDelimiters: Rails/Output: Exclude: - 'config/deploy.rb' + +# It brings pain for no real benefits +Metrics/ModuleLength: + Enabled: false