From c3dba29b8fa6dfa92c7b438cb94ed930b3ea2b84 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Sun, 14 Apr 2024 11:48:42 +0100 Subject: [PATCH] Add Rubocop --- .rubocop.yml | 18 +++++++++ Gemfile | 1 + Gemfile.lock | 40 +++++++++++++++++++ app/models/user.rb | 3 +- config/application.rb | 2 +- config/environments/development.rb | 2 +- config/environments/test.rb | 2 +- .../initializers/filter_parameter_logging.rb | 2 +- test/application_system_test_case.rb | 2 +- 9 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..8a921fd --- /dev/null +++ b/.rubocop.yml @@ -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 + diff --git a/Gemfile b/Gemfile index 219ea31..9f66c4a 100644 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,7 @@ group :development, :test do end group :development do + gem "rubocop-rails-omakase" gem "web-console" end diff --git a/Gemfile.lock b/Gemfile.lock index 457965a..59cdd87 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 910f458..2e96f49 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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, diff --git a/config/application.rb b/config/application.rb index b85621c..ea6f6f8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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. # diff --git a/config/environments/development.rb b/config/environments/development.rb index 2e7fb48..b40633f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 diff --git a/config/environments/test.rb b/config/environments/test.rb index adbb4a6..64be917 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -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. diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index c2d89e2..8fd698f 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -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, ] diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d19212a..d7e6bba 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -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