Skip to content

Commit

Permalink
I’ve run rubocop so we are using the latest ruby syntax where changes…
Browse files Browse the repository at this point in the history
… have been made for ruby v3.
  • Loading branch information
tim-s-ccs committed Mar 16, 2023
1 parent 2678518 commit 11f648f
Show file tree
Hide file tree
Showing 159 changed files with 506 additions and 513 deletions.
9 changes: 1 addition & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,5 @@ Rails/HelperInstanceVariable:
Style/OptionalBooleanParameter:
Enabled: false

# TODO: Reenable these cops
Style/HashSyntax:
Enabled: false

Naming/BlockForwarding:
Enabled: false

Style/ArrayIntersect:
Enabled: false
EnforcedShorthandSyntax: consistent
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def update

context = context_from_params

if @buyer_detail.save(context: context)
if @buyer_detail.save(context:)
redirect_to redirect_path(context)
else
render render_template(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def show_path(building = @building)
end

def edit_path(building, section)
edit_facilities_management_rm3830_building_path(building, section: section)
edit_facilities_management_rm3830_building_path(building, section:)
end

def create_path
facilities_management_rm3830_buildings_path
end

def update_path
facilities_management_rm3830_building_path(@building, section: section)
facilities_management_rm3830_building_path(@building, section:)
end

def start_a_procurement_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def show_path(building = @building)
end

def edit_path(building, section)
edit_facilities_management_rm3830_procurement_edit_building_path(@procurement, building, section: section)
edit_facilities_management_rm3830_procurement_edit_building_path(@procurement, building, section:)
end

def create_path
facilities_management_rm3830_procurement_edit_buildings_path(@procurement)
end

def update_path
facilities_management_rm3830_procurement_edit_building_path(@procurement, @building, section: section)
facilities_management_rm3830_procurement_edit_building_path(@procurement, @building, section:)
end

def start_a_procurement_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def update
def update_procurement_building_service(pbs_params, context)
@building_service.assign_attributes(pbs_params)

if @building_service.save(context: context)
if @building_service.save(context:)
redirect_to facilities_management_rm3830_procurement_building_path(@procurement_building)
else
params[:service_question] = params[:facilities_management_rm3830_procurement_building_service][:service_question]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def start_bulk_upload
def download_da_spreadsheet(spreadsheet_creator, filename)
spreadsheet_builder = spreadsheet_creator.new @procurement.first_unsent_contract.id
spreadsheet_builder.build
send_data spreadsheet_builder.to_xlsx, filename: filename
send_data spreadsheet_builder.to_xlsx, filename:
end

def change_the_contract_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def show_path(building = @building)
end

def edit_path(building, section)
edit_facilities_management_rm6232_building_path(building, section: section)
edit_facilities_management_rm6232_building_path(building, section:)
end

def create_path
facilities_management_rm6232_buildings_path
end

def update_path
facilities_management_rm6232_building_path(@building, section: section)
facilities_management_rm6232_building_path(@building, section:)
end

def start_a_procurement_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def show_path(building = @building)
end

def edit_path(building, section)
edit_facilities_management_rm6232_procurement_edit_building_path(@procurement, building, section: section)
edit_facilities_management_rm6232_procurement_edit_building_path(@procurement, building, section:)
end

def create_path
facilities_management_rm6232_procurement_edit_buildings_path(@procurement)
end

def update_path
facilities_management_rm6232_procurement_edit_building_path(@procurement, @building, section: section)
facilities_management_rm6232_procurement_edit_building_path(@procurement, @building, section:)
end

def start_a_procurement_path
Expand Down
10 changes: 5 additions & 5 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ def display_label(_attribute, text, form_object_name, _id_for_label)
tag.label(text, class: 'govuk-label', for: form_object_name)
end

def govuk_form_group_with_optional_error(journey, *attributes, &block)
def govuk_form_group_with_optional_error(journey, *attributes, &)
attributes_with_errors = attributes.select { |a| journey.errors[a].any? }

css_classes = ['govuk-form-group']
css_classes += ['govuk-form-group--error'] if attributes_with_errors.any?

tag.div(class: css_classes, &block)
tag.div(class: css_classes, &)
end

def govuk_fieldset_with_optional_error(journey, *attributes, &block)
def govuk_fieldset_with_optional_error(journey, *attributes, &)
attributes_with_errors = attributes.select { |a| journey.errors[a].any? }

options = { class: 'govuk-fieldset' }
options['aria-describedby'] = attributes_with_errors.map { |a| error_id(a) } if attributes_with_errors.any?

tag.fieldset(**options, &block)
tag.fieldset(**options, &)
end

def list_potential_errors(model_object, attribute, form_object_name, error_lookup = nil, error_position = nil)
Expand Down Expand Up @@ -275,7 +275,7 @@ def input_visible?(visible)
end

def search_box(placeholder_text, column = 0)
text_field_tag 'fm-table-filter-input', nil, class: 'govuk-input', placeholder: placeholder_text, data: { column: column }
text_field_tag 'fm-table-filter-input', nil, class: 'govuk-input', placeholder: placeholder_text, data: { column: }
end

def link_to_public_file_for_download(filename, file_type, text, show_doc_image, **html_options)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/facilities_management/procurements_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module ProcurementsHelper
def section_has_error?(section)
return false unless @procurement.errors.any?

(requirements_errors_list.keys & section_errors(section)).any?
requirements_errors_list.keys.intersect?(section_errors(section))
end

def section_id(section)
Expand Down
12 changes: 6 additions & 6 deletions app/helpers/gov_uk_helper/accordion.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# rubocop:disable Metrics/ModuleLength
module GovUKHelper::Accordion
def govuk_accordion(name, sections, &block)
def govuk_accordion(name, sections, &)
tag.div(class: 'govuk-accordion', id: "accordion-with-summary-sections-for-#{name}", data: { module: 'govuk-accordion' }) do
capture do
sections.each.with_index(1) do |section, index|
concat(tag.div(class: 'govuk-accordion__section') do
capture do
concat(govuk_accordion_heading(index, section[:name]))
concat(govuk_accordion_content(index, name, section, &block))
concat(govuk_accordion_content(index, name, section, &))
end
end)
end
end
end
end

def govuk_accordion_with_checkboxes(name, sections, model_name, attribute, &block)
def govuk_accordion_with_checkboxes(name, sections, model_name, attribute, &)
tag.div(class: 'govuk-accordion', id: "accordion-with-summary-sections-for-#{name}", data: { module: 'govuk-accordion' }) do
capture do
sections.each.with_index(1) do |(section_id, section), index|
concat(tag.div(class: 'govuk-accordion__section chooser-section', data: { section: section_id, sectionname: section[:name] }) do
capture do
concat(govuk_accordion_heading(index, section[:name]))
concat(govuk_accordion_content(index, section[:name], section) do
check_boxes_for_section(section_id, model_name, attribute, section[:name], section[:items], &block)
check_boxes_for_section(section_id, model_name, attribute, section[:name], section[:items], &)
end)
end
end)
Expand All @@ -48,15 +48,15 @@ def govuk_accordion_content(index, name, section, &block)
end
end

def check_boxes_for_section(section_id, model_name, attribute, section_name, items, &block)
def check_boxes_for_section(section_id, model_name, attribute, section_name, items, &)
tag.div(class: 'govuk-form-group chooser-input', sectionname: section_name, section: section_id) do
tag.div(class: 'govuk-checkboxes') do
capture do
items.each do |item|
concat(tag.div(class: 'govuk-checkboxes__item') do
capture do
concat(check_box_item(section_id, model_name, attribute, item))
concat(check_box_label(section_id, model_name, item, &block))
concat(check_box_label(section_id, model_name, item, &))
end
end)
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/gov_uk_helper/details.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module GovUKHelper::Details
def govuk_details(summary_text, **options, &block)
def govuk_details(summary_text, **options, &)
govuk_details_class = ['govuk-details']
govuk_details_class << options.delete(:class) if options[:class]

tag.details(class: govuk_details_class, data: { module: 'govuk-details' }, **options) do
capture do
concat(tag.summary(tag.span(summary_text, class: 'govuk-details__summary-text'), class: 'govuk-details__summary'))
concat(tag.div(class: 'govuk-details__text', &block))
concat(tag.div(class: 'govuk-details__text', &))
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/gov_uk_helper/notification_banner.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module GovUKHelper::NotificationBanner
def govuk_notification_banner(type, heading, &block)
def govuk_notification_banner(type, heading, &)
tag.div(class: "govuk-notification-banner #{BANNER_TYPE[type][:class]}", role: 'region', aria: { labelledby: 'govuk-notification-banner-title' }, data: { module: 'govuk-notification-banner' }) do
capture do
concat(tag.div(class: 'govuk-notification-banner__header') do
Expand All @@ -8,7 +8,7 @@ def govuk_notification_banner(type, heading, &block)
concat(tag.div(class: 'govuk-notification-banner__content') do
capture do
concat(tag.p(heading, class: 'govuk-notification-banner__heading'))
concat(tag.p(class: 'govuk-body', &block)) if block_given?
concat(tag.p(class: 'govuk-body', &)) if block_given?
end
end)
end
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/gov_uk_helper/radios.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module GovUKHelper::Radios
def govuk_radios_conditional(&block)
tag.div(class: 'govuk-radios govuk-radios--conditional', data: { module: 'govuk-radios' }, &block)
def govuk_radios_conditional(&)
tag.div(class: 'govuk-radios govuk-radios--conditional', data: { module: 'govuk-radios' }, &)
end

def govuk_radios_conditional_item(form, attribute, value, label_text)
Expand All @@ -13,11 +13,11 @@ def govuk_radios_conditional_item(form, attribute, value, label_text)
end
end

def govuk_radios_conditional_area(attribute, value, **options, &block)
def govuk_radios_conditional_area(attribute, value, **options, &)
class_list = ['govuk-radios__conditional govuk-radios__conditional--hidden']
class_list << options.delete(:class)

tag.div(class: class_list.compact.join(' '), id: govuk_radios_conditional_id(attribute, value), **options, &block)
tag.div(class: class_list.compact.join(' '), id: govuk_radios_conditional_id(attribute, value), **options, &)
end

def govuk_radios_conditional_id(attribute, value)
Expand Down
18 changes: 9 additions & 9 deletions app/helpers/layout_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def contained_content(caption, &block)
end
end

def govuk_grouped_field(form, caption, attribute, header_text = '', &block)
def govuk_grouped_field(form, caption, attribute, header_text = '', &)
attribute_has_errors = form.object.errors[attribute].any?

options = {}
Expand All @@ -149,9 +149,9 @@ def govuk_grouped_field(form, caption, attribute, header_text = '', &block)
options[:class] = css_classes

if attribute_has_errors
tag.div(fieldset_structure(form, caption, options, header_text, attribute, &block), class: 'govuk-form-group govuk-form-group--error')
tag.div(fieldset_structure(form, caption, options, header_text, attribute, &), class: 'govuk-form-group govuk-form-group--error')
else
fieldset_structure(form, caption, options, header_text, attribute, &block)
fieldset_structure(form, caption, options, header_text, attribute, &)
end
end

Expand Down Expand Up @@ -225,21 +225,21 @@ def label_details(form, attribute, label_text, hint)
end
end

def numbered_list_helper(heading, &block)
def numbered_list_helper(heading, &)
capture do
concat(tag.h2(heading, class: 'govuk-heading-m govuk-!-font-weight-bold govuk-!-margin-bottom-2'))
concat(tag.div(class: 'govuk-body govuk-!-padding-left-5', &block))
concat(tag.div(class: 'govuk-body govuk-!-padding-left-5', &))
end
end

def ccs_account_panel_row(**options, &block)
def ccs_account_panel_row(**options, &)
class_list = ['govuk-grid-row govuk-!-margin-bottom-6 fm-buyer-account-panel__container']
class_list << options.delete(:class)

tag.div(class: class_list, **options, &block)
tag.div(class: class_list, **options, &)
end

def ccs_account_panel(title, title_url, **options, &block)
def ccs_account_panel(title, title_url, **options, &)
class_list = ['govuk-grid-column-one-third fm-buyer-account-panel']
class_list << options.delete(:class)

Expand All @@ -248,7 +248,7 @@ def ccs_account_panel(title, title_url, **options, &block)
concat(tag.p do
link_to(title, title_url, class: 'ccs-font-weight-semi-bold fm-buyer-account-panel__title_no_link govuk-!-margin-bottom-2 govuk-link--no-visited-state')
end)
concat(tag.p(class: 'govuk-!-top-padding-4', &block))
concat(tag.p(class: 'govuk-!-top-padding-4', &))
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def extension_period_end_date(extension)
end

def call_off_extension(extension)
call_off_extensions.find_by(extension: extension)
call_off_extensions.find_by(extension:)
end

def build_call_off_extensions
4.times do |extension|
call_off_extensions.find_or_initialize_by(extension: extension)
call_off_extensions.find_or_initialize_by(extension:)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def non_zero_rate
end

def priced_at_framework(code, standard)
find_by(code: code, standard: standard)&.framework.present?
find_by(code:, standard:)&.framework.present?
end

# read in the benchmark and framework rates - these were taken from the Damolas spreadsheet and put in the postgres database numbers are to 15dp
Expand All @@ -41,8 +41,8 @@ def read_benchmark_rates
framework_rates[code_and_standard] = row['framework'].to_f
end
{
benchmark_rates: benchmark_rates,
framework_rates: framework_rates
benchmark_rates:,
framework_rates:
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def check_contract_details_completed
end

def check_service_and_buildings_completed
if (error_list & %i[services_incomplete buildings_incomplete]).any? || !buildings_and_services_completed?
if error_list.intersect?(%i[services_incomplete buildings_incomplete]) || !buildings_and_services_completed?
errors.add(:base, :buildings_and_services_incomplete)
errors.add(:base, :service_requirements_incomplete)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def check_contract_details_completed
end

def check_service_and_buildings_completed
errors.add(:base, :buildings_and_services_incomplete) if (error_list & %i[services_incomplete buildings_incomplete]).any? || !buildings_and_services_completed?
errors.add(:base, :buildings_and_services_incomplete) if error_list.intersect?(%i[services_incomplete buildings_incomplete]) || !buildings_and_services_completed?
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def user_supplier?
end

def user_unique?
self.class.where.not(supplier_id: supplier_id).pluck(:user_id).exclude? user.id
self.class.where.not(supplier_id:).pluck(:user_id).exclude? user.id
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/facilities_management/rm3830/procurement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def services
end

def services_require_questions?
(procurement_building_service_codes & services_requiring_questions).any?
procurement_building_service_codes.intersect?(services_requiring_questions)
end

def can_be_deleted?
Expand Down
Loading

0 comments on commit 11f648f

Please sign in to comment.