Skip to content

Commit

Permalink
Update Ruby to 3.1 (#12294)
Browse files Browse the repository at this point in the history
* Upgrade to Ruby 3.1

* Fix boot error

See https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias

* RuboCop: Auto correct Style/HashSyntax

Also corrects other Offenses which came up when correcting for HashSyntax:

- Style/IfUnlessModifier
- Layout/FirstArgumentIndentation
- Layout/FirstHashElementIndentation

* RuboCop: Auto correct Naming/BlockForwarding

* RuboCop: Auto correct Style/ArrayIntersect

* Spec Fix: Mobile Claims and Appeals request spec
  • Loading branch information
ericboehs authored Mar 30, 2023
1 parent 1ea5b7e commit 745787f
Show file tree
Hide file tree
Showing 846 changed files with 3,381 additions and 3,387 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.5
3.1.3
6 changes: 3 additions & 3 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ module VSPDanger

OpenStruct.new(
total_changes: insertions + deletions,
insertions: insertions,
deletions: deletions,
file_name: file_name
insertions:,
deletions:,
file_name:
)
end.compact
end
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# stretch (or in alpine) and is switched automatically to pdftk-java in buster
# https://github.com/department-of-veterans-affairs/va.gov-team/issues/3032

FROM ruby:3.0.5-slim-bullseye AS modules
FROM ruby:3.1.3-slim-bullseye AS modules

WORKDIR /tmp

Expand All @@ -14,7 +14,7 @@ RUN find modules -type f ! \( -name Gemfile -o -name "*.gemspec" -o -path "*/lib
###
# shared build/settings for all child images, reuse these layers yo
###
FROM ruby:3.0.5-slim-bullseye AS base
FROM ruby:3.1.3-slim-bullseye AS base

ARG userid=993
SHELL ["/bin/bash", "-c"]
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source 'https://rubygems.org'

ruby '~> 3.0.5'
ruby '~> 3.1.3'

# Modules
path 'modules' do
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ DEPENDENCIES
yard

RUBY VERSION
ruby 3.0.5p211
ruby 3.1.3p185

BUNDLED WITH
2.4.9
2.4.10
2 changes: 1 addition & 1 deletion app/controllers/concerns/failed_request_loggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ def log_exception_to_personal_information_log(exception, error_class:, **additio
}
data[:additional_data] = additional_data if additional_data.present?

PersonalInformationLog.create! error_class: error_class, data: data
PersonalInformationLog.create! error_class:, data:
end
end
2 changes: 1 addition & 1 deletion app/controllers/concerns/sentry_controller_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def user_context
end

def tags_context
{ controller_name: controller_name }.tap do |tags|
{ controller_name: }.tap do |tags|
if current_user.present?
tags[:sign_in_method] = current_user.identity.sign_in[:service_name]
# account_type is filtered by sentry, becasue in other contexts it refers to a bank account type
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/sign_in/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def cookie_access_token

def authenticate_access_token(with_validation: true)
access_token_jwt = bearer_token || cookie_access_token
AccessTokenJwtDecoder.new(access_token_jwt: access_token_jwt).perform(with_validation: with_validation)
AccessTokenJwtDecoder.new(access_token_jwt:).perform(with_validation:)
end

def load_user_object
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/facilities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def pagination_params
total_entries = page * per_page + 1
hsh.compact.transform_values!(&:to_i)
hsh.merge(
total_entries: total_entries
total_entries:
)
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/inherited_proofing_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def auth

raise unless auth_code

render body: logingov_inherited_proofing_service.render_auth(auth_code: auth_code),
render body: logingov_inherited_proofing_service.render_auth(auth_code:),
content_type: 'text/html'
rescue => e
render json: { errors: e }, status: :bad_request
end

def user_attributes
user_attributes = InheritedProofing::UserAttributesFetcher.new(auth_code: @auth_code).perform
encrypted_attributes = InheritedProofing::UserAttributesEncryptor.new(user_attributes: user_attributes).perform
encrypted_attributes = InheritedProofing::UserAttributesEncryptor.new(user_attributes:).perform
render json: { data: encrypted_attributes }
rescue => e
render json: { errors: e }, status: :bad_request
Expand All @@ -46,7 +46,7 @@ def callback
def auth_code_bearer_token
header = request.authorization
access_token_jwt = header.gsub(BEARER_PATTERN, '') if header&.match(BEARER_PATTERN)
InheritedProofing::JwtDecoder.new(access_token_jwt: access_token_jwt).perform
InheritedProofing::JwtDecoder.new(access_token_jwt:).perform
end

def authenticate_auth_code_access_token
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/openid_application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def token_from_request
def establish_session(profile)
ttl = token.payload['exp'] - Time.current.utc.to_i

user_identity = OpenidUserIdentity.build_from_profile(uuid: token.identifiers.uuid, profile: profile, ttl: ttl)
@current_user = OpenidUser.build_from_identity(identity: user_identity, ttl: ttl)
user_identity = OpenidUserIdentity.build_from_profile(uuid: token.identifiers.uuid, profile:, ttl:)
@current_user = OpenidUser.build_from_identity(identity: user_identity, ttl:)
@session = build_session(ttl,
token.identifiers.uuid,
Okta::UserProfile.new({ 'last_login_type' => profile['last_login_type'],
Expand Down Expand Up @@ -211,13 +211,13 @@ def parse_profile(profile_response)
end

def build_session(ttl, uuid, profile)
session = Session.new(token: hash_token(token), uuid: uuid, profile: profile)
session = Session.new(token: hash_token(token), uuid:, profile:)
session.expire(ttl)
session
end

def build_launch_session(ttl, launch)
session = Session.new(token: hash_token(token), launch: launch)
session = Session.new(token: hash_token(token), launch:)
session.expire(ttl)
session
end
Expand Down Expand Up @@ -333,7 +333,7 @@ def permit_scopes(scopes, actions: [])
return false unless token.payload

if (actions.empty? ||
Array.wrap(actions).map(&:to_s).include?(action_name)) && (Array.wrap(scopes) & token.payload['scp']).empty?
Array.wrap(actions).map(&:to_s).include?(action_name)) && !Array.wrap(scopes).intersect?(token.payload['scp'])
render_unauthorized
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/claim_documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ClaimDocumentsController < ApplicationController
skip_before_action(:authenticate)

def create
attachment = klass.new(form_id: form_id)
attachment = klass.new(form_id:)
# add the file after so that we have a form_id and guid for the uploader to use
attachment.file = params['file']
raise Common::Exceptions::ValidationErrors, attachment unless attachment.valid?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/claim_letters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def show
document_id = CGI.unescape(params[:document_id])

service.get_letter(document_id) do |data, mime_type, disposition, filename|
send_data(data, type: mime_type, disposition: disposition, filename: filename)
send_data(data, type: mime_type, disposition:, filename:)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/coe_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def submit_coe_claim

Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.class::FORM}"
clear_saved_form(claim.form_id)
render json: { data: { attributes: { reference_number: response, claim: claim } } }
render json: { data: { attributes: { reference_number: response, claim: } } }
end

def documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def data_and_metadata_with_updated_rated_disabilites

{
formData: parsed_form_data,
metadata: metadata
metadata:
}
end

def rated_disabilities_evss
@rated_disabilities_evss ||= FormProfiles::VA526ez.for(form_id: form_id, user: @current_user)
@rated_disabilities_evss ||= FormProfiles::VA526ez.for(form_id:, user: @current_user)
.initialize_rated_disabilities_information
rescue
# if the call to EVSS fails we can skip updating. EVSS fails around an hour each night.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/feature_toggles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def index
features = get_all_features
end

render json: { data: { type: 'feature_toggles', features: features } }
render json: { data: { type: 'feature_toggles', features: } }
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/financial_status_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def fsr_form
:married,
{ ages_of_other_dependents: [],
veteran_full_name: full_name,
address: address,
address:,
spouse_full_name: full_name,
employment_history: [
:veteran_or_spouse,
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/v0/higher_level_reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create
AppealSubmission.create!(user_uuid: @current_user.uuid,
user_account: @current_user.user_account,
type_of_appeal: 'HLR',
submitted_appeal_uuid: submitted_appeal_uuid)
submitted_appeal_uuid:)
render json: hlr_response_body
rescue => e
request = begin
Expand All @@ -29,7 +29,7 @@ def create
end

log_exception_to_personal_information_log(
e, error_class: error_class(method: 'create', exception_class: e.class), request: request
e, error_class: error_class(method: 'create', exception_class: e.class), request:
)
raise
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/in_progress_forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def show

def update
form = InProgressForm.form_for_user(form_id, @current_user) ||
InProgressForm.new(form_id: form_id, user_uuid: @current_user.uuid)
InProgressForm.new(form_id:, user_uuid: @current_user.uuid)
form.user_account = @current_user.user_account
form.real_user_uuid = @current_user.uuid
form.update!(form_data: params[:form_data] || params[:formData], metadata: params[:metadata])
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/v0/mhv_opt_in_flags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def create

status = :ok
opt_in_flag = MHVOptInFlag.find_or_create_by(user_account: current_user.user_account,
feature: feature) do |_mhv_opt_in_flag|
feature:) do |_mhv_opt_in_flag|
status = :created
end
render json: { mhv_opt_in_flag: { user_account_id: opt_in_flag.user_account_id, feature: opt_in_flag.feature } },
status: status
status:
rescue MHVOptInFlagFeatureNotValid => e
render json: { errors: e }, status: :bad_request
rescue
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/v0/notice_of_disagreements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module V0
class NoticeOfDisagreementsController < AppealsBaseController
def create
nod_response_body = AppealSubmission.submit_nod(current_user: @current_user, request_body_hash: request_body_hash)
nod_response_body = AppealSubmission.submit_nod(current_user: @current_user, request_body_hash:)
render json: nod_response_body
rescue => e
request = begin
Expand All @@ -13,7 +13,7 @@ def create
end

log_exception_to_personal_information_log(
e, error_class: error_class(method: 'create', exception_class: e.class), request: request
e, error_class: error_class(method: 'create', exception_class: e.class), request:
)
raise
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/post911_gi_bill_statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def service_available?

def log_vet_not_found(user, timestamp)
PersonalInformationLog.create(
data: { timestamp: timestamp, user: user_json(user) },
data: { timestamp:, user: user_json(user) },
error_class: 'EVSS::GiBillStatus::NotFound'
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def log_errors_for(response)
'mpi missing data bug',
:info,
{
response: response,
params: params,
response:,
params:,
gender: response.gender,
birth_date: response.birth_date
},
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/profile/service_histories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_military_info
json = JSON.parse(response.episodes.to_json, symbolize_names: true)

render status: response.status,
json: json,
json:,
serializer: ServiceHistorySerializer
end

Expand Down
Loading

0 comments on commit 745787f

Please sign in to comment.