[Rails 6] Rubocop warning list

Introduction

Creating a portfolio for job change activities. With the introduction of CircleCi this time, Rubocop will perform style checking of the code at the time of push, and I would like to summarize the errors pointed out there.

environment

Ruby on Rails '6.0.0' Ruby '2.6.5'

①Layout/ExtraSpacing: Unnecessary spacing detected.

Unnecessary space was confirmed

app/models/company.rb


validates_format_of :password, on: :create,  with: PASSWORD_REGEX, message: 'Please include both letters and numbers in'

It's a little confusing this time, but it seems that a warning was issued because there was an extra space for one character between "on :: create" and "with: ~".

②Layout/EmptyLineBetweenDefs: Use empty lines between method definitions.

Checking if the method definition statement is separated by a single empty line.

def a
end
def b
end

It seems that it occurred because there was no space between "def a" and "def b".

③Layout/TrailingWhitespace: Trailing whitespace detected.

A warning was issued because there was an extra space at the end of the relevant part.

At the end

bundle exec rubocop -a

If you use the above command, it seems that it will be corrected without permission, I posted it because I wanted to find out the meaning for some reason. If you feel like it, I will post a new warning message. .. .. ..

Recommended Posts

[Rails 6] Rubocop warning list
[Note] Rails error list
[Rails] List instances of multiple models
[Rails] Introduction of Rubocop by beginners
[rails] List of actions defined in Controller
[Rails] warning: constant Gem :: ConfigMap is deprecated
[Rails] Gem Rubocop Static code analysis tool