Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ca9f138
[RUBY-4069] updated gems
brujeo Nov 21, 2025
f984730
[RUBY-4069] Fixing coding style issue - replaced abort with raise
brujeo Nov 21, 2025
574a4ab
[RUBY-4069] Fixing RSpec/LeakyLocalVariable coding style issues
brujeo Nov 21, 2025
47b4c11
[RUBY-4069] Fixing sonar cloud issue - Inherit from the 'ApplicationC…
brujeo Nov 21, 2025
96f2bbc
[RUBY-4069] Fixing sonar cloud issue - Use a specific exception class…
brujeo Nov 21, 2025
f18ef6a
[RUBY-4069] Fixing sonar cloud issue - "return" statements should not…
brujeo Nov 21, 2025
afd70a2
[RUBY-4069] Fixing sonar cloud issue - "return" statements should not…
brujeo Nov 21, 2025
540769e
[RUBY-4069] Fixing sonar cloud issue - "return" statements should not…
brujeo Nov 21, 2025
c847963
[RUBY-4069] Fixing sonar cloud issue - "return" statements should not…
brujeo Nov 21, 2025
57ae7c8
[RUBY-4069] Fixing sonar cloud issues - duplicate id in html templates
brujeo Nov 21, 2025
4cfd08a
[RUBY-4069] Fixing sonar cloud issues - Replace this `return` stateme…
brujeo Nov 21, 2025
cd3aa5a
[RUBY-4069] Fixing sonar cloud issues - setting defaults
brujeo Nov 21, 2025
e3f7149
[RUBY-4069] Fixing sonar cloud issues - shifting require statements
brujeo Nov 21, 2025
fdf9755
[RUBY-4069] Fixing sonar cloud issues - Use a specific exception clas…
brujeo Nov 24, 2025
94c3243
[RUBY-4069] Fixing sonar cloud issues - Use a specific exception clas…
brujeo Nov 24, 2025
fec58a3
[RUBY-4069] Fixing sonar cloud issues - Move this 'require' statement…
brujeo Nov 24, 2025
c859da5
[RUBY-4069] suppressing false positive SonarCloud warning
brujeo Nov 24, 2025
99b0d27
[RUBY-4069] suppressing false positive SonarCloud warning
brujeo Nov 24, 2025
22b990d
[RUBY-4069] suppressing false positive SonarCloud warning
brujeo Nov 24, 2025
e0a35ef
[RUBY-4069] Fixing sonar cloud issues - Move this 'require' statement…
brujeo Nov 24, 2025
ea4b11e
[RUBY-4069] Fixing sonar cloud issues - Move this 'require' statement…
brujeo Nov 24, 2025
dbfa554
[RUBY-4069] suppressing false positive SonarCloud warning
brujeo Nov 24, 2025
0675698
[RUBY-4069] Fixing sonar cloud issues - Move this 'require' statement…
brujeo Nov 24, 2025
57cc498
[RUBY-4069] Fixing sonar cloud issues - Move this 'require' statement…
brujeo Nov 24, 2025
ecb9fcb
[RUBY-4069] Fixing sonar cloud issues - Move this 'require' statement…
brujeo Nov 24, 2025
b26033b
[RUBY-4069] reverting previously made sonar cloud adjustments - as no…
brujeo Nov 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ GEM
rbtree3 (~> 0.6)
ast (2.4.3)
aws-eventstream (1.4.0)
aws-partitions (1.1180.0)
aws-sdk-core (3.236.0)
aws-partitions (1.1186.0)
aws-sdk-core (3.239.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
base64
bigdecimal
jmespath (~> 1, >= 1.6.1)
logger
aws-sdk-kms (1.116.0)
aws-sdk-kms (1.117.0)
aws-sdk-core (~> 3, >= 3.234.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.202.0)
aws-sdk-s3 (1.205.0)
aws-sdk-core (~> 3, >= 3.234.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down Expand Up @@ -168,9 +168,9 @@ GEM
docile (1.4.1)
dotenv (3.1.8)
drb (2.2.3)
erb (5.1.3)
erb (6.0.0)
erubi (1.13.1)
factory_bot (6.5.5)
factory_bot (6.5.6)
activesupport (>= 6.1.0)
factory_bot_rails (6.5.1)
factory_bot (~> 6.5)
Expand All @@ -183,8 +183,8 @@ GEM
logger
faraday-http-cache (2.5.1)
faraday (>= 0.8)
faraday-net_http (3.4.1)
net-http (>= 0.5.0)
faraday-net_http (3.4.2)
net-http (~> 0.5)
faraday-retry (2.3.2)
faraday (~> 2.0)
github_changelog_generator (1.15.2)
Expand Down Expand Up @@ -214,7 +214,7 @@ GEM
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jmespath (1.6.2)
json (2.15.2)
json (2.16.0)
json_schemer (2.4.0)
bigdecimal
hana (~> 1.3)
Expand Down Expand Up @@ -250,10 +250,10 @@ GEM
method_source (1.1.0)
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (5.26.0)
minitest (5.26.2)
multi_json (1.17.0)
net-http (0.6.0)
uri
net-http (0.8.0)
uri (>= 0.11.1)
net-imap (0.5.12)
date
net-protocol
Expand Down Expand Up @@ -342,19 +342,19 @@ GEM
psych (>= 4.0.0)
tsort
regexp_parser (2.11.3)
reline (0.6.2)
reline (0.6.3)
io-console (~> 0.5)
retriable (3.1.2)
rexml (3.4.4)
roo (2.10.1)
nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0)
rspec-core (3.13.5)
rspec-core (3.13.6)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
rspec-mocks (3.13.7)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (8.0.2)
Expand All @@ -379,16 +379,16 @@ GEM
rubocop-ast (>= 1.47.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.47.1)
rubocop-ast (1.48.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-capybara (2.22.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-factory_bot (2.27.1)
rubocop-factory_bot (2.28.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rails (2.33.4)
rubocop-rails (2.34.0)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
Expand All @@ -397,10 +397,10 @@ GEM
rubocop-rake (0.7.1)
lint_roller (~> 1.1)
rubocop (>= 1.72.1)
rubocop-rspec (3.7.0)
rubocop-rspec (3.8.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec_rails (2.31.0)
rubocop (~> 1.81)
rubocop-rspec_rails (2.32.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec (~> 3.5)
Expand Down Expand Up @@ -431,7 +431,7 @@ GEM
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
stringio (3.1.7)
stringio (3.1.8)
thor (1.4.0)
timecop (0.9.10)
timeout (0.4.4)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/pafs_core/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PafsCore
class ApplicationController < ActionController::Base
class ApplicationController < ::ApplicationController
include PafsCore::ApplicationHelper
include PafsCore::CustomHeaders

Expand Down
2 changes: 1 addition & 1 deletion app/models/pafs_core/area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def ea_parent
elsif rma?
parent.parent
else
raise "Cannot find ea parent for #{name}"
raise PafsCore::AreaParentError, "Cannot find ea parent for #{name}"
end
end

Expand Down
8 changes: 5 additions & 3 deletions app/models/pafs_core/funding_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ def self.to_financial_year(year)
next if FundingSources::REMOVED_FROM_FUNDING_VALUES.include?(source)

define_method("#{source}_total") do
return public_send(source).to_i unless FundingSources::AGGREGATE_SOURCES.include?(source)

(public_send(source) || []).map(&:amount).compact.sum.to_i
if FundingSources::AGGREGATE_SOURCES.include?(source)
(public_send(source) || []).map(&:amount).compact.sum.to_i
else
public_send(source).to_i
end
end
end

Expand Down
18 changes: 15 additions & 3 deletions app/presenters/pafs_core/carbon_impact_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,35 @@ def carbon_impact_rates
# of 3.5 would be picked up from the 2028/29 field as this is the latest available year.
def carbon_impact_rate_for_year(year_string, rate_label)
rate_not_present_in_mid_year_data = false
result = nil

# check if year present
year_present = carbon_impact_rates.find { |rates| rates["Year"] == year_string }.present?

carbon_impact_rates.reverse.each do |rates|
# year not present in data at all, return the previous year rate available
return rates[rate_label] if !year_present && rates[rate_label].present?
if !year_present && rates[rate_label].present?
result = rates[rate_label]
break
end

if rates["Year"] == year_string
return rates[rate_label] if rates[rate_label].present?
if rates[rate_label].present?
result = rates[rate_label]
break
end

rate_not_present_in_mid_year_data = true
end

# year present but rate is missing, return the rate from the previous year available
return rates[rate_label] if rate_not_present_in_mid_year_data && rates[rate_label].present?
if rate_not_present_in_mid_year_data && rates[rate_label].present?
result = rates[rate_label]
break
end
end

result
end

# Cap DN / Cap Do Nothing Intensity rate for the mid year
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/pafs_core/project_summary_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def standard_of_protection_step
elsif protects_against_coastal_erosion?
:standard_of_protection_coastal
else
raise "Risks not set prior to standard of protection"
raise PafsCore::RisksNotSetError, "Risks not set prior to standard of protection"
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/services/pafs_core/area_importer.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

require "csv"

module PafsCore
class AreaImporter

require "csv"
HEADERS = ["name",
"parent area",
"type",
Expand All @@ -15,7 +15,7 @@ def initialize
end

def full_import(path_to_file)
abort("Areas already exist") if PafsCore::Area.any?
raise PafsCore::AreaImportError, "Areas already exist" if PafsCore::Area.any?

extract_csv_data(path_to_file)

Expand All @@ -35,7 +35,7 @@ def extract_csv_data(path_to_file)
end

def import_areas
abort("Headers incorrect.") unless (@areas_to_be_imported.first.keys - HEADERS).empty?
raise PafsCore::AreaImportError, "Headers incorrect." unless (@areas_to_be_imported.first.keys - HEADERS).empty?

remove_areas_that_have_already_been_imported

Expand Down
5 changes: 3 additions & 2 deletions app/services/pafs_core/calculator_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ class CalculatorParser
].freeze

def initialize(calculator, project)
calculator_sheet_name = calculator.sheets.grep(/PF Calculator/i).first || raise("No calculator sheet found")
calculator_sheet_name = calculator.sheets.grep(/PF Calculator/i).first ||
raise(PafsCore::CalculatorSheetNotFoundError, "No calculator sheet found")
@sheet = calculator.sheet(calculator_sheet_name)
@project = project
end

def self.parse(file, project)
raise "require an xlsx file" unless File.extname(file.path) == ".xlsx"
raise PafsCore::InvalidFileTypeError, "require an xlsx file" unless File.extname(file.path) == ".xlsx"

begin
calculator = Roo::Excelx.new(file.path)
Expand Down
2 changes: 1 addition & 1 deletion app/services/pafs_core/project_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def initial_attributes(area_name = nil)
end

def derive_rfcc_code_from_user(area_name)
raise "User has no RFCC area code" unless user.rfcc_code(area_name)
raise PafsCore::MissingRfccAreaCodeError, "User has no RFCC area code" unless user.rfcc_code(area_name)

user.rfcc_code(area_name)
end
Expand Down
3 changes: 2 additions & 1 deletion app/services/pafs_core/spreadsheet_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def add_project_to_sheet(sheet, project, row_no)
value = use_value ? project.send(col[:field_name]) : 0
sheet[row_no][column_index(col[:column])].change_contents(value)
rescue StandardError => e
raise "Boom - Project (#{project.slug}) Row no (#{row_no}) col (#{col}) " \
raise PafsCore::SpreadsheetProcessingError,
"Boom - Project (#{project.slug}) Row no (#{row_no}) col (#{col}) " \
"field_name (#{col[:field_name]}) value (#{value}): exception #{e}"
end
end
Expand Down
7 changes: 5 additions & 2 deletions app/steps/pafs_core/benefit_area_file_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def step_params(params)
end

def contins_required_gis_files(uploaded_file)
all_extensions_present = true

Zip::File.open(uploaded_file.tempfile.path) do |zip_file|
entries = zip_file.entries.map(&:name)

Expand All @@ -76,11 +78,12 @@ def contins_required_gis_files(uploaded_file)

errors.add(:base, "The selected file must be a zip file, " \
"containing the following mandatory files: dbf. shx. shp. prj.")
return false
all_extensions_present = false
break
end
end

true
all_extensions_present
rescue Zip::Error
errors.add(:base, "The selected file must be a zip file, " \
"containing the following mandatory files: dbf. shx. shp. prj.")
Expand Down
20 changes: 14 additions & 6 deletions app/steps/pafs_core/coastal_erosion_protection_outcomes_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,27 @@ def update(params)
private

def values?
coastal_erosion_protection_outcomes.each do |outcome|
error_found = false

outcomes = coastal_erosion_protection_outcomes.each do |outcome|
%i[households_at_reduced_risk
households_protected_from_loss_in_next_20_years
households_protected_from_loss_in_20_percent_most_deprived].each do |attr|
if outcome.send(attr).to_i.positive?
return errors.add(
:base,
"In the applicable year(s), tell us how many households moved to a lower flood risk category " \
"(column A), OR if this does not apply select the checkbox."
)
error_found = true
break
end
end
break if error_found
end

return outcomes unless error_found

errors.add(
:base,
"In the applicable year(s), tell us how many households moved to a lower flood risk category " \
"(column A), OR if this does not apply select the checkbox."
)
end

def values_make_sense
Expand Down
2 changes: 1 addition & 1 deletion app/views/pafs_core/projects/_submit_project.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>
<% else %>
<div class="govuk-grid-column-three-quarters">
<h2 class="govuk-heading-m" id="submission">
<h2 class="govuk-heading-m" id="submission-notice">
<p>EA Projects are now managed in PoL</p>
</h2>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,15 @@
<% end %>
<div class="govuk-checkboxes__item">
<%# <input name="natural_flood_risk_measures_step[other_flood_measures_selected]" type="hidden" value="0"> %>
<% if f.object.other_flood_measures_selected %>
<input id="natural_flood_risk_measures_step_other_flood_measures_selected"
type="checkbox"
name="natural_flood_risk_measures_step[other_flood_measures_selected]"
class="govuk-checkboxes__input"
value="other_flood_measures_selected"
checked
onclick="toggleBoxVisibility()"
onkeydown="toggleBoxVisibility()"
>
<% else %>
<input id="natural_flood_risk_measures_step_other_flood_measures_selected"
type="checkbox"
name="natural_flood_risk_measures_step[other_flood_measures_selected]"
class="govuk-checkboxes__input"
value="other_flood_measures_selected"
onclick="toggleBoxVisibility()"
onkeydown="toggleBoxVisibility()"
>
<% end %>
<input id="natural_flood_risk_measures_step_other_flood_measures_selected"
type="checkbox"
name="natural_flood_risk_measures_step[other_flood_measures_selected]"
class="govuk-checkboxes__input"
value="other_flood_measures_selected"
<%= 'checked' if f.object.other_flood_measures_selected %>
onclick="toggleBoxVisibility()"
onkeydown="toggleBoxVisibility()"
>
<label for="natural_flood_risk_measures_step_other_flood_measures_selected" class="govuk-label govuk-checkboxes__label">
Other
</label>
Expand Down
2 changes: 1 addition & 1 deletion app/views/pafs_core/summary/_approach.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div class="add-row">
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
<h2 class="govuk-heading-m" id="approach"><%= project.summary_label(:approach_title) %></h2>
<h2 class="govuk-heading-m" id="approach-add"><%= project.summary_label(:approach_title) %></h2>
</div>
<div class="govuk-grid-column-one-quarter">
<% unless project.archived? %>
Expand Down
Loading
Loading