Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RST 5622 - update rubocop config #1608

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
451 changes: 424 additions & 27 deletions .rubocop.yml

Large diffs are not rendered by default.

1,213 changes: 1,213 additions & 0 deletions .rubocop_todo.yml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ group :development, :test do
gem 'rspec-its', '~> 1.2', require: 'rspec/its'
gem 'rspec-rails', '~> 6.0'
gem 'rspec_junit_formatter', '~> 0.6.0'
gem 'rubocop', '~> 1.8', :require => false
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', '~> 2.1', :require => false
gem 'rubocop', '~> 1.8', require: false
gem "rubocop-rails", "~> 2.17", require: false
gem 'rubocop-rspec', '~> 2.1', require: false
gem 'shoulda-matchers', '~> 5.1'
gem 'spring', '~> 4.0'
gem 'parallel_tests', '~> 4.0'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ DEPENDENCIES
rspec-rails (~> 6.0)
rspec_junit_formatter (~> 0.6.0)
rubocop (~> 1.8)
rubocop-rails
rubocop-rails (~> 2.17)
rubocop-rspec (~> 2.1)
selenium-webdriver (~> 4.3, < 4.11)
sentry-rails (~> 5.7)
Expand Down
3 changes: 2 additions & 1 deletion app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ class Claim < ApplicationRecord
include ClaimLists

def self.ransackable_associations(_auth_object = nil)
['claimants', 'employment', 'events', 'office', 'primary_claimant', 'primary_respondent', 'representative', 'respondents', 'secondary_claimants', 'secondary_respondents', 'user']
['claimants', 'employment', 'events', 'office', 'primary_claimant', 'primary_respondent', 'representative', 'respondents', 'secondary_claimants', 'secondary_respondents',
'user']
end

has_one :user, foreign_key: :reference, primary_key: :application_reference, inverse_of: :claim, required: false
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Application < Rails::Application
# config.eager_load_paths << Rails.root.join("extras")

# The default locale is :en and all translations from config/locales/**/*.rb,yml are auto loaded.
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
config.i18n.load_path += Dir[Rails.root.join("config/locales/**/*.{rb,yml}").to_s]
config.i18n.default_locale = :en
# config.active_record.schema_format = :sql
config.active_record.yaml_column_permitted_classes = [ActiveSupport::HashWithIndifferentAccess]
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/timeout_sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
end

describe 'for email' do
let(:claim) { create :claim, email_address: nil }
let(:claim) { create(:claim, email_address: nil) }

before do
allow(user_session).to receive(:email_address).and_return(email)
Expand Down
8 changes: 4 additions & 4 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@

trait :null_primary_claimant do
primary_claimant do
build :claimant,
build(:claimant,
address_telephone_number: nil,
mobile_number: nil,
email_address: nil,
fax_number: nil,
contact_preference: nil,
gender: nil, date_of_birth: nil
gender: nil, date_of_birth: nil)
end
end

Expand All @@ -90,11 +90,11 @@

trait :null_representative do
representative do
build :representative,
build(:representative,
address_telephone_number: nil,
mobile_number: nil,
email_address: nil,
dx_number: nil
dx_number: nil)
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/features/admin_panel/admin_index_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
RSpec.describe 'Viewing the admin interfaces index page', type: :feature do

let(:out_of_filter_range_claim) do
create :claim,
create(:claim,
submitted_at: Date.new(2015, 6, 1),
created_at: Date.new(2015, 6, 1)
created_at: Date.new(2015, 6, 1))
end

let(:claim) do
create :claim,
create(:claim,
application_reference: 'SUCH-9999',
fee_group_reference: '511234567800',
submitted_at: Date.new(2015, 6, 5),
# Set created_at to a later date than other models to ensure it's the first row.
created_at: Date.new(2015, 6, 5)
created_at: Date.new(2015, 6, 5))
end

before do
Expand Down
14 changes: 7 additions & 7 deletions spec/features/admin_panel/admin_show_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

RSpec.describe 'Viewing a claims details in the admin interface', type: :feature do
let!(:claim_with_attachments) do
create :claim, :submitted, :with_pdf,
create(:claim, :submitted, :with_pdf,
fee_group_reference: '511234567800',
confirmation_email_recipients: ['[email protected]', '[email protected]']
confirmation_email_recipients: ['[email protected]', '[email protected]'])
end

let!(:enqueued_claim) do
create :claim, :with_pdf,
create(:claim, :with_pdf,
fee_group_reference: '511234567800',
confirmation_email_recipients: ['[email protected]', '[email protected]']
confirmation_email_recipients: ['[email protected]', '[email protected]'])
end

context 'with time frozen' do
Expand Down Expand Up @@ -78,11 +78,11 @@

context 'claim without large text inputs' do
let!(:claim_without_large_text_inputs) do
create :claim,
create(:claim,
claim_details: nil,
miscellaneous_information: nil,
other_claim_details: nil,
other_outcome: nil
other_outcome: nil)
end

before { visit admin_claim_path claim_without_large_text_inputs.reference }
Expand All @@ -105,7 +105,7 @@
end

context 'claim without attachments' do
let!(:claim_without_attachments) { create :claim, :no_attachments }
let!(:claim_without_attachments) { create(:claim, :no_attachments) }

before { visit admin_claim_path claim_without_attachments.reference }

Expand Down
2 changes: 1 addition & 1 deletion spec/features/create_claim_applications_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe 'Claim applications', type: :feature, js: true do
describe 'Claim applications', js: true, type: :feature do
include FormMethods
include Messages
include MailMatchers
Expand Down
2 changes: 1 addition & 1 deletion spec/features/multi_lang/claimant_validation_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rails_helper'
RSpec.describe 'Claimant Validation', type: :feature, js: true do
RSpec.describe 'Claimant Validation', js: true, type: :feature do
it 'filters out an incorrect phone number and provides the correct message' do
# Arrange - get to the page loaded with a claimant with the phone number overridden
claimant = build(:ui_claimant, :mandatory, phone_or_mobile_number: 'somethingwromg', alternative_phone_or_mobile_number: 'something_wrong')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rails_helper'
RSpec.describe 'Representatives Details Validation', type: :feature, js: true do
RSpec.describe 'Representatives Details Validation', js: true, type: :feature do
it 'filters out an incorrect phone number and provides the correct message' do
# Arrange - get to the page loaded with a claimant with the phone number overridden
claimant = build(:ui_claimant, :mandatory)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rails_helper'
RSpec.describe 'Respondents Details Validation', type: :feature, js: true do
RSpec.describe 'Respondents Details Validation', js: true, type: :feature do
it 'filters out an incorrect phone number and provides the correct message' do
# Arrange - get to the page loaded with a claimant with the phone number overridden
claimant = build(:ui_claimant, :mandatory)
Expand Down
2 changes: 1 addition & 1 deletion spec/features/quick_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe 'Quick edit' do
include FormMethods

let(:claim_ready_for_review) { create :claim, :no_attachments, state: 'created' }
let(:claim_ready_for_review) { create(:claim, :no_attachments, state: 'created') }

before do
fill_in_return_form claim_ready_for_review.reference, 'lollolol'
Expand Down
2 changes: 1 addition & 1 deletion spec/forms/additional_claimants_upload_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

let(:additional_claimants_upload_form) { described_class.new(resource) }

let(:resource) { create :claim, :no_attachments }
let(:resource) { create(:claim, :no_attachments) }
let(:path) { Rails.root.join('spec/support/files').to_s }
let(:file) { { 'path' => path, 'filename' => 'test.csv', 'content_type' => 'application/csv' } }

Expand Down
4 changes: 2 additions & 2 deletions spec/models/claim_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

RSpec.describe Claim, type: [:claim, :model] do
let(:claim_enqueued) { create :claim }
let(:claim_enqueued) { create(:claim) }
let(:claim) { described_class.create }

it { is_expected.to have_secure_password }
Expand Down Expand Up @@ -129,7 +129,7 @@
end

context 'claim with a single claimant' do
let(:claim) { create :claim, :single_claimant }
let(:claim) { create(:claim, :single_claimant) }

specify { expect(claim).not_to be_multiple_claimants }
end
Expand Down
12 changes: 6 additions & 6 deletions spec/models/stats/claim_stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
after { travel_back }

let(:current_time) { Time.zone.parse("2010-01-27 13:56:25") }
let(:started_claim) { create :claim, :not_submitted }
let(:old_started_claim) { create :claim, :not_submitted, created_at: 91.days.ago }
let(:old_out_of_range_started_claim) { create :claim, :not_submitted, created_at: 92.days.ago }
let(:completed_claim) { create :claim, :submitted }
let(:old_completed_claim) { create :claim, :submitted, created_at: 91.days.ago }
let(:old_out_of_range_completed_claim) { create :claim, :submitted, created_at: 92.days.ago }
let(:started_claim) { create(:claim, :not_submitted) }
let(:old_started_claim) { create(:claim, :not_submitted, created_at: 91.days.ago) }
let(:old_out_of_range_started_claim) { create(:claim, :not_submitted, created_at: 92.days.ago) }
let(:completed_claim) { create(:claim, :submitted) }
let(:old_completed_claim) { create(:claim, :submitted, created_at: 91.days.ago) }
let(:old_out_of_range_completed_claim) { create(:claim, :submitted, created_at: 92.days.ago) }
let(:not_started_claim) { Claim.create }

describe '.started_within_max_submission_timeframe' do
Expand Down
6 changes: 3 additions & 3 deletions spec/presenters/confirmation_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe ConfirmationPresenter, type: :presenter do
let(:confirmation_presenter) { described_class.new claim }

let(:claim) { create :claim }
let(:claim) { create(:claim) }

around do |example|
travel_to(Time.new(2014).utc) { example.run }
Expand Down Expand Up @@ -52,7 +52,7 @@
end

context 'when there is no associated fee office' do
let(:claim) { create :claim, :no_fee_group_reference }
let(:claim) { create(:claim, :no_fee_group_reference) }

it 'is the submission date' do
expect(confirmation_presenter.submission_information).
Expand All @@ -72,7 +72,7 @@
end

context 'when no attachments were uploaded' do
let(:claim) { create :claim, :no_attachments }
let(:claim) { create(:claim, :no_attachments) }

it 'yields text to state no attachments are present' do
expect { |b| confirmation_presenter.each_item(&b) }.
Expand Down
6 changes: 3 additions & 3 deletions spec/services/carrierwave_filename_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
let(:claimants_csv) { claim.additional_claimants_csv }

context 'attachment exists' do
let(:claim) { create :claim }
let(:claim) { create(:claim) }

it 'returns the filename including the extension' do
expect(described_class.for(claimants_csv)).to eq 'file.csv'
end

context 'handling filenames with non alphanumeric characters' do
let(:claim) { create :claim, :non_sanitized_attachment_filenames }
let(:claim) { create(:claim, :non_sanitized_attachment_filenames) }

context 'when underscore = true' do
it 'returns the filename with underscores' do
Expand All @@ -29,7 +29,7 @@
end

context 'attachment does not exist' do
let(:claim) { create :claim, :without_additional_claimants_csv }
let(:claim) { create(:claim, :without_additional_claimants_csv) }

it 'returns nil' do
expect(described_class.for(claimants_csv)).to be_nil
Expand Down
2 changes: 1 addition & 1 deletion spec/services/et_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

let(:mock_submit_diversity_service) { class_spy('SubmitDiversityResponseToApiService', call: mock_submit_diversity_service_instance) }
let(:mock_submit_diversity_service_instance) { instance_spy('SubmitDiversityResponseToApiService', valid?: true, errors: []) }
let(:example_diversity_response) { create :diversity }
let(:example_diversity_response) { create(:diversity) }

it 'delegates to SubmitClaimToApiService' do
expect(service).to be mock_submit_diversity_service_instance
Expand Down
2 changes: 0 additions & 2 deletions spec/services/submit_claim_to_api_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# rubocop:disable RSpec/MultipleExpectations
require 'rails_helper'

RSpec.describe SubmitClaimToApiService, type: :service do
Expand Down Expand Up @@ -336,4 +335,3 @@
end
end
end
# rubocop:enable RSpec/MultipleExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
include_context 'with build diversity response endpoint recording'
include_context 'with command matcher'
context 'typical data set' do
let(:example_diversity_response) { create :diversity }
let(:example_diversity_response) { create(:diversity) }

include_context 'with action performed before each example'
it { is_expected.to be_a_valid_api_command('BuildDiversityResponse').version(2).for_db_data(example_diversity_response) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
end

let(:null_object) { NullObject.new }
let(:claim) { build_stubbed :claim, miscellaneous_information: "hey\r\nhey" }
let(:claim) { build_stubbed(:claim, miscellaneous_information: "hey\r\nhey") }

before do
view.singleton_class.class_eval do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ET1::Test::ReviewPage.new
end
let(:claim) do
create :claim, claim_details: "wut\r\nwut", other_known_claimants: true, other_known_claimant_names: "Johnny Wishbone\r\nSamuel Pepys"
create(:claim, claim_details: "wut\r\nwut", other_known_claimants: true, other_known_claimant_names: "Johnny Wishbone\r\nSamuel Pepys")
end

let(:null_object) { NullObject.new }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
ET1::Test::ReviewPage.new
end
let(:claim) do
create :claim, desired_outcomes: [:tribunal_recommendation, :new_employment_and_compensation],
other_outcome: "25 bags\r\nyour job"
create(:claim, desired_outcomes: [:tribunal_recommendation, :new_employment_and_compensation],
other_outcome: "25 bags\r\nyour job")
end

let(:null_object) { NullObject.new }
Expand Down
4 changes: 2 additions & 2 deletions spec/views/claim_reviews/show/review_page_claim_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
end
let(:claim_type_section) { review_page.claim_type_section }
let(:claim) do
create :claim,
create(:claim,
is_unfair_dismissal: true,
discrimination_claims: [:sex_including_equal_pay, :race, :sexual_orientation],
pay_claims: [:redundancy, :other], other_claim_details: "yo\r\nyo",
is_whistleblowing: true, send_claim_to_whistleblowing_entity: false
is_whistleblowing: true, send_claim_to_whistleblowing_entity: false)
end

let(:null_object) { NullObject.new }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let(:null_object) { NullObject.new }
let(:claimant_collection_section) { review_page.group_claim }

let(:claim) { create :claim }
let(:claim) { create(:claim) }

before do
view.singleton_class.class_eval do
Expand Down Expand Up @@ -50,15 +50,15 @@ def claim_path_for(*)
end

context 'with secondary claimants' do
let(:claim) { create :claim, :without_additional_claimants_csv, :with_secondary_claimants }
let(:claim) { create(:claim, :without_additional_claimants_csv, :with_secondary_claimants) }

it 'presents the list of claimants' do
expect(claimant_collection_section.claimants[0]).to be_valid_for_model(claim.secondary_claimants[0])
end
end

context 'without secondary claimants' do
let(:claim) { create :claim, :single_claimant }
let(:claim) { create(:claim, :single_claimant) }

it 'returns "No"' do
expect(claimant_collection_section.group_claim.answer).to have_text 'No'
Expand Down
Loading