diff --git a/.erb-lint.yml b/.erb_lint.yml similarity index 100% rename from .erb-lint.yml rename to .erb_lint.yml diff --git a/.rubocop.yml b/.rubocop.yml index 7bc65bbd8..4a54015a2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,7 @@ require: - rubocop-performance + +plugins: - rubocop-rails - rubocop-rspec @@ -28,3 +30,6 @@ Rails/UnknownEnv: - development - test - review + +RSpec/IndexedLet: + Enabled: false diff --git a/.ruby-version b/.ruby-version index 9cec7165a..f9892605c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.6 +3.4.4 diff --git a/Dockerfile b/Dockerfile index 281fd6ca2..88a7e6a79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.1.6-alpine3.20 as base +FROM ruby:3.4.4-alpine3.20 as base WORKDIR /app @@ -10,7 +10,7 @@ RUN apk add --update --no-cache tzdata && \ # build-base: compilation tools for bundle # yarn: node package manager # postgresql-dev: postgres driver and libraries -RUN apk add --no-cache build-base=0.5-r3 busybox=1.36.1-r29 nodejs=20.15.1-r0 yarn=1.22.22-r0 bash=5.2.26-r0 libpq-dev +RUN apk add --no-cache build-base=0.5-r3 busybox=1.36.1-r29 nodejs=20.15.1-r0 yarn=1.22.22-r0 bash=5.2.26-r0 libpq-dev yaml-dev linux-headers # Bundler version should be the same version as what the Gemfile.lock was bundled with RUN gem install bundler:2.6.4 --no-document diff --git a/Gemfile b/Gemfile index f6e7fdac5..91ed6c8a8 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "3.1.6" +ruby "3.4.4" # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem "rails", "~> 7.2.2" @@ -51,7 +51,7 @@ gem "paper_trail-globalid" gem "pundit" # Request rate limiting -gem "rack", ">= 2.2.6.3" +gem "rack", "~> 3.1.20" gem "rack-attack" gem "redis", "~> 4.8" # Receive exceptions and configure alerts @@ -72,9 +72,12 @@ gem "sidekiq-cron" gem "unread" # Pinning versions to address vulnerabilities -gem "nokogiri", "~> 1.18.9" +gem "nokogiri", "~> 1.19.1" gem "thor", "~> 1.4.0" +# Pinning until activesupport is updated to v8.1.2 +gem "connection_pool", "~> 2.5" + group :development, :test do # Check gems for known vulnerabilities gem "bundler-audit" @@ -95,7 +98,7 @@ group :development do # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md gem "erb_lint", require: false gem "rack-mini-profiler", "~> 3.3.0" - gem "rubocop-govuk", "4.3.0", require: false + gem "rubocop-govuk", "5.2.0", require: false gem "rubocop-performance", require: false gem "rubocop-rails", require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 34bfd3067..4277b9499 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,7 +78,7 @@ GEM tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) - ast (2.4.2) + ast (2.4.3) auto_strip_attributes (2.6.0) activerecord (>= 4.0) aws-eventstream (1.4.0) @@ -113,15 +113,15 @@ GEM thread_safe (~> 0.3, >= 0.3.1) base64 (0.3.0) bcrypt (3.1.20) - benchmark (0.4.1) - better_html (2.0.2) - actionview (>= 6.0) - activesupport (>= 6.0) + benchmark (0.5.0) + better_html (2.2.0) + actionview (>= 7.0) + activesupport (>= 7.0) ast (~> 2.0) erubi (~> 1.4) parser (>= 2.4) smart_properties - bigdecimal (3.2.2) + bigdecimal (4.0.1) bindex (0.8.1) bootsnap (1.18.3) msgpack (~> 1.2) @@ -151,7 +151,7 @@ GEM coderay (1.1.3) coercible (1.0.0) descendants_tracker (~> 0.0.1) - concurrent-ruby (1.3.5) + concurrent-ruby (1.3.6) connection_pool (2.5.3) crack (1.0.0) bigdecimal @@ -184,12 +184,12 @@ GEM drb (2.2.3) dumb_delegator (1.0.0) encryptor (3.0.0) - erb_lint (0.5.0) + erb_lint (0.9.0) activesupport better_html (>= 2.0.1) parser (>= 2.7.1.4) rainbow - rubocop + rubocop (>= 1) smart_properties erubi (1.13.1) et-orbi (1.2.11) @@ -232,7 +232,7 @@ GEM hashdiff (1.1.0) html-attributes-utils (1.0.2) activesupport (>= 6.1.4.4) - i18n (1.14.7) + i18n (1.14.8) concurrent-ruby (~> 1.0) ice_nine (0.11.2) iniparse (1.5.0) @@ -261,13 +261,15 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) + language_server-protocol (3.17.0.5) launchy (2.5.2) addressable (~> 2.8) + lint_roller (1.1.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) - loofah (2.24.0) + loofah (2.25.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -279,7 +281,9 @@ GEM matrix (0.4.2) method_source (1.1.0) mini_mime (1.1.5) - minitest (5.25.5) + minitest (6.0.2) + drb (~> 2.0) + prism (~> 1.5) msgpack (1.7.2) multipart-post (2.4.1) nested_form (0.3.2) @@ -295,13 +299,13 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) - nokogiri (1.18.9-arm64-darwin) + nokogiri (1.19.1-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.9-x86_64-darwin) + nokogiri (1.19.1-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.9-x86_64-linux-gnu) + nokogiri (1.19.1-x86_64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.9-x86_64-linux-musl) + nokogiri (1.19.1-x86_64-linux-musl) racc (~> 1.4) notifications-ruby-client (6.0.0) jwt (>= 1.5, < 3) @@ -317,10 +321,10 @@ GEM paper_trail-globalid (0.2.0) globalid paper_trail (>= 3.0.0) - parallel (1.24.0) + parallel (1.27.0) parallel_tests (4.5.1) parallel - parser (3.3.0.5) + parser (3.3.10.2) ast (~> 2.4.1) racc pg (1.5.5) @@ -328,6 +332,7 @@ GEM pp (0.6.2) prettyprint prettyprint (0.2.0) + prism (1.9.0) propshaft (0.8.0) actionpack (>= 7.0.0) activesupport (>= 7.0.0) @@ -349,7 +354,7 @@ GEM activesupport (>= 3.0.0) raabro (1.4.0) racc (1.8.1) - rack (3.1.18) + rack (3.1.20) rack-attack (6.7.0) rack (>= 1.0, < 4) rack-mini-profiler (3.3.1) @@ -375,7 +380,7 @@ GEM activesupport (= 7.2.2.2) bundler (>= 1.15.0) railties (= 7.2.2.2) - rails-dom-testing (2.2.0) + rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) @@ -409,7 +414,7 @@ GEM redis (4.8.1) redis-client (0.22.1) connection_pool - regexp_parser (2.9.0) + regexp_parser (2.11.3) reline (0.6.0) io-console (~> 0.5) request_store (1.7.0) @@ -439,34 +444,45 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) rspec-support (3.13.1) - rubocop (1.25.0) + rubocop (1.82.1) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.15.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.48.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.1) - parser (>= 3.0.1.1) - rubocop-govuk (4.3.0) - rubocop (= 1.25.0) - rubocop-ast (= 1.15.1) - rubocop-rails (= 2.13.2) - rubocop-rake (= 0.6.0) - rubocop-rspec (= 2.7.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.49.0) + parser (>= 3.3.7.2) + prism (~> 1.7) + rubocop-capybara (2.22.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-govuk (5.2.0) + rubocop (= 1.82.1) + rubocop-ast (= 1.49.0) + rubocop-capybara (= 2.22.1) + rubocop-rails (= 2.34.3) + rubocop-rake (= 0.7.1) + rubocop-rspec (= 3.9.0) rubocop-performance (1.19.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.13.2) + rubocop-rails (2.34.3) activesupport (>= 4.2.0) + lint_roller (~> 1.1) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-rake (0.6.0) - rubocop (~> 1.0) - rubocop-rspec (2.7.0) - rubocop (~> 1.19) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rake (0.7.1) + lint_roller (~> 1.1) + rubocop (>= 1.72.1) + rubocop-rspec (3.9.0) + lint_roller (~> 1.1) + rubocop (~> 1.81) ruby-openai (7.0.1) event_stream_parser (>= 0.3.0, < 2.0.0) faraday (>= 1) @@ -514,7 +530,9 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) uk_postcode (2.1.8) - unicode-display_width (2.5.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.2.0) unread (0.14.0) activerecord (>= 6.1) uri (1.0.4) @@ -563,6 +581,7 @@ DEPENDENCIES capybara capybara-lockstep capybara-screenshot + connection_pool (~> 2.5) cssbundling-rails devise devise_two_factor_authentication @@ -579,7 +598,7 @@ DEPENDENCIES json-schema listen (~> 3.3) method_source (~> 1.1) - nokogiri (~> 1.18.9) + nokogiri (~> 1.19.1) notifications-ruby-client overcommit (>= 0.37.0) paper_trail (~> 15.2) @@ -591,7 +610,7 @@ DEPENDENCIES pry-byebug puma (~> 6.4) pundit - rack (>= 2.2.6.3) + rack (~> 3.1.20) rack-attack rack-mini-profiler (~> 3.3.0) rails (~> 7.2.2) @@ -600,7 +619,7 @@ DEPENDENCIES redis (~> 4.8) roo rspec-rails - rubocop-govuk (= 4.3.0) + rubocop-govuk (= 5.2.0) rubocop-performance rubocop-rails ruby-openai @@ -621,7 +640,7 @@ DEPENDENCIES webmock RUBY VERSION - ruby 3.1.6p260 + ruby 3.4.4p0 BUNDLED WITH 2.6.4 diff --git a/app/controllers/csv_downloads_controller.rb b/app/controllers/csv_downloads_controller.rb index 25f70026f..e2a7fb4f1 100644 --- a/app/controllers/csv_downloads_controller.rb +++ b/app/controllers/csv_downloads_controller.rb @@ -5,7 +5,7 @@ class CsvDownloadsController < ApplicationController @csv_download = CsvDownload.find(params[:id]) authorize @csv_download - return render "errors/download_link_expired" if @csv_download.expired? + render "errors/download_link_expired" if @csv_download.expired? end def download diff --git a/app/controllers/lettings_logs_controller.rb b/app/controllers/lettings_logs_controller.rb index 38a89b682..cd2a6ca5a 100644 --- a/app/controllers/lettings_logs_controller.rb +++ b/app/controllers/lettings_logs_controller.rb @@ -190,7 +190,7 @@ private end def resolve_logs! - if @log&.unresolved && @log.location.present? && @log.scheme.present? && @log&.resolve! + if @log&.unresolved && @log.location.present? && @log.scheme.present? && @log.resolve! unresolved_logs_count_for_user = current_user.lettings_logs.unresolved.assigned_to(current_user).count flash.now[:notice] = helpers.flash_notice_for_resolved_logs(unresolved_logs_count_for_user) end diff --git a/app/controllers/lettings_logs_filters_controller.rb b/app/controllers/lettings_logs_filters_controller.rb index 9180737d3..c6ea0ba70 100644 --- a/app/controllers/lettings_logs_filters_controller.rb +++ b/app/controllers/lettings_logs_filters_controller.rb @@ -52,8 +52,6 @@ class LettingsLogsFiltersController < ApplicationController end end -private - def lettings_session_filters params["years"] = [params["years"]] if params["years"].present? lettings_filter_manager.session_filters diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index 32f7b2d0c..f1878e9ab 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -105,7 +105,7 @@ private answer_options = { "" => "Select an option" } if current_user.support? - Organisation.all.each do |organisation| + Organisation.all.find_each do |organisation| date = @merge_request.merge_date || Time.zone.today answer_options[organisation.id] = organisation.name(date:) end diff --git a/app/controllers/sales_logs_filters_controller.rb b/app/controllers/sales_logs_filters_controller.rb index ffa4f4bc4..70a4c2b49 100644 --- a/app/controllers/sales_logs_filters_controller.rb +++ b/app/controllers/sales_logs_filters_controller.rb @@ -53,8 +53,6 @@ class SalesLogsFiltersController < ApplicationController end end -private - def sales_session_filters params["years"] = [params["years"]] if params["years"].present? sales_filter_manager.session_filters diff --git a/app/helpers/bulk_upload/lettings_log_to_csv.rb b/app/helpers/bulk_upload/lettings_log_to_csv.rb index 155fb9b12..18a524b0d 100644 --- a/app/helpers/bulk_upload/lettings_log_to_csv.rb +++ b/app/helpers/bulk_upload/lettings_log_to_csv.rb @@ -2,12 +2,10 @@ class BulkUpload::LettingsLogToCsv attr_reader :log, :line_ending, :col_offset, :overrides def initialize(log:, line_ending: "\n", col_offset: 1, overrides: {}) - # rubocop:disable Rails/HelperInstanceVariable @log = log @line_ending = line_ending @col_offset = col_offset @overrides = overrides - # rubocop:enable Rails/HelperInstanceVariable end def row_prefix diff --git a/app/helpers/bulk_upload/sales_log_to_csv.rb b/app/helpers/bulk_upload/sales_log_to_csv.rb index 1171f481f..30833c1c7 100644 --- a/app/helpers/bulk_upload/sales_log_to_csv.rb +++ b/app/helpers/bulk_upload/sales_log_to_csv.rb @@ -2,12 +2,10 @@ class BulkUpload::SalesLogToCsv attr_reader :log, :line_ending, :col_offset, :overrides def initialize(log:, line_ending: "\n", col_offset: 1, overrides: {}) - # rubocop:disable Rails/HelperInstanceVariable @log = log @line_ending = line_ending @col_offset = col_offset @overrides = overrides - # rubocop:enable Rails/HelperInstanceVariable end def row_prefix diff --git a/app/helpers/data_sharing_agreement_helper.rb b/app/helpers/data_sharing_agreement_helper.rb index 79296e6dc..5ab5e3272 100644 --- a/app/helpers/data_sharing_agreement_helper.rb +++ b/app/helpers/data_sharing_agreement_helper.rb @@ -67,7 +67,7 @@ module DataSharingAgreementHelper "12.2. For #{@org_name}: Name: #{@dpo_name}, Postal Address: #{@org_address}, E-mail address: #{@dpo_email}, Telephone number: #{@org_phone}" end end -# rubocop:enable Rails/HelperInstanceVariable + # rubocop:enable Rails/HelperInstanceVariable private diff --git a/app/helpers/form_page_error_helper.rb b/app/helpers/form_page_error_helper.rb index ded09d54c..c2ce87310 100644 --- a/app/helpers/form_page_error_helper.rb +++ b/app/helpers/form_page_error_helper.rb @@ -5,7 +5,7 @@ module FormPageErrorHelper end def remove_duplicate_page_errors(lettings_log) - lettings_log.errors.group_by(&:message).each do |_, errors| + lettings_log.errors.group_by(&:message).each_value do |errors| next if errors.size == 1 errors.shift diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb index 9ef74ca51..b8a111b0c 100644 --- a/app/helpers/locations_helper.rb +++ b/app/helpers/locations_helper.rb @@ -91,7 +91,8 @@ module LocationsHelper def toggle_location_link(location) return govuk_button_link_to "Deactivate this location", scheme_location_new_deactivation_path(location.scheme, location), warning: true if location.active? || location.deactivates_in_a_long_time? - return govuk_button_link_to "Reactivate this location", scheme_location_new_reactivation_path(location.scheme, location) if location.deactivated? && !location.deactivated_by_scheme? + + govuk_button_link_to "Reactivate this location", scheme_location_new_reactivation_path(location.scheme, location) if location.deactivated? && !location.deactivated_by_scheme? end def delete_location_link(location) diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 3d9577ce9..6755b4646 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -101,13 +101,13 @@ module MergeRequestsHelper attribute = page if attribute.nil? return nil unless value_exists?(merge_request, attribute) - unless merge_request.status == "request_merged" || merge_request.status == "processing" + unless %w[request_merged processing].include?(merge_request.status) { text: merge_request_action_text(merge_request, attribute), href: send("#{page}_merge_request_path", merge_request, referrer: "check_answers"), visually_hidden_text: page.humanize } end end def merge_outcome_action(merge_request, page) - unless merge_request.status == "request_merged" || merge_request.status == "processing" + unless %w[request_merged processing].include?(merge_request.status) { text: "View", href: send("#{page}_merge_request_path", merge_request), visually_hidden_text: page.humanize } end end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 318918134..d3a369b45 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -57,7 +57,7 @@ class NotificationRenderer < Redcarpet::Render::HTML def initialize(options = {}) link_class = "govuk-link" link_class += " govuk-link--inverse" if options[:invert_link_colour] - @bold = options[:bold_all_text] # rubocop:disable Rails/HelperInstanceVariable + @bold = options[:bold_all_text] base_options = { escape_html: true, safe_links_only: true, link_attributes: { class: link_class } } super base_options end @@ -78,7 +78,7 @@ class NotificationRenderer < Redcarpet::Render::HTML end def paragraph(text) - return %(

#{text}

) if @bold # rubocop:disable Rails/HelperInstanceVariable + return %(

#{text}

) if @bold %(

#{text}

) end diff --git a/app/helpers/question_view_helper.rb b/app/helpers/question_view_helper.rb index acb4fa959..0c4b6337f 100644 --- a/app/helpers/question_view_helper.rb +++ b/app/helpers/question_view_helper.rb @@ -44,7 +44,8 @@ module QuestionViewHelper def select_option_name(value) return value.service_name if value.respond_to?(:service_name) return value["name"] if value.is_a?(Hash) && value["name"].present? - return value["postcode"] if value.is_a?(Location) + + value["postcode"] if value.is_a?(Location) end private diff --git a/app/helpers/schemes_helper.rb b/app/helpers/schemes_helper.rb index 753f33917..e72250c6e 100644 --- a/app/helpers/schemes_helper.rb +++ b/app/helpers/schemes_helper.rb @@ -12,7 +12,8 @@ module SchemesHelper def toggle_scheme_link(scheme) return govuk_button_link_to "Deactivate this scheme", scheme_new_deactivation_path(scheme), warning: true if scheme.active? || scheme.deactivates_in_a_long_time? - return govuk_button_link_to "Reactivate this scheme", scheme_new_reactivation_path(scheme) if scheme.deactivated? || scheme.deactivating_soon? + + govuk_button_link_to "Reactivate this scheme", scheme_new_reactivation_path(scheme) if scheme.deactivated? || scheme.deactivating_soon? end def delete_scheme_link(scheme) diff --git a/app/mailers/devise_notify_mailer.rb b/app/mailers/devise_notify_mailer.rb index 5ee3fd898..4065e3aa9 100644 --- a/app/mailers/devise_notify_mailer.rb +++ b/app/mailers/devise_notify_mailer.rb @@ -92,8 +92,7 @@ class DeviseNotifyMailer < Devise::Mailer def email_changed?(record) ( - record.confirmable_template == User::CONFIRMABLE_TEMPLATE_ID && ( - record.unconfirmed_email.present? && record.unconfirmed_email != record.email) + record.confirmable_template == User::CONFIRMABLE_TEMPLATE_ID && record.unconfirmed_email.present? && record.unconfirmed_email != record.email ) || ( record.versions.last.changeset.key?("unconfirmed_email") && record.confirmed? diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index 19a58d916..6c88c3221 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -254,7 +254,7 @@ private def clear_inapplicable_derived_values! reset_invalidated_derived_values!(dependencies) - if (startdate_changed? || renewal_changed?) && (renewal_was == 1 && startdate_was&.between?(Time.zone.local(2021, 4, 1), Time.zone.local(2022, 3, 31))) + if (startdate_changed? || renewal_changed?) && renewal_was == 1 && startdate_was&.between?(Time.zone.local(2021, 4, 1), Time.zone.local(2022, 3, 31)) self.underoccupation_benefitcap = nil end if renewal_changed? && renewal_was == 1 @@ -270,7 +270,7 @@ private self.wchair = nil self.location_id = nil end - if form.start_year_2024_or_later? && (unittype_gn_changed? && unittype_gn_was == 2) + if form.start_year_2024_or_later? && unittype_gn_changed? && unittype_gn_was == 2 self.beds = nil end end @@ -439,13 +439,15 @@ private def get_lar return 1 if rent_type == 2 - return 2 if rent_type == 1 + + 2 if rent_type == 1 end def get_irproduct return 1 if rent_type == 3 return 2 if rent_type == 4 - return 3 if rent_type == 5 + + 3 if rent_type == 5 end def clear_gender_description_unless_gender_not_same_as_sex! diff --git a/app/models/derived_variables/shared_logic.rb b/app/models/derived_variables/shared_logic.rb index c326cb8c9..4b76d83d8 100644 --- a/app/models/derived_variables/shared_logic.rb +++ b/app/models/derived_variables/shared_logic.rb @@ -9,7 +9,7 @@ private previously_in_derived_state = dependency[:conditions].all? { |attribute, value| send("#{attribute}_was") == value } next unless previously_in_derived_state - dependency[:derived_values].each do |derived_attribute, _derived_value| + dependency[:derived_values].each_key do |derived_attribute| Rails.logger.debug("Cleared derived #{derived_attribute} value") send("#{derived_attribute}=", nil) end diff --git a/app/models/form/sales/pages/deposit.rb b/app/models/form/sales/pages/deposit.rb index 4fc5e1b83..411cfb270 100644 --- a/app/models/form/sales/pages/deposit.rb +++ b/app/models/form/sales/pages/deposit.rb @@ -23,6 +23,7 @@ class Form::Sales::Pages::Deposit < ::Form::Page def copy_key return "sales.sale_information.deposit.shared_ownership" if @ownershipsch == 1 return "sales.sale_information.deposit.discounted_ownership" if @ownershipsch == 2 - return "sales.sale_information.deposit.outright_sale" if @ownershipsch == 3 + + "sales.sale_information.deposit.outright_sale" if @ownershipsch == 3 end end diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb index 9fe7a7ce1..ede6335e1 100644 --- a/app/models/form/sales/questions/deposit_amount.rb +++ b/app/models/form/sales/questions/deposit_amount.rb @@ -29,12 +29,14 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question def top_guidance_partial return "financial_calculations_shared_ownership" if @ownershipsch == 1 return "financial_calculations_discounted_ownership" if @ownershipsch == 2 - return "financial_calculations_outright_sale" if @ownershipsch == 3 + + "financial_calculations_outright_sale" if @ownershipsch == 3 end def copy_key return "sales.sale_information.deposit.shared_ownership" if @ownershipsch == 1 return "sales.sale_information.deposit.discounted_ownership" if @ownershipsch == 2 - return "sales.sale_information.deposit.outright_sale" if @ownershipsch == 3 + + "sales.sale_information.deposit.outright_sale" if @ownershipsch == 3 end end diff --git a/app/models/form/sales/questions/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb index 0d2bda4fd..a61dce8f3 100644 --- a/app/models/form/sales/questions/mortgage_amount.rb +++ b/app/models/form/sales/questions/mortgage_amount.rb @@ -26,6 +26,7 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question def top_guidance_partial return "financial_calculations_shared_ownership" if @ownershipsch == 1 return "financial_calculations_discounted_ownership" if @ownershipsch == 2 - return "financial_calculations_outright_sale" if @ownershipsch == 3 + + "financial_calculations_outright_sale" if @ownershipsch == 3 end end diff --git a/app/models/form/sales/questions/mortgageused.rb b/app/models/form/sales/questions/mortgageused.rb index a0079b1b4..fc5818886 100644 --- a/app/models/form/sales/questions/mortgageused.rb +++ b/app/models/form/sales/questions/mortgageused.rb @@ -41,6 +41,7 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question def top_guidance_partial return "financial_calculations_shared_ownership" if @ownershipsch == 1 return "financial_calculations_discounted_ownership" if @ownershipsch == 2 - return "financial_calculations_outright_sale" if @ownershipsch == 3 + + "financial_calculations_outright_sale" if @ownershipsch == 3 end end diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb index 56810eae4..d37d549ce 100644 --- a/app/models/form/sales/questions/purchase_price.rb +++ b/app/models/form/sales/questions/purchase_price.rb @@ -30,6 +30,7 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question def top_guidance_partial return "financial_calculations_discounted_ownership" if @ownership_sch == 2 - return "financial_calculations_outright_sale" if @ownership_sch == 3 + + "financial_calculations_outright_sale" if @ownership_sch == 3 end end diff --git a/app/models/form/subsection.rb b/app/models/form/subsection.rb index 3b74e29a5..41431b06f 100644 --- a/app/models/form/subsection.rb +++ b/app/models/form/subsection.rb @@ -1,5 +1,5 @@ class Form::Subsection - attr_accessor :id, :label, :section, :pages, :depends_on, :form + attr_accessor :id, :label, :section, :pages, :depends_on def initialize(id, hsh, section) @id = id diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index c3b72fbdd..d70d0e012 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -482,7 +482,7 @@ class LettingsLog < Log def is_london_rent? # 2: London Affordable Rent # 4: London Living Rent - rent_type == 2 || rent_type == 4 + [2, 4].include?(rent_type) end def previous_tenancy_was_foster_care? @@ -714,7 +714,7 @@ class LettingsLog < Log end def affordable_or_social_rent? - renttype == 1 || renttype == 2 + [1, 2].include?(renttype) end def no_or_unknown_other_housing_needs? @@ -931,7 +931,7 @@ private num_of_weeks = NUM_OF_WEEKS_FROM_PERIOD[period] return "" unless value && num_of_weeks - format_as_currency((value * 52 / num_of_weeks)) + format_as_currency(value * 52 / num_of_weeks) end def fully_wheelchair_accessible? diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index d4d23f44d..cf9e0dd44 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -533,7 +533,7 @@ class SalesLog < Log end def is_not_staircasing? - staircase == 2 || staircase == 3 + [2, 3].include?(staircase) end def stairowned_100? diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index f34eec790..063c16599 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -136,7 +136,7 @@ module Validations::Sales::SaleInformationValidations def validate_grant_amount(record) return unless record.saledate && record.form.start_year_2024_or_later? - return unless record.grant && (record.type == 8 || record.type == 21) + return unless record.grant && [8, 21].include?(record.type) unless record.grant.between?(9_000, 16_000) record.errors.add :grant, I18n.t("validations.sales.sale_information.grant.out_of_range") diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index 2bc574774..3569c379f 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -144,7 +144,7 @@ module Validations::Sales::SoftValidations def grant_outside_common_range? return unless grant && type && saledate - return if form.start_year_2024_or_later? && (type == 21 || type == 8) + return if form.start_year_2024_or_later? && [21, 8].include?(type) !grant.between?(9_000, 16_000) end diff --git a/app/models/validations/shared_validations.rb b/app/models/validations/shared_validations.rb index 530735213..4558a5a36 100644 --- a/app/models/validations/shared_validations.rb +++ b/app/models/validations/shared_validations.rb @@ -56,11 +56,11 @@ module Validations::SharedValidations next unless incorrect_accuracy - case question.step - when 0.01 then record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_hundredth", field:) - when 0.1 then record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_tenth", field:) - when 1 then record.errors.add question.id.to_sym, :not_integer, message: I18n.t("validations.shared.numeric.whole_number", field:) - when 10 then record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_ten", field:) + case question.step.to_d + when BigDecimal("0.01") then record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_hundredth", field:) + when BigDecimal("0.1") then record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_tenth", field:) + when BigDecimal("1") then record.errors.add question.id.to_sym, :not_integer, message: I18n.t("validations.shared.numeric.whole_number", field:) + when BigDecimal("10") then record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_ten", field:) else record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_step", field:, step: question.step) end diff --git a/app/policies/location_policy.rb b/app/policies/location_policy.rb index 3b4a22131..966cfe35c 100644 --- a/app/policies/location_policy.rb +++ b/app/policies/location_policy.rb @@ -32,7 +32,7 @@ class LocationPolicy def delete? return false unless user.support? - return false unless location.status == :incomplete || location.status == :deactivated + return false unless %i[incomplete deactivated].include?(location.status) !has_any_logs_in_editable_collection_period end diff --git a/app/policies/organisation_policy.rb b/app/policies/organisation_policy.rb index 9c5fc4449..4db37b5ea 100644 --- a/app/policies/organisation_policy.rb +++ b/app/policies/organisation_policy.rb @@ -20,7 +20,7 @@ class OrganisationPolicy def delete? return false unless user.support? - return false unless organisation.status == :deactivated || organisation.status == :merged + return false unless %i[deactivated merged].include?(organisation.status) !has_any_logs_in_editable_collection_period end diff --git a/app/policies/scheme_policy.rb b/app/policies/scheme_policy.rb index 54a2b9e89..6fa9ac95a 100644 --- a/app/policies/scheme_policy.rb +++ b/app/policies/scheme_policy.rb @@ -71,7 +71,7 @@ class SchemePolicy def delete? return false unless user.support? - return false unless scheme.status == :incomplete || scheme.status == :deactivated + return false unless %i[incomplete deactivated].include?(scheme.status) !has_any_logs_in_editable_collection_period end diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index 70aa4951e..1e8b9db56 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -536,7 +536,7 @@ private end def validate_valid_radio_option - log.attributes.each do |question_id, _v| + log.attributes.each_key do |question_id| question = log.form.get_question(question_id, log) next unless question&.type == "radio" @@ -1321,22 +1321,26 @@ private def scheme_field return :field_16 if log_uses_new_scheme_id? - return :field_15 if log_uses_old_scheme_id? + + :field_15 if log_uses_old_scheme_id? end def scheme_id return field_16.strip if log_uses_new_scheme_id? - return field_15 if log_uses_old_scheme_id? + + field_15 if log_uses_old_scheme_id? end def location_field return :field_17 if log_uses_new_scheme_id? - return :field_16 if log_uses_old_scheme_id? + + :field_16 if log_uses_old_scheme_id? end def location_id return field_17 if log_uses_new_scheme_id? - return field_16 if log_uses_old_scheme_id? + + field_16 if log_uses_old_scheme_id? end def scheme_or_management_group @@ -1424,7 +1428,8 @@ private ].each do |hash| define_method("age#{hash[:person]}_known?") do return 1 if public_send(hash[:field]) == "R" - return 0 if send("person_#{hash[:person]}_present?") + + 0 if send("person_#{hash[:person]}_present?") end end @@ -1488,7 +1493,8 @@ private def housingneeds_other return 1 if field_86 == 1 - return 0 if [field_83, field_84, field_85].include?(1) + + 0 if [field_83, field_84, field_85].include?(1) end def prevloc @@ -1555,7 +1561,7 @@ private end def earnings - field_122.round if field_122.present? + field_122.presence&.round end def tshortfall_known diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 66d46ead5..1ba683f66 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -562,7 +562,7 @@ class BulkUpload::Lettings::Year2024::RowParser private def validate_valid_radio_option - log.attributes.each do |question_id, _v| + log.attributes.each_key do |question_id| question = log.form.get_question(question_id, log) next unless question&.type == "radio" @@ -1455,7 +1455,8 @@ private ].each do |hash| define_method("age#{hash[:person]}_known?") do return 1 if public_send(hash[:field]) == "R" - return 0 if send("person_#{hash[:person]}_present?") + + 0 if send("person_#{hash[:person]}_present?") end end @@ -1519,7 +1520,8 @@ private def housingneeds_other return 1 if field_82 == 1 - return 0 if [field_79, field_80, field_81].include?(1) + + 0 if [field_79, field_80, field_81].include?(1) end def prevloc @@ -1595,7 +1597,7 @@ private end def earnings - field_119.round if field_119.present? + field_119.presence&.round end def tshortfall_known diff --git a/app/services/bulk_upload/lettings/year2025/row_parser.rb b/app/services/bulk_upload/lettings/year2025/row_parser.rb index 0745056d2..9887c42be 100644 --- a/app/services/bulk_upload/lettings/year2025/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2025/row_parser.rb @@ -561,7 +561,7 @@ class BulkUpload::Lettings::Year2025::RowParser private def validate_valid_radio_option - log.attributes.each do |question_id, _v| + log.attributes.each_key do |question_id| question = log.form.get_question(question_id, log) next unless question&.type == "radio" @@ -1452,7 +1452,8 @@ private ].each do |hash| define_method("age#{hash[:person]}_known?") do return 1 if public_send(hash[:field]) == "R" - return 0 if send("person_#{hash[:person]}_present?") + + 0 if send("person_#{hash[:person]}_present?") end end @@ -1516,7 +1517,8 @@ private def housingneeds_other return 1 if field_82 == 1 - return 0 if [field_79, field_80, field_81].include?(1) + + 0 if [field_79, field_80, field_81].include?(1) end def prevloc @@ -1592,7 +1594,7 @@ private end def earnings - field_119.round if field_119.present? + field_119.presence&.round end def tshortfall_known diff --git a/app/services/bulk_upload/lettings/year2026/row_parser.rb b/app/services/bulk_upload/lettings/year2026/row_parser.rb index b73bf792a..c8fc4c891 100644 --- a/app/services/bulk_upload/lettings/year2026/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2026/row_parser.rb @@ -606,7 +606,7 @@ class BulkUpload::Lettings::Year2026::RowParser private def validate_valid_radio_option - log.attributes.each do |question_id, _v| + log.attributes.each_key do |question_id| question = log.form.get_question(question_id, log) next unless question&.type == "radio" @@ -1573,7 +1573,8 @@ private ].each do |hash| define_method("age#{hash[:person]}_known?") do return 1 if public_send(hash[:field]) == "R" - return 0 if send("person_#{hash[:person]}_present?") + + 0 if send("person_#{hash[:person]}_present?") end end @@ -1637,7 +1638,8 @@ private def housingneeds_other return 1 if field_82 == 1 - return 0 if [field_79, field_80, field_81].include?(1) + + 0 if [field_79, field_80, field_81].include?(1) end def prevloc @@ -1713,7 +1715,7 @@ private end def earnings - field_119.round if field_119.present? + field_119.presence&.round end def tshortfall_known diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index ddcf18b6a..75f964e7c 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -915,7 +915,7 @@ private attributes["mortlen"] = mortlen attributes["proplen"] = proplen if proplen&.positive? - attributes["proplen_asked"] = attributes["proplen"]&.present? ? 0 : 1 + attributes["proplen_asked"] = attributes["proplen"].present? ? 0 : 1 attributes["jointmore"] = field_15 attributes["staircase"] = field_87 attributes["privacynotice"] = field_29 @@ -992,7 +992,8 @@ private ].each do |hash| define_method("age#{hash[:person]}_known?") do return 1 if public_send(hash[:field]) == "R" - return 0 if send("person_#{hash[:person]}_present?") + + 0 if send("person_#{hash[:person]}_present?") end end @@ -1050,72 +1051,84 @@ private def sale_type return field_8 if shared_ownership? return field_9 if discounted_ownership? - return field_10 if outright_sale? + + field_10 if outright_sale? end def value return field_103 if shared_ownership? return field_116 if discounted_ownership? - return field_127 if outright_sale? + + field_127 if outright_sale? end def mortgage return field_106 if shared_ownership? return field_120 if discounted_ownership? - return field_129 if outright_sale? + + field_129 if outright_sale? end def extrabor return field_110 if shared_ownership? return field_124 if discounted_ownership? - return field_133 if outright_sale? + + field_133 if outright_sale? end def deposit return field_111 if shared_ownership? return field_125 if discounted_ownership? - return field_134 if outright_sale? + + field_134 if outright_sale? end def mscharge return field_114 if shared_ownership? return field_126 if discounted_ownership? - return field_135 if outright_sale? + + field_135 if outright_sale? end def mortgagelender return field_107 if shared_ownership? return field_121 if discounted_ownership? - return field_130 if outright_sale? + + field_130 if outright_sale? end def mortgagelenderother return field_108 if shared_ownership? return field_122 if discounted_ownership? - return field_131 if outright_sale? + + field_131 if outright_sale? end def mortlen return field_109 if shared_ownership? return field_123 if discounted_ownership? - return field_132 if outright_sale? + + field_132 if outright_sale? end def proplen return field_86 if shared_ownership? - return field_115 if discounted_ownership? + + field_115 if discounted_ownership? end def mortgageused return field_105 if shared_ownership? return field_119 if discounted_ownership? - return field_128 if outright_sale? + + field_128 if outright_sale? end def mortgageused_field return :field_105 if shared_ownership? return :field_119 if discounted_ownership? - return :field_128 if outright_sale? + + :field_128 if outright_sale? end def owning_organisation @@ -1263,7 +1276,7 @@ private end def validate_valid_radio_option - log.attributes.each do |question_id, _v| + log.attributes.each_key do |question_id| question = log.form.get_question(question_id, log) next if question_id == "type" diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index a1b214182..879bdbb3f 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -938,7 +938,7 @@ private attributes["mortlen"] = mortlen attributes["proplen"] = proplen if proplen&.positive? - attributes["proplen_asked"] = attributes["proplen"]&.present? ? 0 : 1 + attributes["proplen_asked"] = attributes["proplen"].present? ? 0 : 1 attributes["jointmore"] = field_16 attributes["staircase"] = field_86 attributes["privacynotice"] = field_18 @@ -1026,7 +1026,8 @@ private ].each do |hash| define_method("age#{hash[:person]}_known?") do return 1 if public_send(hash[:field]) == "R" - return 0 if send("person_#{hash[:person]}_present?") + + 0 if send("person_#{hash[:person]}_present?") end end @@ -1084,64 +1085,75 @@ private def sale_type return field_9 if shared_ownership? return field_10 if discounted_ownership? - return field_11 if outright_sale? + + field_11 if outright_sale? end def value return field_101 if shared_ownership? return field_114 if discounted_ownership? - return field_125 if outright_sale? + + field_125 if outright_sale? end def mortgage return field_104 if shared_ownership? return field_118 if discounted_ownership? - return field_127 if outright_sale? + + field_127 if outright_sale? end def extrabor return field_108 if shared_ownership? return field_122 if discounted_ownership? - return field_129 if outright_sale? + + field_129 if outright_sale? end def deposit return field_109 if shared_ownership? return field_123 if discounted_ownership? - return field_130 if outright_sale? + + field_130 if outright_sale? end def mscharge return field_112 if shared_ownership? return field_124 if discounted_ownership? - return field_131 if outright_sale? + + field_131 if outright_sale? end def mortgagelender return field_105 if shared_ownership? - return field_119 if discounted_ownership? + + field_119 if discounted_ownership? end def mortgagelenderother return field_106 if shared_ownership? - return field_120 if discounted_ownership? + + field_120 if discounted_ownership? end def mortlen return field_107 if shared_ownership? return field_121 if discounted_ownership? - return field_128 if outright_sale? + + field_128 if outright_sale? end def proplen return field_85 if shared_ownership? - return field_113 if discounted_ownership? + + field_113 if discounted_ownership? end def mortgageused return field_103 if shared_ownership? return field_117 if discounted_ownership? - return field_126 if outright_sale? + + field_126 if outright_sale? end def value_fields @@ -1393,7 +1405,7 @@ private end def validate_valid_radio_option - log.attributes.each do |question_id, _v| + log.attributes.each_key do |question_id| question = log.form.get_question(question_id, log) next if question_id == "type" diff --git a/app/services/bulk_upload/sales/year2025/row_parser.rb b/app/services/bulk_upload/sales/year2025/row_parser.rb index a78b9fe5d..19094f6c6 100644 --- a/app/services/bulk_upload/sales/year2025/row_parser.rb +++ b/app/services/bulk_upload/sales/year2025/row_parser.rb @@ -906,7 +906,7 @@ private attributes["mortlen"] = mortlen attributes["proplen"] = proplen if proplen&.positive? - attributes["proplen_asked"] = attributes["proplen"]&.present? ? 0 : 1 + attributes["proplen_asked"] = attributes["proplen"].present? ? 0 : 1 attributes["jointmore"] = field_13 attributes["staircase"] = field_10 attributes["privacynotice"] = field_15 @@ -1008,7 +1008,8 @@ private ].each do |hash| define_method("age#{hash[:person]}_known?") do return 1 if public_send(hash[:field]) == "R" - return 0 if send("person_#{hash[:person]}_present?") + + 0 if send("person_#{hash[:person]}_present?") end end @@ -1076,58 +1077,68 @@ private def sale_type return field_9 if shared_ownership? - return field_11 if discounted_ownership? + + field_11 if discounted_ownership? end def value return field_86 if shared_ownership_initial_purchase? return field_113 if discounted_ownership? - return field_107 if staircasing? + + field_107 if staircasing? end def equity return field_87 if shared_ownership_initial_purchase? - return field_108 if staircasing? + + field_108 if staircasing? end def mortgage return field_89 if shared_ownership? - return field_117 if discounted_ownership? + + field_117 if discounted_ownership? end def extrabor - return field_119 if discounted_ownership? + field_119 if discounted_ownership? end def deposit return field_91 if shared_ownership? - return field_120 if discounted_ownership? + + field_120 if discounted_ownership? end def mrent return field_93 if shared_ownership_initial_purchase? - return field_111 if staircasing? + + field_111 if staircasing? end def mscharge return field_94 if shared_ownership? - return field_121 if discounted_ownership? + + field_121 if discounted_ownership? end def mortlen return field_90 if shared_ownership? - return field_118 if discounted_ownership? + + field_118 if discounted_ownership? end def proplen return field_79 if shared_ownership? - return field_112 if discounted_ownership? + + field_112 if discounted_ownership? end def mortgageused return field_88 if shared_ownership_initial_purchase? return field_116 if discounted_ownership? - return field_109 if staircasing? + + field_109 if staircasing? end def value_fields @@ -1369,7 +1380,7 @@ private end def validate_valid_radio_option - log.attributes.each do |question_id, _v| + log.attributes.each_key do |question_id| question = log.form.get_question(question_id, log) next if question_id == "type" diff --git a/app/services/bulk_upload/sales/year2026/row_parser.rb b/app/services/bulk_upload/sales/year2026/row_parser.rb index adb7cc6a2..08d56fe37 100644 --- a/app/services/bulk_upload/sales/year2026/row_parser.rb +++ b/app/services/bulk_upload/sales/year2026/row_parser.rb @@ -934,7 +934,7 @@ private attributes["mortlen"] = mortlen attributes["proplen"] = proplen if proplen&.positive? - attributes["proplen_asked"] = attributes["proplen"]&.present? ? 0 : 1 + attributes["proplen_asked"] = attributes["proplen"].present? ? 0 : 1 attributes["jointmore"] = field_13 attributes["staircase"] = field_10 attributes["privacynotice"] = field_15 @@ -1036,7 +1036,8 @@ private ].each do |hash| define_method("age#{hash[:person]}_known?") do return 1 if public_send(hash[:field]) == "R" - return 0 if send("person_#{hash[:person]}_present?") + + 0 if send("person_#{hash[:person]}_present?") end end @@ -1104,58 +1105,68 @@ private def sale_type return field_9 if shared_ownership? - return field_11 if discounted_ownership? + + field_11 if discounted_ownership? end def value return field_86 if shared_ownership_initial_purchase? return field_113 if discounted_ownership? - return field_107 if staircasing? + + field_107 if staircasing? end def equity return field_87 if shared_ownership_initial_purchase? - return field_108 if staircasing? + + field_108 if staircasing? end def mortgage return field_89 if shared_ownership? - return field_117 if discounted_ownership? + + field_117 if discounted_ownership? end def extrabor - return field_119 if discounted_ownership? + field_119 if discounted_ownership? end def deposit return field_91 if shared_ownership? - return field_120 if discounted_ownership? + + field_120 if discounted_ownership? end def mrent return field_93 if shared_ownership_initial_purchase? - return field_111 if staircasing? + + field_111 if staircasing? end def mscharge return field_94 if shared_ownership? - return field_121 if discounted_ownership? + + field_121 if discounted_ownership? end def mortlen return field_90 if shared_ownership? - return field_118 if discounted_ownership? + + field_118 if discounted_ownership? end def proplen return field_79 if shared_ownership? - return field_112 if discounted_ownership? + + field_112 if discounted_ownership? end def mortgageused return field_88 if shared_ownership_initial_purchase? return field_116 if discounted_ownership? - return field_109 if staircasing? + + field_109 if staircasing? end def value_fields @@ -1398,7 +1409,7 @@ private end def validate_valid_radio_option - log.attributes.each do |question_id, _v| + log.attributes.each_key do |question_id| question = log.form.get_question(question_id, log) next if question_id == "type" diff --git a/app/services/csv/lettings_log_csv_service.rb b/app/services/csv/lettings_log_csv_service.rb index 003515ac9..dd3be8595 100644 --- a/app/services/csv/lettings_log_csv_service.rb +++ b/app/services/csv/lettings_log_csv_service.rb @@ -398,12 +398,14 @@ module Csv def label_if_boolean_value(value) return "Yes" if value == true - return "No" if value == false + + "No" if value == false end def conventional_yes_no_label(value) return "Yes" if value == 1 - return "No" if value&.zero? + + "No" if value&.zero? end end end diff --git a/app/services/csv/sales_log_csv_service.rb b/app/services/csv/sales_log_csv_service.rb index ed16653f1..07ccad82c 100644 --- a/app/services/csv/sales_log_csv_service.rb +++ b/app/services/csv/sales_log_csv_service.rb @@ -408,7 +408,8 @@ module Csv def label_if_boolean_value(value) return "Yes" if value == true - return "No" if value == false + + "No" if value == false end end end diff --git a/app/services/documentation_generator.rb b/app/services/documentation_generator.rb index c2005f320..58c2031f7 100644 --- a/app/services/documentation_generator.rb +++ b/app/services/documentation_generator.rb @@ -93,7 +93,7 @@ class DocumentationGenerator interruption_screen_pages = form.pages.select { |page| page.questions.first.type == "interruption_screen" } interruption_screen_pages_grouped_by_question = interruption_screen_pages.group_by { |page| page.questions.first.id } - interruption_screen_pages_grouped_by_question.each do |_question_id, pages| + interruption_screen_pages_grouped_by_question.each_value do |pages| pages.map do |page| save_soft_validation(form, page, validation_descriptions, log_type) end diff --git a/app/services/exports/organisation_export_constants.rb b/app/services/exports/organisation_export_constants.rb index 6c78a55db..7ffbfd223 100644 --- a/app/services/exports/organisation_export_constants.rb +++ b/app/services/exports/organisation_export_constants.rb @@ -23,6 +23,6 @@ module Exports::OrganisationExportConstants "dpo_email", "profit_status", "group", - "status" + "status", ] end diff --git a/app/services/filter_manager.rb b/app/services/filter_manager.rb index 7757ad39e..69e895809 100644 --- a/app/services/filter_manager.rb +++ b/app/services/filter_manager.rb @@ -121,7 +121,7 @@ class FilterManager new_filters = new_filters.except("user") if params["assigned_to"] == "all" new_filters["user"] = current_user.id.to_s if params["assigned_to"] == "you" - new_filters = new_filters.except("user_text_search") if params["assigned_to"] == "all" || params["assigned_to"] == "you" + new_filters = new_filters.except("user_text_search") if %w[all you].include?(params["assigned_to"]) new_filters = new_filters.except("owning_organisation_text_search") if params["owning_organisation_select"] == "all" new_filters = new_filters.except("managing_organisation_text_search") if params["managing_organisation_select"] == "all" end diff --git a/app/views/form/_checkbox_question.html.erb b/app/views/form/_checkbox_question.html.erb index b4feb12bd..d3c52c270 100644 --- a/app/views/form/_checkbox_question.html.erb +++ b/app/views/form/_checkbox_question.html.erb @@ -16,7 +16,7 @@ hint: { text: option["hint"] }, checked: @log[key] == 1, exclusive: after_divider, - link_errors: index.zero? ? true : nil, + link_errors: index.zero? || nil, **stimulus_html_attributes(question) %> <% end %> <% end %> diff --git a/app/views/form/_interruption_screen_question.html.erb b/app/views/form/_interruption_screen_question.html.erb index c0063e477..9aa38ca5d 100644 --- a/app/views/form/_interruption_screen_question.html.erb +++ b/app/views/form/_interruption_screen_question.html.erb @@ -18,7 +18,7 @@
<%= f.govuk_submit "Confirm and continue" %> <%= govuk_link_to( - (@page.skip_text || "Skip for now"), - (@page.skip_href(@log) || send(@log.form.next_page_redirect_path(@page, @log, current_user, ignore_answered: true), @log)), + @page.skip_text || "Skip for now", + @page.skip_href(@log) || send(@log.form.next_page_redirect_path(@page, @log, current_user, ignore_answered: true), @log), ) %>
diff --git a/app/views/form/_radio_question.html.erb b/app/views/form/_radio_question.html.erb index bf6abb0d0..e810d7b7a 100644 --- a/app/views/form/_radio_question.html.erb +++ b/app/views/form/_radio_question.html.erb @@ -28,14 +28,14 @@ key, label: { text: options["value"] }, hint: { text: options["hint"] }, - link_errors: index.zero? ? true : nil, + link_errors: index.zero? || nil, **stimulus_html_attributes(question) %> <% else %> <%= f.govuk_radio_button question.id.to_sym, key, label: { text: options["value"] }, hint: { text: options["hint"] }, - link_errors: index.zero? ? true : nil, + link_errors: index.zero? || nil, **stimulus_html_attributes(question) do %> <%= render partial: "#{conditional_question.type}_question", locals: { question: conditional_question, diff --git a/app/views/rails_admin/main/_submit_buttons.html.erb b/app/views/rails_admin/main/_submit_buttons.html.erb index 241624c4e..1768ce2b3 100644 --- a/app/views/rails_admin/main/_submit_buttons.html.erb +++ b/app/views/rails_admin/main/_submit_buttons.html.erb @@ -1,6 +1,6 @@
- +