Skip to content

Commit

Permalink
Merge pull request #7988 from ministryofjustice/rubocop
Browse files Browse the repository at this point in the history
Rubocop fixes
  • Loading branch information
jrmhaig authored Jan 14, 2025
2 parents 14315a5 + f403351 commit 97797cc
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 166 deletions.
33 changes: 10 additions & 23 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1000`
# on 2024-12-30 12:47:30 UTC using RuboCop version 1.69.2.
# on 2024-12-30 18:51:32 UTC using RuboCop version 1.69.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -16,7 +16,7 @@ FactoryBot/FactoryAssociationWithStrategy:
- 'spec/factories/claim/transfer_details.rb'
- 'spec/factories/expenses.rb'

# Offense count: 652
# Offense count: 650
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Expand Down Expand Up @@ -284,7 +284,7 @@ Metrics/CyclomaticComplexity:
- 'lib/data_migrator/offence_unique_code_migrator.rb'
- 'spec/api/v2/claim_spec.rb'

# Offense count: 60
# Offense count: 56
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Exclude:
Expand All @@ -293,7 +293,6 @@ Metrics/MethodLength:
- 'app/controllers/external_users/application_controller.rb'
- 'app/controllers/external_users/fees/prices_controller.rb'
- 'app/controllers/external_users/registrations_controller.rb'
- 'app/controllers/pages_controller.rb'
- 'app/interfaces/api/helpers/api_helper.rb'
- 'app/models/ability.rb'
- 'app/models/allocation.rb'
Expand All @@ -305,7 +304,6 @@ Metrics/MethodLength:
- 'app/presenters/fee/interim_fee_type_presenter.rb'
- 'app/services/claims/case_worker_claims.rb'
- 'app/services/claims/fee_calculator/graduated_price.rb'
- 'app/services/message_queue/message_template.rb'
- 'app/services/reports/provisional_assessments_by_dates.rb'
- 'app/services/stats/management_information_generator.rb'
- 'app/validators/claim/advocate_claim_validator.rb'
Expand All @@ -329,14 +327,12 @@ Metrics/MethodLength:
- 'spec/factories/claim/base_claims.rb'
- 'spec/factories/disbursement_types.rb'
- 'spec/models/claims/cloner_spec.rb'
- 'spec/models/remote/case_type_spec.rb'
- 'spec/models/timed_transitions/transitioner_spec.rb'
- 'spec/presenters/fee/interim_fee_type_presenter_spec.rb'
- 'spec/support/api/claims/advocate_claim_test/final.rb'
- 'spec/support/api/claims/advocate_claim_test/hardship.rb'
- 'spec/support/api/claims/base_claim_test.rb'
- 'spec/support/factory_helpers.rb'
- 'spec/support/matchers/hash_matchers.rb'
- 'spec/support/scheme_date_helpers.rb'

# Offense count: 7
Expand Down Expand Up @@ -514,7 +510,7 @@ RSpec/BeforeAfterAll:
- 'spec/services/claims/update_claim_spec.rb'
- 'spec/services/claims/update_draft_spec.rb'

# Offense count: 1343
# Offense count: 1342
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Expand Down Expand Up @@ -600,7 +596,6 @@ RSpec/ContextWording:
- 'spec/models/offence_class_spec.rb'
- 'spec/models/provider_spec.rb'
- 'spec/models/redetermination_spec.rb'
- 'spec/models/remote/case_type_spec.rb'
- 'spec/models/representation_order_spec.rb'
- 'spec/models/stage_collection_spec.rb'
- 'spec/models/stage_transition_spec.rb'
Expand Down Expand Up @@ -731,7 +726,7 @@ RSpec/EmptyExampleGroup:
- 'spec/services/claims/fee_calculator/graduated_price_spec.rb'
- 'spec/validators/claim/base_claim_sub_model_validator_spec.rb'

# Offense count: 166
# Offense count: 165
# Configuration parameters: Max, CountAsOne.
RSpec/ExampleLength:
Exclude:
Expand Down Expand Up @@ -782,7 +777,6 @@ RSpec/ExampleLength:
- 'spec/models/message_spec.rb'
- 'spec/models/offence_spec.rb'
- 'spec/models/redetermination_spec.rb'
- 'spec/models/remote/case_type_spec.rb'
- 'spec/models/stats/stats_report_spec.rb'
- 'spec/models/subscribers/slack_spec.rb'
- 'spec/models/timed_transitions/transitioner_spec.rb'
Expand Down Expand Up @@ -1012,7 +1006,7 @@ RSpec/LetSetup:
- 'spec/validators/claim/advocate_interim_claim_web_validations_spec.rb'
- 'spec/views/case_workers/claims/show_spec.rb'

# Offense count: 169
# Offense count: 167
# Configuration parameters: EnforcedStyle.
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Expand All @@ -1026,7 +1020,6 @@ RSpec/MessageSpies:
- 'spec/controllers/messages_controller_spec.rb'
- 'spec/helpers/case_workers/claims_helper_spec.rb'
- 'spec/helpers/case_workers/travel_helper_spec.rb'
- 'spec/helpers/claims_helper_spec.rb'
- 'spec/lib/caching/api_request_spec.rb'
- 'spec/models/allocation_spec.rb'
- 'spec/models/assessment_spec.rb'
Expand Down Expand Up @@ -1078,7 +1071,7 @@ RSpec/MultipleDescribes:
- 'spec/models/claim/base_claim_spec.rb'
- 'spec/routing/claims_controller_spec.rb'

# Offense count: 636
# Offense count: 632
# Configuration parameters: Max.
RSpec/MultipleExpectations:
Exclude:
Expand Down Expand Up @@ -1123,9 +1116,7 @@ RSpec/MultipleExpectations:
- 'spec/controllers/provider_management/providers_controller_spec.rb'
- 'spec/controllers/users_controller_spec.rb'
- 'spec/controllers/vat_rates_controller_spec.rb'
- 'spec/helpers/case_workers/admin/allocations_helper_spec.rb'
- 'spec/helpers/case_workers/claims_helper_spec.rb'
- 'spec/helpers/claims_helper_spec.rb'
- 'spec/lib/caching/api_request_spec.rb'
- 'spec/lib/caching/memory_store_spec.rb'
- 'spec/lib/extensions/devise_extension_spec.rb'
Expand Down Expand Up @@ -1155,7 +1146,6 @@ RSpec/MultipleExpectations:
- 'spec/models/fee/shared_examples_for_duplicable.rb'
- 'spec/models/injection_attempt_spec.rb'
- 'spec/models/message_spec.rb'
- 'spec/models/remote/case_type_spec.rb'
- 'spec/models/representation_order_spec.rb'
- 'spec/models/stage_collection_spec.rb'
- 'spec/models/stage_transition_spec.rb'
Expand Down Expand Up @@ -1466,15 +1456,14 @@ RSpec/PredicateMatcher:
- 'spec/services/claims/update_draft_spec.rb'
- 'spec/validators/claim/shared_examples_for_advocate_litigator.rb'

# Offense count: 69
# Offense count: 67
RSpec/StubbedMock:
Exclude:
- 'spec/api/entities/cclf/case_type_spec.rb'
- 'spec/controllers/case_workers/admin/allocations_controller_spec.rb'
- 'spec/controllers/case_workers/claims_controller_spec.rb'
- 'spec/controllers/messages_controller_spec.rb'
- 'spec/helpers/case_workers/claims_helper_spec.rb'
- 'spec/helpers/claims_helper_spec.rb'
- 'spec/models/claim/advocate_hardship_claim_spec.rb'
- 'spec/models/claim/advocate_interim_claim_spec.rb'
- 'spec/models/claim/advocate_supplementary_claim_spec.rb'
Expand Down Expand Up @@ -1512,7 +1501,7 @@ RSpec/SubjectStub:
- 'spec/services/claims/create_draft_spec.rb'
- 'spec/services/claims/update_claim_spec.rb'

# Offense count: 71
# Offense count: 69
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
Expand All @@ -1522,7 +1511,6 @@ RSpec/VerifiedDoubles:
- 'spec/controllers/heartbeat_controller_spec.rb'
- 'spec/controllers/messages_controller_spec.rb'
- 'spec/helpers/case_workers/claims_helper_spec.rb'
- 'spec/helpers/claims_helper_spec.rb'
- 'spec/lib/caching/api_request_spec.rb'
- 'spec/lib/rule/applicator_spec.rb'
- 'spec/models/allocation_spec.rb'
Expand Down Expand Up @@ -1673,11 +1661,10 @@ Rails/Output:
- 'lib/data_migrator/offence_unique_code_migrator.rb'
- 'lib/data_migrator/provider_suppliers_migrator.rb'

# Offense count: 3
# Offense count: 2
Rails/OutputSafety:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/helpers/claims_helper.rb'
- 'app/helpers/external_users/claims_helper.rb'

# Offense count: 2
Expand Down
21 changes: 4 additions & 17 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,10 @@ def api_release_notes; end

def servicedown
respond_to do |format|
format.html do
render :servicedown
end
format.json do
render json:
[{ error: 'Service temporarily unavailable' }],
status: :service_unavailable
end
format.js do
render json:
[{ error: 'Service temporarily unavailable' }],
status: :service_unavailable
end
format.all do
render plain: 'error: Service temporarily unavailable',
status: :service_unavailable
end
format.html { render :servicedown }
format.json { render json: [{ error: 'Service temporarily unavailable' }], status: :service_unavailable }
format.js { render json: [{ error: 'Service temporarily unavailable' }], status: :service_unavailable }
format.all { render plain: 'error: Service temporarily unavailable', status: :service_unavailable }
end
end

Expand Down
4 changes: 0 additions & 4 deletions app/helpers/case_workers/admin/allocations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ def allocation_scheme_filters
%w[agfs
lgfs]
end

def owner_column_header
params[:scheme].blank? || params[:scheme] == 'agfs' ? I18n.t('common.advocate') : I18n.t('common.litigator')
end
end
6 changes: 0 additions & 6 deletions app/helpers/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ module ClaimsHelper

SIGNPOST_FEES = %w[MIUMU MIAPF].freeze

def claim_allocation_checkbox_helper(claim, case_worker)
checked = claim.allocated_to_case_worker?(case_worker) ? 'checked="checked"' : nil
element_id = "id=\"case_worker_claim_ids_#{claim.id}\""
%(<input #{checked} #{element_id} name="case_worker[claim_ids][]" type="checkbox" value="#{claim.id}">).html_safe
end

def to_slug(string)
string.downcase.gsub(/ +/, '-').gsub(/[^a-zA-Z0-9-]/, '')
end
Expand Down
22 changes: 0 additions & 22 deletions app/services/message_queue/message_template.rb

This file was deleted.

16 changes: 0 additions & 16 deletions spec/helpers/case_workers/admin/allocations_helper_spec.rb

This file was deleted.

22 changes: 0 additions & 22 deletions spec/helpers/claims_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,6 @@
end

RSpec.describe ClaimsHelper do
describe '#claim_allocation_checkbox_helper' do
let(:case_worker) { double CaseWorker }
let(:claim) { double Claim }

before do
allow(claim).to receive(:id).and_return(66)
allow(case_worker).to receive(:id).and_return(888)
end

it 'produces the html for a checked checkbox if the claim is allocated to the case worker' do
expect(claim).to receive(:allocated_to_case_worker?).with(case_worker).and_return(true)
expected_html = '<input checked="checked" id="case_worker_claim_ids_66" name="case_worker[claim_ids][]" type="checkbox" value="66">'
expect(claim_allocation_checkbox_helper(claim, case_worker)).to eq expected_html
end

it 'produces the html for a un-checked checkbox if the claim is not allocated to the case worker' do
expect(claim).to receive(:allocated_to_case_worker?).with(case_worker).and_return(false)
expected_html = '<input id="case_worker_claim_ids_66" name="case_worker[claim_ids][]" type="checkbox" value="66">'
expect(claim_allocation_checkbox_helper(claim, case_worker)).to eq expected_html
end
end

describe '#show_api_promo_to_user?' do
helper do
def current_user
Expand Down
Loading

0 comments on commit 97797cc

Please sign in to comment.