Add Rubocop

This commit is contained in:
Trevor Vallender 2024-04-14 11:48:42 +01:00
parent 2158426d88
commit c3dba29b8f
9 changed files with 66 additions and 6 deletions

18
.rubocop.yml Normal file
View File

@ -0,0 +1,18 @@
inherit_gem:
rubocop-rails-omakase: rubocop.yml
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: consistent_comma
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma
Layout/IndentationConsistency:
Enabled: true
Layout/IndentationWidth:
Enabled: true

View File

@ -20,6 +20,7 @@ group :development, :test do
end
group :development do
gem "rubocop-rails-omakase"
gem "web-console"
end

View File

@ -77,6 +77,7 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
bigdecimal (3.1.7)
@ -117,6 +118,8 @@ GEM
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
@ -153,6 +156,10 @@ GEM
racc (~> 1.4)
nokogiri (1.16.4-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pg (1.5.6)
psych (5.1.2)
stringio
@ -197,6 +204,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rdoc (6.6.3.1)
psych (>= 4.0.0)
@ -204,6 +212,36 @@ GEM
reline (0.5.1)
io-console (~> 0.5)
rexml (3.2.6)
rubocop (1.63.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-minitest (0.35.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.24.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails-omakase (1.0.0)
rubocop
rubocop-minitest
rubocop-performance
rubocop-rails
ruby-progressbar (1.13.0)
rubyzip (2.3.2)
selenium-webdriver (4.19.0)
base64 (~> 0.2)
@ -228,6 +266,7 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
@ -260,6 +299,7 @@ DEPENDENCIES
pg
puma (>= 5.0)
rails (~> 7.1.3, >= 7.1.3.2)
rubocop-rails-omakase
selenium-webdriver
sprockets-rails
stimulus-rails

View File

@ -14,7 +14,8 @@ class User < ApplicationRecord
uniqueness: true,
length: { minimum: 5, maximum: 100 },
format: { with: URI::MailTo::EMAIL_REGEXP,
message: "must be a valid email address" }
message: "must be a valid email address",
}
normalizes :email, with: ->(email) { email.strip.downcase }
validates :first_name,
presence: true,

View File

@ -14,7 +14,7 @@ module Forg
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w(assets tasks))
config.autoload_lib(ignore: %w[assets tasks])
# Configuration for the application, engines, and railties goes here.
#

View File

@ -25,7 +25,7 @@ Rails.application.configure do
config.cache_store = :memory_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
"Cache-Control" => "public, max-age=#{2.days.to_i}",
}
else
config.action_controller.perform_caching = false

View File

@ -20,7 +20,7 @@ Rails.application.configure do
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
"Cache-Control" => "public, max-age=#{1.hour.to_i}",
}
# Show full error reports and disable caching.

View File

@ -4,5 +4,5 @@
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn,
]

View File

@ -1,5 +1,5 @@
require "test_helper"
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
driven_by :selenium, using: :chrome, screen_size: [ 1400, 1400 ]
end