Skip to content

Commit b9cf8c5

Browse files
Set up Rubocop
1 parent e16323c commit b9cf8c5

File tree

15 files changed

+79
-43
lines changed

15 files changed

+79
-43
lines changed

.rubocop.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Omakase Ruby styling for Rails
2+
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
3+
4+
# Overwrite or add rules to create your own house style
5+
#
6+
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
7+
# Layout/SpaceInsideArrayLiteralBrackets:
8+
# Enabled: false

Gemfile.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ GEM
175175
parser (3.3.3.0)
176176
ast (~> 2.4.1)
177177
racc
178-
pg (1.5.6)
179178
propshaft (0.9.0)
180179
actionpack (>= 7.0.0)
181180
activesupport (>= 7.0.0)
@@ -302,7 +301,6 @@ DEPENDENCIES
302301
bootsnap
303302
capybara
304303
importmap-rails
305-
pg (~> 1.1)
306304
propshaft
307305
puma (>= 5.0)
308306
rails!

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Add your own tasks in files placed in lib/tasks ending in .rake,
22
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
33

4-
require_relative "config/application"
4+
require_relative 'config/application'
55

66
Rails.application.load_tasks

bin/bundle

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# this file is here to facilitate running it.
99
#
1010

11-
require "rubygems"
11+
require 'rubygems'
1212

1313
m = Module.new do
1414
module_function
@@ -18,45 +18,47 @@ m = Module.new do
1818
end
1919

2020
def env_var_version
21-
ENV["BUNDLER_VERSION"]
21+
ENV['BUNDLER_VERSION']
2222
end
2323

2424
def cli_arg_version
2525
return unless invoked_as_script? # don't want to hijack other binstubs
26-
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
26+
return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update`
27+
2728
bundler_version = nil
2829
update_index = nil
2930
ARGV.each_with_index do |a, i|
30-
if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
31-
bundler_version = a
32-
end
31+
bundler_version = a if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
3332
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34-
bundler_version = $1
33+
34+
bundler_version = Regexp.last_match(1)
3535
update_index = i
3636
end
3737
bundler_version
3838
end
3939

4040
def gemfile
41-
gemfile = ENV["BUNDLE_GEMFILE"]
41+
gemfile = ENV['BUNDLE_GEMFILE']
4242
return gemfile if gemfile && !gemfile.empty?
4343

44-
File.expand_path("../Gemfile", __dir__)
44+
File.expand_path('../Gemfile', __dir__)
4545
end
4646

4747
def lockfile
4848
lockfile =
4949
case File.basename(gemfile)
50-
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
50+
when 'gems.rb' then gemfile.sub(/\.rb$/, '.locked')
5151
else "#{gemfile}.lock"
5252
end
5353
File.expand_path(lockfile)
5454
end
5555

5656
def lockfile_version
5757
return unless File.file?(lockfile)
58+
5859
lockfile_contents = File.read(lockfile)
5960
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
61+
6062
Regexp.last_match(1)
6163
end
6264

@@ -76,20 +78,24 @@ m = Module.new do
7678
end
7779

7880
def load_bundler!
79-
ENV["BUNDLE_GEMFILE"] ||= gemfile
81+
ENV['BUNDLE_GEMFILE'] ||= gemfile
8082

8183
activate_bundler
8284
end
8385

8486
def activate_bundler
8587
gem_error = activation_error_handling do
86-
gem "bundler", bundler_requirement
88+
gem 'bundler', bundler_requirement
8789
end
8890
return if gem_error.nil?
91+
8992
require_error = activation_error_handling do
90-
require "bundler/version"
93+
require 'bundler/version'
94+
end
95+
if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
96+
return
9197
end
92-
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98+
9399
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
94100
exit 42
95101
end
@@ -104,6 +110,4 @@ end
104110

105111
m.load_bundler!
106112

107-
if m.invoked_as_script?
108-
load Gem.bin_path("bundler", "bundle")
109-
end
113+
load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script?

bin/importmap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
22

3-
require_relative "../config/application"
4-
require "importmap/commands"
3+
require_relative '../config/application'
4+
require 'importmap/commands'

bin/rails

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
2-
APP_PATH = File.expand_path("../config/application", __dir__)
3-
require_relative "../config/boot"
4-
require "rails/commands"
2+
APP_PATH = File.expand_path('../config/application', __dir__)
3+
require_relative '../config/boot'
4+
require 'rails/commands'

bin/rake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
2-
require_relative "../config/boot"
3-
require "rake"
2+
require_relative '../config/boot'
3+
require 'rake'
44
Rake.application.run

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')

bin/setup

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env ruby
2-
require "fileutils"
2+
require 'fileutils'
33

44
# path to your application root.
5-
APP_ROOT = File.expand_path("..", __dir__)
5+
APP_ROOT = File.expand_path('..', __dir__)
66

77
def system!(*args)
88
system(*args, exception: true)
@@ -13,21 +13,21 @@ FileUtils.chdir APP_ROOT do
1313
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
1414
# Add necessary setup steps to this file.
1515

16-
puts "== Installing dependencies =="
17-
system! "gem install bundler --conservative"
18-
system("bundle check") || system!("bundle install")
16+
puts '== Installing dependencies =='
17+
system! 'gem install bundler --conservative'
18+
system('bundle check') || system!('bundle install')
1919

2020
# puts "\n== Copying sample files =="
2121
# unless File.exist?("config/database.yml")
2222
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
2323
# end
2424

2525
puts "\n== Preparing database =="
26-
system! "bin/rails db:prepare"
26+
system! 'bin/rails db:prepare'
2727

2828
puts "\n== Removing old logs and tempfiles =="
29-
system! "bin/rails log:clear tmp:clear"
29+
system! 'bin/rails log:clear tmp:clear'
3030

3131
puts "\n== Restarting application server =="
32-
system! "bin/rails restart"
32+
system! 'bin/rails restart'
3333
end

config.ru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is used by Rack-based servers to start the application.
22

3-
require_relative "config/environment"
3+
require_relative 'config/environment'
44

55
run Rails.application
66
Rails.application.load_server

0 commit comments

Comments
 (0)