Skip to content

Commit 2dc8b7b

Browse files
authored
857-fix-rubocop (#584)
## Status - Closes RaspberryPiFoundation/digital-editor-issues#857 ## What's changed? - Updates rubocop and associated plugins - Fixes rubocop syntax - Fixes lint issues ## Steps to perform after deploying to production N/A
1 parent e4c2a7e commit 2dc8b7b

39 files changed

+184
-179
lines changed

.rubocop.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
---
22
require:
33
- rubocop-graphql
4+
plugins:
5+
- rubocop-rails
46
- rubocop-capybara
7+
- rubocop-performance
8+
- rubocop-rspec_rails
9+
- rubocop-factory_bot
510
inherit_from:
611
- https://raspberrypifoundation.github.io/digital-engineering/configs/rubocop-base.yml
712
- https://raspberrypifoundation.github.io/digital-engineering/configs/rubocop-rails.yml
@@ -28,11 +33,17 @@ RSpec/DescribeClass:
2833
- "spec/graphql/mutations/**"
2934

3035
RSpec/MultipleMemoizedHelpers:
31-
Max: 8
36+
Max: 15
3237

3338
RSpec/ExampleLength:
3439
Enabled: false
3540

41+
RSpec/MultipleExpectations:
42+
Enabled: false
43+
44+
RSpec/IndexedLet:
45+
Enabled: false
46+
3647
Metrics/BlockLength:
3748
Enabled: false
3849

@@ -45,3 +56,9 @@ Layout/LineLength:
4556
Naming/VariableNumber:
4657
EnforcedStyle: snake_case
4758
AllowedIdentifiers: sha256, X-Hub-Signature-256
59+
60+
Style/SafeNavigationChainLength:
61+
Enabled: false
62+
63+
Rails/EnvLocal:
64+
Enabled: false

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ group :development, :test do
5050
gem 'rspec_junit_formatter'
5151
gem 'rspec-rails'
5252
gem 'rubocop', require: false
53+
gem 'rubocop-capybara', require: false
54+
gem 'rubocop-factory_bot', require: false
5355
gem 'rubocop-graphql', require: false
56+
gem 'rubocop-performance', require: false
5457
gem 'rubocop-rails', require: false
5558
gem 'rubocop-rspec', require: false
59+
gem 'rubocop-rspec_rails', require: false
5660
gem 'simplecov', require: false
5761
end
5862

Gemfile.lock

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ GEM
9898
administrate-field-active_storage (1.0.1)
9999
administrate (>= 0.2.2)
100100
rails (>= 7.0)
101-
ast (2.4.2)
101+
ast (2.4.3)
102102
awesome_print (1.9.2)
103103
aws-eventstream (1.2.0)
104104
aws-partitions (1.718.0)
@@ -116,8 +116,8 @@ GEM
116116
aws-sigv4 (~> 1.4)
117117
aws-sigv4 (1.5.2)
118118
aws-eventstream (~> 1, >= 1.0.2)
119-
base64 (0.2.0)
120-
bigdecimal (3.1.8)
119+
base64 (0.3.0)
120+
bigdecimal (3.2.2)
121121
bootsnap (1.16.0)
122122
msgpack (~> 1.2)
123123
builder (3.3.0)
@@ -138,8 +138,8 @@ GEM
138138
choice (0.2.0)
139139
climate_control (1.2.0)
140140
coderay (1.1.3)
141-
concurrent-ruby (1.3.3)
142-
connection_pool (2.4.1)
141+
concurrent-ruby (1.3.5)
142+
connection_pool (2.5.3)
143143
countries (5.7.1)
144144
unaccent (~> 0.3)
145145
crack (0.4.5)
@@ -159,7 +159,7 @@ GEM
159159
dotenv-rails (2.8.1)
160160
dotenv (= 2.8.1)
161161
railties (>= 3.2)
162-
drb (2.2.1)
162+
drb (2.2.3)
163163
email_validator (2.2.4)
164164
activemodel
165165
erubi (1.13.0)
@@ -202,7 +202,7 @@ GEM
202202
graphql
203203
hashdiff (1.0.1)
204204
hashie (5.0.0)
205-
i18n (1.14.5)
205+
i18n (1.14.7)
206206
concurrent-ruby (~> 1.0)
207207
image_processing (1.12.2)
208208
mini_magick (>= 4.9.5, < 5)
@@ -222,7 +222,7 @@ GEM
222222
rails-dom-testing (>= 1, < 3)
223223
railties (>= 4.2.0)
224224
thor (>= 0.14, < 2.0)
225-
json (2.6.3)
225+
json (2.13.2)
226226
jwt (2.2.3)
227227
kaminari (1.2.2)
228228
activesupport (>= 4.1.0)
@@ -236,7 +236,8 @@ GEM
236236
activerecord
237237
kaminari-core (= 1.2.2)
238238
kaminari-core (1.2.2)
239-
language_server-protocol (3.17.0.3)
239+
language_server-protocol (3.17.0.5)
240+
lint_roller (1.1.0)
240241
logger (1.6.0)
241242
loofah (2.22.0)
242243
crass (~> 1.0.2)
@@ -251,10 +252,10 @@ GEM
251252
method_source (1.0.0)
252253
mini_magick (4.12.0)
253254
mini_mime (1.1.2)
254-
minitest (5.23.1)
255+
minitest (5.25.5)
255256
msgpack (1.6.0)
256257
multi_xml (0.6.0)
257-
mutex_m (0.2.0)
258+
mutex_m (0.3.0)
258259
net-imap (0.4.12)
259260
date
260261
net-protocol
@@ -295,9 +296,10 @@ GEM
295296
paper_trail (15.1.0)
296297
activerecord (>= 6.1)
297298
request_store (~> 1.4)
298-
parallel (1.22.1)
299-
parser (3.2.1.0)
299+
parallel (1.27.0)
300+
parser (3.3.9.0)
300301
ast (~> 2.4.1)
302+
racc
301303
pg (1.4.6)
302304
postmark (1.25.0)
303305
json
@@ -317,8 +319,8 @@ GEM
317319
puma (6.4.2)
318320
nio4r (~> 2.0)
319321
raabro (1.4.0)
320-
racc (1.8.0)
321-
rack (2.2.9)
322+
racc (1.8.1)
323+
rack (2.2.17)
322324
rack-cors (2.0.0)
323325
rack (>= 2.0.0)
324326
rack-protection (3.2.0)
@@ -371,13 +373,12 @@ GEM
371373
logger
372374
rdoc (6.7.0)
373375
psych (>= 4.0.0)
374-
regexp_parser (2.7.0)
376+
regexp_parser (2.11.2)
375377
reline (0.5.9)
376378
io-console (~> 0.5)
377379
request_store (1.7.0)
378380
rack (>= 1.4)
379-
rexml (3.3.0)
380-
strscan
381+
rexml (3.4.1)
381382
rspec (3.12.0)
382383
rspec-core (~> 3.12.0)
383384
rspec-expectations (~> 3.12.0)
@@ -401,29 +402,44 @@ GEM
401402
rspec-support (3.12.0)
402403
rspec_junit_formatter (0.6.0)
403404
rspec-core (>= 2, < 4, != 2.12.0)
404-
rubocop (1.47.0)
405+
rubocop (1.74.0)
405406
json (~> 2.3)
407+
language_server-protocol (~> 3.17.0.2)
408+
lint_roller (~> 1.1.0)
406409
parallel (~> 1.10)
407-
parser (>= 3.2.0.0)
410+
parser (>= 3.3.0.2)
408411
rainbow (>= 2.2.2, < 4.0)
409-
regexp_parser (>= 1.8, < 3.0)
410-
rexml (>= 3.2.5, < 4.0)
411-
rubocop-ast (>= 1.26.0, < 2.0)
412+
regexp_parser (>= 2.9.3, < 3.0)
413+
rubocop-ast (>= 1.38.0, < 2.0)
412414
ruby-progressbar (~> 1.7)
413-
unicode-display_width (>= 2.4.0, < 3.0)
414-
rubocop-ast (1.27.0)
415-
parser (>= 3.2.1.0)
416-
rubocop-capybara (2.17.1)
417-
rubocop (~> 1.41)
415+
unicode-display_width (>= 2.4.0, < 4.0)
416+
rubocop-ast (1.42.0)
417+
parser (>= 3.3.7.2)
418+
rubocop-capybara (2.22.1)
419+
lint_roller (~> 1.1)
420+
rubocop (~> 1.72, >= 1.72.1)
421+
rubocop-factory_bot (2.27.1)
422+
lint_roller (~> 1.1)
423+
rubocop (~> 1.72, >= 1.72.1)
418424
rubocop-graphql (1.0.0)
419425
rubocop (>= 0.87, < 2)
420-
rubocop-rails (2.18.0)
426+
rubocop-performance (1.24.0)
427+
lint_roller (~> 1.1)
428+
rubocop (>= 1.72.1, < 2.0)
429+
rubocop-ast (>= 1.38.0, < 2.0)
430+
rubocop-rails (2.30.3)
421431
activesupport (>= 4.2.0)
432+
lint_roller (~> 1.1)
422433
rack (>= 1.1)
423-
rubocop (>= 1.33.0, < 2.0)
424-
rubocop-rspec (2.18.1)
425-
rubocop (~> 1.33)
426-
rubocop-capybara (~> 2.17)
434+
rubocop (>= 1.72.1, < 2.0)
435+
rubocop-ast (>= 1.38.0, < 2.0)
436+
rubocop-rspec (3.6.0)
437+
lint_roller (~> 1.1)
438+
rubocop (~> 1.72, >= 1.72.1)
439+
rubocop-rspec_rails (2.31.0)
440+
lint_roller (~> 1.1)
441+
rubocop (~> 1.72, >= 1.72.1)
442+
rubocop-rspec (~> 3.5)
427443
ruby-graphviz (1.2.5)
428444
rexml
429445
ruby-lsp (0.17.7)
@@ -435,7 +451,7 @@ GEM
435451
ruby-lsp (>= 0.17.2, < 0.18.0)
436452
ruby-lsp-rspec (0.1.12)
437453
ruby-lsp (~> 0.17.0)
438-
ruby-progressbar (1.11.0)
454+
ruby-progressbar (1.13.0)
439455
ruby-vips (2.2.0)
440456
ffi (~> 1.12)
441457
ruby2_keywords (0.0.5)
@@ -482,7 +498,6 @@ GEM
482498
activesupport (>= 5.2)
483499
sprockets (>= 3.0.0)
484500
stringio (3.1.1)
485-
strscan (3.1.0)
486501
thor (1.3.1)
487502
tilt (2.3.0)
488503
time (0.3.0)
@@ -491,7 +506,9 @@ GEM
491506
tzinfo (2.0.6)
492507
concurrent-ruby (~> 1.0)
493508
unaccent (0.4.0)
494-
unicode-display_width (2.4.2)
509+
unicode-display_width (3.1.5)
510+
unicode-emoji (~> 4.0, >= 4.0.4)
511+
unicode-emoji (4.0.4)
495512
uniform_notifier (1.16.0)
496513
uri (0.13.0)
497514
version_gem (1.1.3)
@@ -563,9 +580,13 @@ DEPENDENCIES
563580
rspec-rails
564581
rspec_junit_formatter
565582
rubocop
583+
rubocop-capybara
584+
rubocop-factory_bot
566585
rubocop-graphql
586+
rubocop-performance
567587
rubocop-rails
568588
rubocop-rspec
589+
rubocop-rspec_rails
569590
ruby-lsp (~> 0.17.7)
570591
ruby-lsp-rails
571592
ruby-lsp-rspec

app/controllers/test_utilities_controller.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,10 @@ class TestUtilitiesController < ApplicationController
77
Rails.application.load_tasks if Rake::Task.tasks.empty?
88

99
def reseed
10-
# rubocop:disable Rails/Output
11-
pp 'api_key_valid?', api_key_valid?
12-
pp 'api_key_present?', ENV['RESEED_API_KEY'].present?
13-
pp 'api_key_correct?', request.headers['X-RESEED-API-KEY'] == ENV['RESEED_API_KEY']
14-
pp 'host_allowed?', host_allowed?
15-
pp 'host', request.host
16-
pp 'reseed_allowed?', reseed_allowed?
17-
1810
if reseed_allowed?
19-
pp 'reseed was allowed'
20-
pp 'destroying seeds...'
2111
Rake::Task['test_seeds:destroy'].execute
22-
pp 'creating seeds...'
2312
Rake::Task['test_seeds:create'].execute
24-
pp 'success!'
2513
render json: { message: 'Database reseeded successfully.' }, status: :ok
26-
# rubocop:enable Rails/Output
2714
else
2815
head :not_found
2916
end

app/models/role.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Role < ApplicationRecord
44
belongs_to :school
55

6-
enum :role, %i[student teacher owner]
6+
enum :role, { student: 0, teacher: 1, owner: 2 }
77

88
validates :user_id, presence: true
99
validates :role, presence: true, uniqueness: { scope: %i[school_id user_id] }

app/models/school.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class School < ApplicationRecord
99

1010
VALID_URL_REGEX = %r{\A(?:https?://)?(?:www.)?[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,63}(\.[a-z]{2,63})*(/.*)?\z}ix
1111

12-
enum :user_origin, %i[for_education experience_cs], default: :for_education, validate: true
12+
enum :user_origin, { for_education: 0, experience_cs: 1 }, default: :for_education, validate: true
1313

1414
validates :name, presence: true
1515
validates :website, presence: true, format: { with: VALID_URL_REGEX, message: I18n.t('validations.school.website') }

config/initializers/content_security_policy.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
# Be sure to restart your server when you modify this file.
34

45
# Define an application-wide content security policy.

config/initializers/inflections.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
# Be sure to restart your server when you modify this file.
34

45
# Add new inflection rules using the following format. Inflections

config/initializers/permissions_policy.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
# Be sure to restart your server when you modify this file.
34

45
# Define an application-wide HTTP permissions policy. For further

lib/concepts/project/operations/update.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def update_component_attributes(response, update_hash)
7575
end
7676

7777
def overwrite_component_attributes(response, component_params)
78-
component = response[:project].components.select { |c| c.id == component_params[:id] }.first
78+
component = response[:project].components.find { |c| c.id == component_params[:id] }
7979
component.assign_attributes(component_params)
8080
end
8181

0 commit comments

Comments
 (0)