Skip to content

Commit

Permalink
Update Rubocop GOVUK to 5.0.2
Browse files Browse the repository at this point in the history
We are a couple of major versions behind the GOVUK Rubocop rules.

This change updates the linter and applies the corrections these new
rules introduce.
  • Loading branch information
felixclack committed Aug 9, 2024
1 parent 3459170 commit aff2c3d
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 50 deletions.
11 changes: 8 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ Rails/LexicallyScopedActionFilter:
Rails/SaveBang:
Enabled: false

RSpec/Capybara/FeatureMethods:
Exclude:
- spec/system/**/*
RSpec/Dialect:
PreferredMethods:
background: :before
scenario: :it
xscenario: :xit
given: :let
given!: :let!
feature: :describe

RSpec/InstanceVariable:
Exclude:
Expand Down
34 changes: 17 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ GEM
net-smtp (0.4.0.1)
net-protocol
nio4r (2.7.0)
nokogiri (1.16.6-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux)
racc (~> 1.4)
notifications-ruby-client (5.4.0)
Expand All @@ -313,7 +315,7 @@ GEM
os (1.1.4)
pagy (6.5.0)
parallel (1.24.0)
parser (3.3.0.5)
parser (3.3.4.2)
ast (~> 2.4.1)
racc
patience_diff (1.2.0)
Expand Down Expand Up @@ -426,7 +428,7 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.62.1)
rubocop (1.64.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -437,29 +439,26 @@ GEM
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-govuk (4.15.0)
rubocop (= 1.62.1)
rubocop-ast (= 1.31.2)
rubocop-rails (= 2.24.0)
rubocop-govuk (5.0.2)
rubocop (= 1.64.1)
rubocop-ast (= 1.31.3)
rubocop-capybara (= 2.21.0)
rubocop-rails (= 2.25.1)
rubocop-rake (= 0.6.0)
rubocop-rspec (= 2.27.1)
rubocop-rails (2.24.0)
rubocop-rspec (= 3.0.1)
rubocop-rails (2.25.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.27.1)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec (3.0.1)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
ruby-rc4 (0.1.5)
ruby2_keywords (0.0.5)
Expand Down Expand Up @@ -546,6 +545,7 @@ GEM
zeitwerk (2.6.16)

PLATFORMS
arm64-darwin-24
x86_64-linux

DEPENDENCIES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
context "with a valid value" do
it "saves the value on the referral" do
save
expect(referral.allegation_details_complete).to eq(false)
expect(referral.allegation_details_complete).to be(false)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
end

it "clears the allegation details" do
expect(referral.allegation_details).to be nil
expect(referral.allegation_details).to be_nil
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
context "with a valid value" do
it "saves the value on the referral" do
save
expect(referral.evidence_details_complete).to eq(false)
expect(referral.evidence_details_complete).to be(false)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
context "with a valid value" do
it "saves the value on the referral" do
save
expect(referral.has_evidence).to eq(false)
expect(referral.has_evidence).to be(false)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

it "updates details on the referral" do
save
expect(referral.previous_misconduct_details).to be nil
expect(referral.previous_misconduct_details).to be_nil
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
end

it "saves the age_known value" do
expect(referral.age_known).to eq(false)
expect(referral.age_known).to be(false)
end

context "when the date of birth was previously set" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
context "with a valid value" do
it "saves the value on the referral" do
save
expect(referral.personal_details_complete).to eq(false)
expect(referral.personal_details_complete).to be(false)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/forms/referrals/teacher_role/duties_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
end

it "updates details on the referral" do
expect(referral.duties_details).to be nil
expect(referral.duties_details).to be_nil
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/file_size_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
subject { file_size(attachment) }

context "when called with an attachment" do
let(:attachment) { instance_double("ActiveStorage::Blob", byte_size: 33.6.kilobytes) }
let(:attachment) { instance_double(ActiveStorage::Blob, byte_size: 33.6.kilobytes) }

it { is_expected.to eq "33.6KB" }
end
Expand Down
18 changes: 9 additions & 9 deletions spec/lib/custom_attrs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class TestClass

context "when the class doesn't have a referral object" do
it "returns nil" do
expect(email_known).to eq(nil)
expect(email_address).to eq(nil)
expect(email_known).to be_nil
expect(email_address).to be_nil
end
end

Expand All @@ -30,7 +30,7 @@ class TestClass
before { test_class.referral = referral }

it "returns the referral's values" do
expect(email_known).to eq(true)
expect(email_known).to be(true)
expect(email_address).to eq("[email protected]")
end

Expand All @@ -41,7 +41,7 @@ class TestClass
end

it "returns the referral's updated values" do
expect(email_known).to eq(false)
expect(email_known).to be(false)
expect(email_address).to eq("[email protected]")
end
end
Expand All @@ -54,8 +54,8 @@ class TestClass

context "when the class doesn't have an organisation object" do
it "returns nil" do
expect(name).to eq(nil)
expect(street_1).to eq(nil)
expect(name).to be_nil
expect(street_1).to be_nil
end
end

Expand Down Expand Up @@ -90,8 +90,8 @@ class TestClass

context "when the class doesn't have a referrer object" do
it "returns nil" do
expect(first_name).to eq(nil)
expect(last_name).to eq(nil)
expect(first_name).to be_nil
expect(last_name).to be_nil
end
end

Expand Down Expand Up @@ -125,7 +125,7 @@ class TestClass

context "when the class doesn't have an eligibility_check object" do
it "returns nil" do
expect(serious_misconduct).to eq(nil)
expect(serious_misconduct).to be_nil
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/devise/otp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
secret_key = ROTP::Base32.random
submitted_otp = ROTP::HOTP.new(secret_key).at(0)

expect(described_class.valid?(secret_key, submitted_otp)).to eq true
expect(described_class.valid?(secret_key, submitted_otp)).to be true
end

it "returns false if the OTPs don't match" do
secret_key = ROTP::Base32.random
submitted_otp = "bad_guess"

expect(described_class.valid?(secret_key, submitted_otp)).to eq false
expect(described_class.valid?(secret_key, submitted_otp)).to be false
end
end
end
8 changes: 4 additions & 4 deletions spec/lib/staff_http_basic_auth_strategy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
context "with staff users" do
before { create(:staff) }

it { is_expected.to eq(false) }
it { is_expected.to be(false) }
end

context "when feature is active" do
before { FeatureFlags::FeatureFlag.activate(:staff_http_basic_auth) }

it { is_expected.to eq(true) }
it { is_expected.to be(true) }
end

context "when there are no staff users" do
it { is_expected.to eq(true) }
it { is_expected.to be(true) }
end
end

describe "#store?" do
subject(:store?) { staff_http_basic_auth_strategy.store? }

it { is_expected.to eq(false) }
it { is_expected.to be(false) }
end

describe "#authenticate!" do
Expand Down
9 changes: 5 additions & 4 deletions spec/models/section_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ def slug

context "when the section is not started" do
it "returns the start path" do
allow(section).to receive(:started?).and_return(false)
allow(section).to receive(:start_path).and_return(:start_path)
allow(section).to receive_messages(started?: false, start_path: :start_path)
expect(path).to eq :start_path
end
end

context "when the section is started" do
it "returns the check answers path" do
allow(section).to receive(:started?).and_return(true)
allow(section).to receive(:check_answers_path).and_return(:check_answers_path)
allow(section).to receive_messages(
started?: true,
check_answers_path: :check_answers_path
)

expect(path).to eq :check_answers_path
end
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/rack_attack_initializer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe "Rack::Attack initializer", rack_attack: true do
RSpec.describe "Rack::Attack initializer", :rack_attack do
before { FeatureFlags::FeatureFlag.activate(:service_open) }

describe "limit_otp_emails throttle" do
Expand Down
2 changes: 1 addition & 1 deletion spec/system/smoke_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

TEST_ENVIRONMENTS = "local dev test preprod review"

RSpec.describe "Smoke test", type: :system, js: true, smoke_test: true do
RSpec.describe "Smoke test", :js, :smoke_test, type: :system do
it "works as expected" do
when_i_visit_the_service
then_it_loads_successfully
Expand Down

0 comments on commit aff2c3d

Please sign in to comment.