Skip to content

Commit 1f16575

Browse files
committed
Switch to StandardRB rubocop linter
1 parent 9223604 commit 1f16575

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+376
-214
lines changed

.rubocop.yml

+44-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1-
# Omakase Ruby styling for Rails
1+
require:
2+
- rubocop-capybara
3+
- rubocop-minitest
4+
- rubocop-performance
5+
- rubocop-rails
6+
- standard
7+
28
inherit_gem:
3-
rubocop-rails-omakase: rubocop.yml
9+
standard: config/base.yml
10+
11+
AllCops:
12+
SuggestExtensions: false
13+
TargetRubyVersion: 3.3
14+
NewCops: enable
15+
16+
Minitest/MultipleAssertions:
17+
Max: 10 # default 3
18+
19+
Style/FrozenStringLiteralComment:
20+
Enabled: true
21+
22+
# These below cops are good practice going forward, but due to legacy we exclude some migrations
23+
Rails/CreateTableWithTimestamps:
24+
Exclude:
25+
- db/migrate/20181101154531_create_cms.rb
26+
- db/migrate/20220603215833_create_active_storage_variant_records.active_storage.rb
27+
28+
Rails/SkipsModelValidations:
29+
Exclude:
30+
- db/migrate/20220603215832_add_service_name_to_active_storage_blobs.active_storage.rb
31+
32+
Rails/BulkChangeTable:
33+
Exclude:
34+
- db/migrate/20181101154602_create_friendly_id_slugs.rb
35+
- db/migrate/20181101154832_add_slug_to_profiles.rb
36+
37+
Rails/ThreeStateBooleanColumn:
38+
Exclude:
39+
- db/migrate/20181101154627_create_profiles.rb
40+
41+
# Below are cops that are currently disabled, where we should fix in the future
42+
# TODO: Fix ProfilesController so we don't need to use global vars
43+
Style/GlobalVars:
44+
Exclude:
45+
- app/controllers/profiles_controller.rb

Gemfile

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source "https://rubygems.org"
24
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
35

@@ -37,12 +39,18 @@ gem "rdoc", ">= 6.6.3.1"
3739

3840
group :development, :test do
3941
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
40-
gem "byebug", platforms: [ :mri, :mingw, :x64_mingw ]
42+
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
43+
44+
# Linters
45+
gem "rubocop", require: false
46+
gem "rubocop-capybara", require: false
47+
gem "rubocop-minitest", require: false
48+
gem "rubocop-performance", require: false
49+
gem "rubocop-rails", require: false
50+
gem "standard", ">= 1.35.1", require: false
4151
end
4252

4353
group :development do
44-
gem "rubocop-rails-omakase", require: false
45-
4654
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
4755
gem "web-console", ">= 3.3.0"
4856

@@ -58,4 +66,4 @@ group :test do
5866
end
5967

6068
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
61-
gem "tzinfo-data", platforms: [ :mingw, :mswin, :x64_mingw, :jruby ]
69+
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Gemfile.lock

+32-7
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ GEM
159159
kramdown (2.4.0)
160160
rexml
161161
language_server-protocol (3.17.0.3)
162+
lint_roller (1.1.0)
162163
listen (3.9.0)
163164
rb-fsevent (~> 0.10, >= 0.10.3)
164165
rb-inotify (~> 0.9, >= 0.9.10)
@@ -191,8 +192,18 @@ GEM
191192
net-smtp (0.5.0)
192193
net-protocol
193194
nio4r (2.7.3)
195+
nokogiri (1.16.5-aarch64-linux)
196+
racc (~> 1.4)
197+
nokogiri (1.16.5-arm-linux)
198+
racc (~> 1.4)
199+
nokogiri (1.16.5-arm64-darwin)
200+
racc (~> 1.4)
201+
nokogiri (1.16.5-x86-linux)
202+
racc (~> 1.4)
194203
nokogiri (1.16.5-x86_64-darwin)
195204
racc (~> 1.4)
205+
nokogiri (1.16.5-x86_64-linux)
206+
racc (~> 1.4)
196207
parallel (1.24.0)
197208
parser (3.3.1.0)
198209
ast (~> 2.4.1)
@@ -258,7 +269,7 @@ GEM
258269
rexml (3.2.8)
259270
strscan (>= 3.0.9)
260271
rollbar (3.5.2)
261-
rubocop (1.64.0)
272+
rubocop (1.63.5)
262273
json (~> 2.3)
263274
language_server-protocol (>= 3.17.0)
264275
parallel (~> 1.10)
@@ -271,6 +282,8 @@ GEM
271282
unicode-display_width (>= 2.4.0, < 3.0)
272283
rubocop-ast (1.31.3)
273284
parser (>= 3.3.1.0)
285+
rubocop-capybara (2.20.0)
286+
rubocop (~> 1.41)
274287
rubocop-minitest (0.35.0)
275288
rubocop (>= 1.61, < 2.0)
276289
rubocop-ast (>= 1.31.1, < 2.0)
@@ -282,11 +295,6 @@ GEM
282295
rack (>= 1.1)
283296
rubocop (>= 1.33.0, < 2.0)
284297
rubocop-ast (>= 1.31.1, < 2.0)
285-
rubocop-rails-omakase (1.0.0)
286-
rubocop
287-
rubocop-minitest
288-
rubocop-performance
289-
rubocop-rails
290298
ruby-progressbar (1.13.0)
291299
ruby-vips (2.1.4)
292300
ffi (~> 1.12)
@@ -313,6 +321,18 @@ GEM
313321
actionpack (>= 5.2)
314322
activesupport (>= 5.2)
315323
sprockets (>= 3.0.0)
324+
standard (1.36.0)
325+
language_server-protocol (~> 3.17.0.2)
326+
lint_roller (~> 1.0)
327+
rubocop (~> 1.63.0)
328+
standard-custom (~> 1.0.0)
329+
standard-performance (~> 1.4)
330+
standard-custom (1.0.2)
331+
lint_roller (~> 1.0)
332+
rubocop (~> 1.50)
333+
standard-performance (1.4.0)
334+
lint_roller (~> 1.1)
335+
rubocop-performance (~> 1.21.0)
316336
stringio (3.1.0)
317337
strscan (3.1.0)
318338
temple (0.10.3)
@@ -367,9 +387,14 @@ DEPENDENCIES
367387
rails (~> 7.1.3)
368388
rdoc (>= 6.6.3.1)
369389
rollbar
370-
rubocop-rails-omakase
390+
rubocop
391+
rubocop-capybara
392+
rubocop-minitest
393+
rubocop-performance
394+
rubocop-rails
371395
selenium-webdriver
372396
spring (>= 3.0)
397+
standard (>= 1.35.1)
373398
tzinfo-data
374399
uglifier (>= 1.3.0)
375400
web-console (>= 3.3.0)

Rakefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# frozen_string_literal: true
2+
13
# Add your own tasks in files placed in lib/tasks ending in .rake,
24
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
35

4-
require_relative 'config/application'
6+
require_relative "config/application"
57

68
Rails.application.load_tasks

app/channels/application_cable/channel.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationCable
24
class Channel < ActionCable::Channel::Base
35
end

app/channels/application_cable/connection.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationCable
24
class Connection < ActionCable::Connection::Base
35
end
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationController < ActionController::Base
24
end

app/controllers/errors_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ErrorsController < ApplicationController
24
def file_not_found
35
end

app/controllers/profiles_controller.rb

+56-56
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,69 @@
1+
# frozen_string_literal: true
2+
13
class ProfilesController < ApplicationController
2-
$units = { access: "Access Services",
3-
archives: "Archives",
4-
bib: "Cataloguing Strategies",
5-
collections: "Collection Strategies",
6-
copyright: "Copyright",
7-
digital: "Digital Production & Preservation Services",
8-
digrepo: "Digital Repository & Data Services",
9-
dsc: "Digital Scholarship Centre",
10-
facilities: "Facilities",
11-
health: "Faculty Engagement (Health Sciences)",
12-
science: "Faculty Engagement (Natural + Applied Sciences)",
13-
humanities: "Faculty Engagement (Social Sciences + Humanities)",
14-
iss: "Information Services & User Engagement",
15-
admin: "Library Administration",
16-
lad: "Library Application Development",
17-
las: "Library Application Support",
18-
metadata: "Metadata Strategies",
19-
open: "Open Publishing & Digitization Services",
20-
rdm: "Research Data Management",
21-
researchimpact: "Research Impact",
22-
its: "Specialized Technical Support",
23-
special: "Special Collections",
24-
stratigic: "Strategic Partnerships",
25-
tl: "Teaching & Learning",
26-
ux: "User Experience" }
27-
$buildings = { augustana: "Augustana Campus Library",
28-
bsj: "Bibliothèque Saint-Jean",
29-
bpsc: "Bruce Peel Special Collections",
30-
cameron: "Cameron Library",
31-
sperber: "Sperber Library",
32-
rcrf: "Research & Collections Resource Facility",
33-
rutherford: "Rutherford Library",
34-
stjosephs: "St. Joseph's Library" }
4+
$units = {access: "Access Services",
5+
archives: "Archives",
6+
bib: "Cataloguing Strategies",
7+
collections: "Collection Strategies",
8+
copyright: "Copyright",
9+
digital: "Digital Production & Preservation Services",
10+
digrepo: "Digital Repository & Data Services",
11+
dsc: "Digital Scholarship Centre",
12+
facilities: "Facilities",
13+
health: "Faculty Engagement (Health Sciences)",
14+
science: "Faculty Engagement (Natural + Applied Sciences)",
15+
humanities: "Faculty Engagement (Social Sciences + Humanities)",
16+
iss: "Information Services & User Engagement",
17+
admin: "Library Administration",
18+
lad: "Library Application Development",
19+
las: "Library Application Support",
20+
metadata: "Metadata Strategies",
21+
open: "Open Publishing & Digitization Services",
22+
rdm: "Research Data Management",
23+
researchimpact: "Research Impact",
24+
its: "Specialized Technical Support",
25+
special: "Special Collections",
26+
stratigic: "Strategic Partnerships",
27+
tl: "Teaching & Learning",
28+
ux: "User Experience"}
29+
$buildings = {augustana: "Augustana Campus Library",
30+
bsj: "Bibliothèque Saint-Jean",
31+
bpsc: "Bruce Peel Special Collections",
32+
cameron: "Cameron Library",
33+
sperber: "Sperber Library",
34+
rcrf: "Research & Collections Resource Facility",
35+
rutherford: "Rutherford Library",
36+
stjosephs: "St. Joseph's Library"}
3537

3638
# You'll have to define "cmsPassword" in secrets.yml, or this will fail. Thanks, ansible.
37-
http_basic_authenticate_with name: Rails.application.secrets.cms_user, password: Rails.application.secrets.cms_password, except: [ :index, :show ]
39+
http_basic_authenticate_with name: Rails.application.secrets.cms_user, password: Rails.application.secrets.cms_password, except: [:index, :show]
3840

3941
def index
4042
path = request.url
41-
if path.include? "unit"
42-
@unit = params[:unit]
43+
if path.include? "unit"
44+
@unit = params[:unit]
4345
@unitname = $units[params[:unit].to_sym]
4446
@allunit = Profile.where(unit: @unit)
4547
@heads = @allunit.where(opt_in: true).order(:last_name)
4648
@staff = @allunit.where(opt_in: nil).order(:last_name)
4749
@profiles = @heads + @staff
48-
elsif path.include? "building"
49-
@building = params[:building]
50+
elsif path.include? "building"
51+
@building = params[:building]
5052
@buildingname = $buildings[params[:building].to_sym]
5153
@profiles = Profile.where("campus_address=?", params[:building]).order(:first_name)
52-
else
53-
@profiles = Profile.all.order(:first_name)
54-
end
55-
respond_to do |format|
56-
format.html
57-
format.csv { send_data @profiles.to_csv }
58-
end
54+
else
55+
@profiles = Profile.order(:first_name)
56+
end
57+
respond_to do |format|
58+
format.html
59+
format.csv { send_data @profiles.to_csv }
5960
end
61+
end
6062

6163
def show
62-
@profile = Profile.friendly.find(params[:id])
64+
@profile = Profile.friendly.find(params[:id])
6365
end
6466

65-
6667
def new
6768
@profile = Profile.new
6869
@buildings = $buildings
@@ -76,26 +77,26 @@ def edit
7677
end
7778

7879
def create
79-
@profile = Profile.new(profile_params)
80-
@profile.save
81-
redirect_to @profile
80+
@profile = Profile.new(profile_params)
81+
@profile.save
82+
redirect_to @profile
8283
end
8384

8485
def update
85-
@profile = Profile.friendly.find(params[:id])
86+
@profile = Profile.friendly.find(params[:id])
8687

8788
if @profile.update(profile_params)
8889
redirect_to @profile
8990
else
90-
render "edit"
91+
render "edit"
9192
end
9293
end
9394

9495
def destroy
95-
@profile = Profile.friendly.find(params[:id])
96-
@profile.destroy
96+
@profile = Profile.friendly.find(params[:id])
97+
@profile.destroy
9798

98-
redirect_to profiles_path
99+
redirect_to profiles_path
99100
end
100101

101102
def units
@@ -104,7 +105,6 @@ def units
104105
@profiles = Profile.where("unit=?", params[:id])
105106
end
106107

107-
108108
private
109109

110110
def profile_params

app/helpers/application_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationHelper
24
end

app/jobs/application_job.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationJob < ActiveJob::Base
24
end

app/mailers/application_mailer.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationMailer < ActionMailer::Base
24
default from: "from@example.com"
35
layout "mailer"

app/models/application_record.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationRecord < ActiveRecord::Base
24
self.abstract_class = true
35
end

0 commit comments

Comments
 (0)