Skip to content

Commit 411a287

Browse files
committed
add rubocop
1 parent 5e8a09d commit 411a287

File tree

8 files changed

+106
-3
lines changed

8 files changed

+106
-3
lines changed

.rubocop.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
inherit_mode:
2+
merge:
3+
- Exclude
4+
5+
require:
6+
- standard
7+
- standard-custom
8+
- standard-performance
9+
- rubocop-performance
10+
- rubocop-rails
11+
12+
inherit_gem:
13+
# standard: config/base.yml
14+
standard: config/ruby-3.3.yml
15+
standard-performance: config/base.yml
16+
standard-custom: config/base.yml
17+
standard-rails: config/base.yml
18+
19+
inherit_from:
20+
- .rubocop/minitest.yml
21+
# - .rubocop/custom.yml
22+
# - .rubocop_todo.yml
23+
- .rubocop/strict.yml
24+
25+
AllCops:
26+
NewCops: disable
27+
SuggestExtensions: false
28+
TargetRubyVersion: 3.3

.rubocop/custom.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require:
2+
# Cops source code lives in the lib/ folder
3+
# this isn't working
4+
- ./lib/rubocop/cops
5+
6+
Lint/Env:
7+
Enabled: true
8+
Include:
9+
- "**/*.rb"
10+
Exclude:
11+
- "**/config/environments/**/*"
12+
- "**/config/application.rb"
13+
- "**/config/environment.rb"
14+
- "**/config/puma.rb"
15+
- "**/config/boot.rb"
16+
- "**/spec/*_helper.rb"
17+
- "**/spec/**/support/**/*"
18+
- "lib/generators/**/*"

.rubocop/minitest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require:
2+
- rubocop-minitest

.rubocop/strict.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Lint/Debugger: # don't leave binding.pry or debugger
2+
Enabled: true
3+
Exclude: []
4+
5+
RSpec/Focus: # run ALL tests on CI
6+
Enabled: true
7+
Exclude: []
8+
9+
Rails/Output: # Don't leave puts-debugging
10+
Enabled: true
11+
Exclude: []
12+
13+
Rails/FindEach: # each could severely affect the performance, use find_each
14+
Enabled: true
15+
Exclude: []
16+
17+
Rails/UniqBeforePluck: # uniq.pluck and not pluck.uniq
18+
Enabled: true
19+
Exclude: []

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ group :development, :test do
5555
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
5656
gem "debug", platforms: %i[ mri windows ]
5757
gem "dotenv", "~> 3.1"
58+
59+
gem "rubocop"
60+
gem "rubocop-minitest"
61+
gem "standard", "~> 1.39", require: false
62+
gem "standard-rails"
5863
end
5964

6065
group :development do

Gemfile.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ GEM
243243
unicode-display_width (>= 2.4.0, < 3.0)
244244
rubocop-ast (1.31.3)
245245
parser (>= 3.3.1.0)
246+
rubocop-minitest (0.35.0)
247+
rubocop (>= 1.61, < 2.0)
248+
rubocop-ast (>= 1.31.1, < 2.0)
246249
rubocop-performance (1.21.1)
247250
rubocop (>= 1.48.1, < 2.0)
248251
rubocop-ast (>= 1.31.1, < 2.0)
@@ -334,6 +337,8 @@ DEPENDENCIES
334337
puma (>= 5.0)
335338
rails (~> 7.1.3, >= 7.1.3.4)
336339
redis (>= 4.0.1)
340+
rubocop
341+
rubocop-minitest
337342
selenium-webdriver
338343
simple_form (~> 5.3)
339344
sprockets-rails

bin/rubocop

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rubocop' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12+
13+
bundle_binstub = File.expand_path("bundle", __dir__)
14+
15+
if File.file?(bundle_binstub)
16+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17+
load(bundle_binstub)
18+
else
19+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21+
end
22+
end
23+
24+
require "rubygems"
25+
require "bundler/setup"
26+
27+
load Gem.bin_path("rubocop", "rubocop")

db/migrate/20240705015924_devise_create_users.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class DeviseCreateUsers < ActiveRecord::Migration[7.1]
44
def change
55
create_table :users do |t|
66
## Database authenticatable
7-
t.string :email, null: false, default: ""
7+
t.string :email, null: false, default: ""
88
t.string :encrypted_password, null: false, default: ""
99

1010
## Recoverable
@@ -32,11 +32,10 @@ def change
3232
# t.string :unlock_token # Only if unlock strategy is :email or :both
3333
# t.datetime :locked_at
3434

35-
3635
t.timestamps null: false
3736
end
3837

39-
add_index :users, :email, unique: true
38+
add_index :users, :email, unique: true
4039
# add_index :users, :reset_password_token, unique: true
4140
# add_index :users, :confirmation_token, unique: true
4241
# add_index :users, :unlock_token, unique: true

0 commit comments

Comments
 (0)