Skip to content

Commit

Permalink
Merge pull request #1537 from UKGovernmentBEIS/2292-ruby-parser
Browse files Browse the repository at this point in the history
2: Upgrade standard and parser to avoid parser warning
  • Loading branch information
rgarner committed Jan 20, 2022
2 parents 993deed + b8f9589 commit f540fde
Show file tree
Hide file tree
Showing 181 changed files with 596 additions and 604 deletions.
2 changes: 1 addition & 1 deletion .pryrc
Expand Up @@ -36,6 +36,6 @@ if defined?(Rails)
" ",
ANSI_RESET,
sandbox_status,
" ",
" "
].join
end
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -17,7 +17,7 @@ gem "mail-notify"
gem "monetize"
gem "mini_racer"
gem "nanoid"
gem "parser", "~> 2.6.3.0"
gem "parser", "~> 3.0.1.0"
gem "pry-rails"
gem "puma", "~> 5.5"
gem "pundit"
Expand Down
34 changes: 19 additions & 15 deletions Gemfile.lock
Expand Up @@ -197,7 +197,6 @@ GEM
rainbow (>= 2.2.2, < 4.0)
terminal-table (>= 1.5.1)
ipaddr (1.2.3)
jaro_winkler (1.5.4)
jbuilder (2.11.3)
activesupport (>= 5.0.0)
json (2.5.1)
Expand Down Expand Up @@ -272,8 +271,8 @@ GEM
actionpack (>= 4.2)
omniauth (~> 2.0)
parallel (1.21.0)
parser (2.6.3.0)
ast (~> 2.4.0)
parser (3.0.1.1)
ast (~> 2.4.1)
pg (1.2.3)
pry (0.13.1)
coderay (~> 1.1)
Expand Down Expand Up @@ -349,7 +348,7 @@ GEM
redis-store (>= 1.2, < 2)
redis-store (1.9.0)
redis (>= 4, < 5)
regexp_parser (2.1.1)
regexp_parser (2.2.0)
request_store (1.5.0)
rack (>= 1.4)
rest-client (2.1.0)
Expand Down Expand Up @@ -377,15 +376,20 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.2)
rubocop (0.77.0)
jaro_winkler (~> 1.5.1)
rubocop (1.23.0)
parallel (~> 1.10)
parser (>= 2.6)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.12.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.5.2)
rubocop (>= 0.71.0)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1)
parser (>= 3.0.1.1)
rubocop-performance (1.12.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
ruby_parser (3.17.0)
Expand Down Expand Up @@ -432,9 +436,9 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
standard (0.1.8)
rubocop (~> 0.77.0)
rubocop-performance (~> 1.5.1)
standard (1.5.0)
rubocop (= 1.23.0)
rubocop-performance (= 1.12.0)
strip_attributes (1.11.0)
activemodel (>= 3.0, < 7.0)
sync (0.5.0)
Expand All @@ -452,7 +456,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.8)
unicode-display_width (1.6.1)
unicode-display_width (2.1.0)
uniform_notifier (1.14.2)
web-console (4.2.0)
actionview (>= 6.0.0)
Expand Down Expand Up @@ -515,7 +519,7 @@ DEPENDENCIES
nanoid
omniauth-auth0 (~> 3.0)
omniauth-rails_csrf_protection (~> 1.0.0)
parser (~> 2.6.3.0)
parser (~> 3.0.1.0)
pg
pry-byebug
pry-rails
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -14,7 +14,7 @@ def logout_url
client_id = ENV["AUTH0_CLIENT_ID"]
request_params = {
returnTo: root_url,
client_id: client_id,
client_id: client_id
}

URI::HTTPS.build(host: domain, path: "/v2/logout", query: to_query(request_params))
Expand Down
1 change: 1 addition & 0 deletions app/controllers/concerns/auth.rb
@@ -1,4 +1,5 @@
class UserNotAuthorised < StandardError; end

module Auth
extend ActiveSupport::Concern

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/public/base_controller.rb
Expand Up @@ -8,8 +8,8 @@ def health_check
built_at: ENV.fetch("TIME_OF_BUILD", nil),
sidekiq: {
enqueued: sidekiq_enqueued_size,
retry_size: sidekiq_retry_size,
},
retry_size: sidekiq_retry_size
}
}, status: :ok
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/staff/actual_uploads_controller.rb
Expand Up @@ -76,7 +76,7 @@ def update
activity.roda_identifier,
report.financial_quarter.to_s,
report.financial_year.to_s,
"%.2f" % 0,
"%.2f" % 0
]
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/staff/external_incomes_controller.rb
Expand Up @@ -76,7 +76,7 @@ def external_income_params
:amount,
:financial_quarter,
:financial_year,
:oda_funding,
:oda_funding
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/staff/forecasts_controller.rb
Expand Up @@ -105,7 +105,7 @@ def destroy
:currency,
:value,
:financial_quarter,
:financial_year,
:financial_year
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/staff/incoming_transfers_controller.rb
Expand Up @@ -33,7 +33,7 @@ def transfer_params
:value,
:destination_id,
:source_roda_identifier,
:beis_identifier,
:beis_identifier
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/staff/outgoing_transfers_controller.rb
Expand Up @@ -33,7 +33,7 @@ def transfer_params
:value,
:source_id,
:destination_roda_identifier,
:beis_identifier,
:beis_identifier
)
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/staff/refunds_controller.rb
Expand Up @@ -94,8 +94,8 @@ def attributes_for_editing
"financial_quarter"
))
.merge(report: refund.report,
parent_activity: refund.parent_activity,
comment: refund.comment.body)
parent_activity: refund.parent_activity,
comment: refund.comment.body)
.merge(persisted: true)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/staff/reports_state_controller.rb
Expand Up @@ -8,7 +8,7 @@ class Staff::ReportsStateController < Staff::BaseController
"submitted" => "submit",
"in_review" => "review",
"awaiting_changes" => "request_changes",
"approved" => "approve",
"approved" => "approve"
}

def edit
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/activity_helper.rb
Expand Up @@ -21,7 +21,7 @@ def link_to_activity_parent(parent:, user:)
end

def custom_capitalisation(level)
"#{level.chars.first.upcase}#{level[1..-1]}"
"#{level[0].upcase}#{level[1..]}"
end

def sdg_options
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/codelist_helper.rb
Expand Up @@ -74,14 +74,14 @@ def aid_types

def aid_type_radio_options
aid_types.to_objects_with_description(
code_displayed_in_name: true,
code_displayed_in_name: true
)
end

def fstc_applies_radio_options
[
OpenStruct.new(value: 0, label: I18n.t("form.label.activity.fstc_applies.false")),
OpenStruct.new(value: 1, label: I18n.t("form.label.activity.fstc_applies.true")),
OpenStruct.new(value: 1, label: I18n.t("form.label.activity.fstc_applies.true"))
]
end

Expand Down
8 changes: 4 additions & 4 deletions app/helpers/form_helper.rb
Expand Up @@ -9,14 +9,14 @@ def list_of_organisations
def list_of_matched_effort_providers
@list_of_matched_effort_providers ||= [
OpenStruct.new(name: "", id: ""),
Organisation.matched_effort_providers.active,
Organisation.matched_effort_providers.active
].flatten
end

def list_of_external_income_providers
@list_of_external_income_providers ||= [
OpenStruct.new(name: "", id: ""),
Organisation.external_income_providers.active,
Organisation.external_income_providers.active
].flatten
end

Expand Down Expand Up @@ -46,14 +46,14 @@ def list_of_budget_financial_years
def user_active_options
[
OpenStruct.new(id: "true", name: t("form.user.active.active")),
OpenStruct.new(id: "false", name: t("form.user.active.inactive")),
OpenStruct.new(id: "false", name: t("form.user.active.inactive"))
]
end

def organisation_active_options
[
OpenStruct.new(id: "true", name: t("form.label.organisation.active.true")),
OpenStruct.new(id: "false", name: t("form.label.organisation.active.false")),
OpenStruct.new(id: "false", name: t("form.label.organisation.active.false"))
]
end

Expand Down
4 changes: 2 additions & 2 deletions app/mailers/user_mailer.rb
Expand Up @@ -8,15 +8,15 @@ def welcome(user)
personalisation: {
name: user.name,
link: password_change_link(user: user),
service_url: ENV["DOMAIN"],
service_url: ENV["DOMAIN"]
}
)
end

def password_change_link(user:)
Auth0Api.new.client.post_password_change(
user_id: user.identifier,
result_url: organisation_url(user.organisation),
result_url: organisation_url(user.organisation)
)["ticket"]
end
end
12 changes: 6 additions & 6 deletions app/models/activity.rb
Expand Up @@ -35,7 +35,7 @@ class Activity < ApplicationRecord
:channel_of_delivery_code,
:oda_eligibility,
:oda_eligibility_lead,
:uk_dp_named_contact,
:uk_dp_named_contact
]

VALIDATION_STEPS = [
Expand All @@ -62,7 +62,7 @@ class Activity < ApplicationRecord
:channel_of_delivery_code_step,
:oda_eligibility_step,
:oda_eligibility_lead_step,
:uk_dp_named_contact_step,
:uk_dp_named_contact_step
]

FORM_STATE_VALIDATION_LIST = FORM_STEPS.map(&:to_s).push("complete")
Expand Down Expand Up @@ -156,12 +156,12 @@ class Activity < ApplicationRecord
fund: "fund",
programme: "programme",
project: "project",
third_party_project: "third_party_project",
third_party_project: "third_party_project"
}

enum geography: {
recipient_region: "Recipient region",
recipient_country: "Recipient country",
recipient_country: "Recipient country"
}

enum programme_status: {
Expand All @@ -176,7 +176,7 @@ class Activity < ApplicationRecord
completed: 9,
stopped: 10,
cancelled: 11,
paused: 12,
paused: 12
}

NON_CURRENT_PROGRAMME_STATUSES = ["completed", "stopped", "cancelled"]
Expand All @@ -201,7 +201,7 @@ class Activity < ApplicationRecord
enum oda_eligibility: {
never_eligible: 0,
eligible: 1,
no_longer_eligible: 2,
no_longer_eligible: 2
}

scope :programmes, -> { where(level: :programme) }
Expand Down
2 changes: 1 addition & 1 deletion app/models/benefitting_region.rb
Expand Up @@ -24,7 +24,7 @@ def new_from_hash(region)
new(
name: region["name"],
code: region["code"],
level: Level.find_by_code(region["level"]),
level: Level.find_by_code(region["level"])
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/budget.rb
Expand Up @@ -4,7 +4,7 @@ class Budget < ApplicationRecord

enum budget_type: {
direct: 0,
other_official: 1,
other_official: 1
}

belongs_to :parent_activity, class_name: "Activity"
Expand Down
4 changes: 3 additions & 1 deletion app/models/codelist.rb
@@ -1,6 +1,8 @@
class Codelist
class UnreadableCodelist < StandardError; end

class UnrecognisedSource < StandardError; end

class KeyNotFound < StandardError; end

include Enumerable
Expand Down Expand Up @@ -33,7 +35,7 @@ def codelist_to_hash(path)
def initialize_codelists
{
"iati" => codelist_to_hash("IATI/#{IATI_VERSION}"),
"beis" => codelist_to_hash("BEIS"),
"beis" => codelist_to_hash("BEIS")
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/commitment.rb
Expand Up @@ -6,12 +6,12 @@ class Commitment < ApplicationRecord
validates :value, :financial_quarter, :financial_year, presence: true
validates :value, numericality: {
greater_than: 0,
less_than_or_equal_to: 99_999_999_999.00,
less_than_or_equal_to: 99_999_999_999.00
}
validates :financial_quarter, inclusion: {in: 1..4}
validates :financial_year, numericality: {
greater_than_or_equal_to: 2000,
less_than_or_equal_to: 3000,
only_integer: true,
only_integer: true
}
end
2 changes: 1 addition & 1 deletion app/models/export/activity_actuals_columns.rb
Expand Up @@ -14,7 +14,7 @@ def headers
[
"Actual spend #{financial_quarter}",
"Refund #{financial_quarter}",
"Actual net #{financial_quarter}",
"Actual net #{financial_quarter}"
]
else
["Actual net #{financial_quarter}"]
Expand Down
4 changes: 2 additions & 2 deletions app/models/export/activity_attributes_columns.rb
Expand Up @@ -7,14 +7,14 @@ class Export::ActivityAttributesColumns
:form_state,
:extending_organisation_id,
:geography,
:parent_id,
:parent_id
]

DYNAMIC_ATTRIBUTES = [
:benefitting_region,
:flow,
:finance,
:tied_status,
:tied_status
]

def initialize(activities:, attributes:)
Expand Down

0 comments on commit f540fde

Please sign in to comment.