Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change array style to brackets instead of %w/%i #438

Merged
merged 3 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ Rails/I18nLocaleTexts:

I18n/RailsI18n/DecorateString:
Enabled: false

# Allow string or symbol array without literal
Style/WordArray:
EnforcedStyle: brackets
SupportedStyles:
- brackets

Style/SymbolArray:
EnforcedStyle: brackets
SupportedStyles:
- brackets
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ gem 'jbuilder'
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false
Expand All @@ -57,7 +57,7 @@ gem 'cancancan', '~> 3.4'

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem 'debug', platforms: %i[mri mingw x64_mingw]
gem 'debug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/free_accesses_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

class FreeAccessesController < ApplicationController
before_action :owner, only: %i[create new]
before_action :current_free_access, only: %i[edit update destroy]
before_action :owner, only: [:create, :new]
before_action :current_free_access, only: [:edit, :update, :destroy]

def new
@free_access = @owner.free_accesses.new(start_at: Time.current)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/machines_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class MachinesController < ApplicationController
protect_from_forgery unless: -> { request.format.json? }

before_action :owner, only: %i[create new]
before_action :current_machine, only: %i[show edit update destroy]
before_action :owner, only: [:create, :new]
before_action :current_machine, only: [:show, :edit, :update, :destroy]

def show
authorize! :show, @machine
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/subscriptions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class SubscriptionsController < ApplicationController
before_action :owner, only: %i[create new destroy]
before_action :owner, only: [:create, :new, :destroy]

def new
@subscription = @owner.subscriptions.new
Expand Down
4 changes: 2 additions & 2 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Ability
def initialize(user)
return if user.blank?

can %i[read update], User, id: user.id
can %i[read update destroy], Machine, user: user
can [:read, :update], User, id: user.id
can [:read, :update, :destroy], Machine, user: user
# User can create a new machine to themselves if they don't have too many machines
can [:create], Machine do |machine|
machine.user == user && user.machines.size < USER_MACHINES_LIMIT
Expand Down
4 changes: 1 addition & 3 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@
# Configure parameters to be filtered from the log file. Use this to limit dissemination of
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
# notations and behaviors.
Rails.application.config.filter_parameters += %i[
passw secret token _key crypt salt certificate otp ssn
]
Rails.application.config.filter_parameters += [:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn]
2 changes: 1 addition & 1 deletion config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
end
provider :openid_connect, {
name: :keycloak,
scope: %i[openid email profile room roles],
scope: [:openid, :email, :profile, :room, :roles],
response_type: :code,
issuer: 'https://auth.rezoleo.fr/realms/rezoleo',
discovery: true,
Expand Down
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

resources :users do
resources :machines, shallow: true, except: [:index]
resources :subscriptions, shallow: true, only: %i[new create]
resources :subscriptions, shallow: true, only: [:new, :create]
delete '/last_subscription', to: 'subscriptions#destroy', as: 'last_subscription'
resources :free_accesses, shallow: true, except: %i[index show]
resources :free_accesses, shallow: true, except: [:index, :show]
end
end
2 changes: 1 addition & 1 deletion lib/tasks/system_test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace :test do
end

desc 'Run system tests with Firefox (can be run headless and/or use Firefox Nightly)'
task :firefox, %i[headless nightly] => [:environment] do |_task, args|
task :firefox, [:headless, :nightly] => [:environment] do |_task, args|
# Small (ab)use of args.to_a, normally used to retrieve a variable number of arguments
# Since here we only care that the *strings* 'headless' or 'nightly' are passed, we convert
# the args struct to an array of all argument values, then just check if a specific string is in it.
Expand Down
5 changes: 3 additions & 2 deletions test/models/ip_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ def setup
end

test 'ip must be of a valid format' do
valid_ips = %w[172.30.110.68]
invalid_ips = %w[172..30.110.68 172.300.110.68 172.0004.110.68 172.30.68 172.30.110.68.17 172.30.110.68.]
valid_ips = ['172.30.110.68']
invalid_ips = ['172..30.110.68', '172.300.110.68', '172.0004.110.68', '172.30.68', '172.30.110.68.17',
'172.30.110.68.']

valid_ips.each do |valid_ip|
@ip.ip = valid_ip
Expand Down
6 changes: 3 additions & 3 deletions test/models/machine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def setup
end

test 'mac must be of a valid format' do
valid_macs = %w[AD:14:D4:87:4B:D7 ba:d4:8a:54:47:3f 23:Eb:1a:3A:BC:f7
AD-14-D4-87-4B-D7 ba-d4-8a-54-47-3f AD14D4874BD7 bad48a54473f
AD14.D487.4BD7 ad14.d487.4bd7 AD14.d487.4bD7]
valid_macs = ['AD:14:D4:87:4B:D7', 'ba:d4:8a:54:47:3f', '23:Eb:1a:3A:BC:f7', 'AD-14-D4-87-4B-D7',
'ba-d4-8a-54-47-3f', 'AD14D4874BD7', 'bad48a54473f', 'AD14.D487.4BD7',
'ad14.d487.4bd7', 'AD14.d487.4bD7']

invalid_macs = ['AD:14', # must not be too short
'AD:14:D4:87:4B:', # trailing colon
Expand Down
7 changes: 3 additions & 4 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def setup
end

test 'email must be of a valid format' do
valid_emails = %w[[email protected] [email protected] [email protected]
[email protected] [email protected]]
valid_emails = ['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
invalid_emails = ['user@example,com', 'user_at_foo.org', 'user.name@example',
'foo@bar_baz.com', 'foo@bar+baz.com', '[email protected]', ' ']

Expand Down Expand Up @@ -91,8 +90,8 @@ def setup
end

test 'room must be of a valid format' do
valid_rooms = %w[A205 B134a C001b F313 D111b E231a DF1 DF2 DF3 DF4]
invalid_rooms = %w[A2005 C404 D111c B1 E22 G207]
valid_rooms = ['A205', 'B134a', 'C001b', 'F313', 'D111b', 'E231a', 'DF1', 'DF2', 'DF3', 'DF4']
invalid_rooms = ['A2005', 'C404', 'D111c', 'B1', 'E22', 'G207']

valid_rooms.each do |valid_room|
@user.room = valid_room
Expand Down