diff --git a/.erb-lint.yml b/.erb-lint.yml index 5d41947974a..78dd764abf1 100644 --- a/.erb-lint.yml +++ b/.erb-lint.yml @@ -13,6 +13,8 @@ linters: Enabled: false Rails/OutputSafety: Enabled: false + Lint/UselessAssignment: + Enabled: false DeprecatedClasses: enabled: true rule_set: diff --git a/.rubocop.yml b/.rubocop.yml index 43f1d32e887..ff08dc1443a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -590,6 +590,9 @@ Lint/UriEscapeUnescape: Lint/UriRegexp: Enabled: true +Lint/UselessAssignment: + Enabled: true + Lint/UselessElseWithoutRescue: Enabled: true diff --git a/app/services/analytics.rb b/app/services/analytics.rb index b0e7c6209d1..4638728f1b6 100644 --- a/app/services/analytics.rb +++ b/app/services/analytics.rb @@ -80,7 +80,7 @@ def register_doc_auth_step_from_analytics_event(event, attributes) def track_mfa_submit_event(attributes) track_event(MULTI_FACTOR_AUTH, attributes) - mfa_event_type = (attributes[:success] ? 'success' : 'fail') + attributes[:success] ? 'success' : 'fail' end attr_reader :user, :request, :sp, :ahoy diff --git a/app/services/db/monthly_sp_auth_count/total_monthly_auth_counts_within_iaa_window.rb b/app/services/db/monthly_sp_auth_count/total_monthly_auth_counts_within_iaa_window.rb index 16aec58f44e..eb16b4651fe 100644 --- a/app/services/db/monthly_sp_auth_count/total_monthly_auth_counts_within_iaa_window.rb +++ b/app/services/db/monthly_sp_auth_count/total_monthly_auth_counts_within_iaa_window.rb @@ -89,7 +89,7 @@ def full_month_subquery(issuer:, full_months:) year_months: full_months.map { |r| r.begin.strftime('%Y%m') }, }.transform_values { |value| quote(value) } - full_month_subquery = format(<<~SQL, params) + format(<<~SQL, params) SELECT monthly_sp_auth_counts.user_id , monthly_sp_auth_counts.year_month diff --git a/app/services/db/monthly_sp_auth_count/unique_monthly_auth_counts_by_iaa.rb b/app/services/db/monthly_sp_auth_count/unique_monthly_auth_counts_by_iaa.rb index 0a32776d2f0..498ead6e2f3 100644 --- a/app/services/db/monthly_sp_auth_count/unique_monthly_auth_counts_by_iaa.rb +++ b/app/services/db/monthly_sp_auth_count/unique_monthly_auth_counts_by_iaa.rb @@ -84,7 +84,7 @@ def full_month_subquery(issuers:, full_months:) year_months: full_months.map { |r| r.begin.strftime('%Y%m') }, }.transform_values { |value| quote(value) } - full_month_subquery = format(<<~SQL, params) + format(<<~SQL, params) SELECT monthly_sp_auth_counts.user_id , monthly_sp_auth_counts.year_month diff --git a/app/services/piv_cac_service.rb b/app/services/piv_cac_service.rb index beb18fa73ff..9754b1be04f 100644 --- a/app/services/piv_cac_service.rb +++ b/app/services/piv_cac_service.rb @@ -71,7 +71,7 @@ def token_response(token) ) do |req| req.options.context = { service_name: 'piv_cac_token' } end - rescue Faraday::ConnectionFailed, Faraday::TimeoutError => e + rescue Faraday::ConnectionFailed, Faraday::TimeoutError nil end diff --git a/config/application.rb b/config/application.rb index 7423088bf5d..4163a3df090 100644 --- a/config/application.rb +++ b/config/application.rb @@ -67,7 +67,7 @@ class Application < Rails::Application # see config/initializers/job_configurations.rb for cron schedule includes_star_queue = config.good_job.queues.split(';').any? do |name_threads| - name, threads = name_threads.split(':', 2) + name, _threads = name_threads.split(':', 2) name == '*' end raise 'good_job.queues does not contain *, but it should' if !includes_star_queue diff --git a/config/initializers/job_configurations.rb b/config/initializers/job_configurations.rb index 862900a431c..bc6ead33794 100644 --- a/config/initializers/job_configurations.rb +++ b/config/initializers/job_configurations.rb @@ -1,10 +1,7 @@ cron_5m = '0/5 * * * *' -interval_5m = 5 * 60 cron_1h = '0 * * * *' -interval_1h = 60 * 60 cron_24h = '0 0 * * *' gpo_cron_24h = '0 10 * * *' # 10am UTC is 5am EST/6am EDT -inteval_24h = 24 * 60 * 60 if defined?(Rails::Console) Rails.logger.info 'job_configurations: console detected, skipping schedule' diff --git a/lib/analytics_events_documenter.rb b/lib/analytics_events_documenter.rb index fbebd9fe6ba..c0ab6836858 100644 --- a/lib/analytics_events_documenter.rb +++ b/lib/analytics_events_documenter.rb @@ -93,8 +93,6 @@ def missing_documentation # @return [{ events: Array}] def as_json events_json_summary = analytics_methods.map do |method_object| - param_names = method_object.parameters.map { |p| p.first.chomp(':') } - attributes = method_object.tags('param').map do |tag| { name: tag.name, diff --git a/lib/tasks/newrelic.rake b/lib/tasks/newrelic.rake index e39de8bca3e..9ecfe0b4490 100644 --- a/lib/tasks/newrelic.rake +++ b/lib/tasks/newrelic.rake @@ -13,6 +13,6 @@ namespace :newrelic do task deployment: :environment do require 'new_relic/cli/command' revision = `git rev-parse HEAD`.chomp - NewRelic::Cli::Deployments.new(revision: `git rev-parse HEAD`).run + NewRelic::Cli::Deployments.new(revision: revision).run end end diff --git a/spec/controllers/idv/doc_auth_controller_spec.rb b/spec/controllers/idv/doc_auth_controller_spec.rb index e908dc9b584..bcf299095c6 100644 --- a/spec/controllers/idv/doc_auth_controller_spec.rb +++ b/spec/controllers/idv/doc_auth_controller_spec.rb @@ -138,13 +138,6 @@ mock_next_step(:back_image) allow_any_instance_of(Flow::BaseFlow).to \ receive(:flow_session).and_return(pii_from_doc: {}) - result = { - success: true, - errors: {}, - step: 'ssn', - step_count: 1, - pii_like_keypaths: [[:errors, :ssn], [:error_details, :ssn]], - } put :update, params: { step: 'ssn', doc_auth: { step: 'ssn', ssn: '666-66-6666' } } put :update, params: { step: 'ssn', doc_auth: { step: 'ssn', ssn: '111-11-1111' } } diff --git a/spec/controllers/idv_controller_spec.rb b/spec/controllers/idv_controller_spec.rb index 85b04d2c0e7..c00fcb29841 100644 --- a/spec/controllers/idv_controller_spec.rb +++ b/spec/controllers/idv_controller_spec.rb @@ -71,7 +71,7 @@ end context 'no SP context' do - let(:user) { user = build(:user, password: ControllerHelper::VALID_PASSWORD) } + let(:user) { build(:user, password: ControllerHelper::VALID_PASSWORD) } before do stub_sign_in(user) diff --git a/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb index 47265188ebf..192b5e6c36d 100644 --- a/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb @@ -30,7 +30,7 @@ it 'redirects to the two_factor_options page if user is IAL2' do profile = create(:profile, :active, :verified, pii: { ssn: '1234' }) user = profile.user - raw_key = PersonalKeyGenerator.new(user).create + PersonalKeyGenerator.new(user).create stub_sign_in_before_2fa(user) get :show @@ -86,7 +86,6 @@ profile = create(:profile, :active, :verified, pii: { ssn: '1234' }) user = profile.user raw_key = PersonalKeyGenerator.new(user).create - old_key = user.reload.encrypted_recovery_code_digest stub_sign_in_before_2fa(user) post :create, params: { personal_key_form: { personal_key: raw_key } } diff --git a/spec/features/idv/doc_auth/send_link_step_spec.rb b/spec/features/idv/doc_auth/send_link_step_spec.rb index c0d08df63d0..d04343c209c 100644 --- a/spec/features/idv/doc_auth/send_link_step_spec.rb +++ b/spec/features/idv/doc_auth/send_link_step_spec.rb @@ -81,7 +81,7 @@ it 'throttles sending the link' do allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics) - user = sign_in_and_2fa_user + sign_in_and_2fa_user complete_doc_auth_steps_before_send_link_step timeout = distance_of_time_in_words(Throttle.attempt_window_in_minutes(:idv_send_link).minutes) freeze_time do diff --git a/spec/features/idv/steps/confirmation_step_spec.rb b/spec/features/idv/steps/confirmation_step_spec.rb index 2dbf7bc1fce..b69c5a6dd1b 100644 --- a/spec/features/idv/steps/confirmation_step_spec.rb +++ b/spec/features/idv/steps/confirmation_step_spec.rb @@ -9,8 +9,6 @@ context 'personal key information and actions' do before do - personal_key = 'a1b2c3d4e5f6g7h8' - @user = sign_in_and_2fa_user visit idv_path diff --git a/spec/features/users/password_recovery_via_recovery_code_spec.rb b/spec/features/users/password_recovery_via_recovery_code_spec.rb index ca7bdafba58..efc32532fb1 100644 --- a/spec/features/users/password_recovery_via_recovery_code_spec.rb +++ b/spec/features/users/password_recovery_via_recovery_code_spec.rb @@ -59,7 +59,7 @@ end scenario 'resets password, not allowed to use personal key as 2fa', email: true do - personal_key = personal_key_from_pii(user, pii) + _personal_key = personal_key_from_pii(user, pii) trigger_reset_password_and_click_email_link(user.email) reset_password_and_sign_back_in(user, new_password) diff --git a/spec/forms/new_phone_form_spec.rb b/spec/forms/new_phone_form_spec.rb index 2f2d0b02c9f..f2472fb934d 100644 --- a/spec/forms/new_phone_form_spec.rb +++ b/spec/forms/new_phone_form_spec.rb @@ -154,7 +154,7 @@ it 'is invalid' do phone = PhoneFormatter.format('+1 (954) 525-1262', country_code: 'US') params[:phone] = phone - phone_configuration = create(:phone_configuration, user: user, phone: phone) + create(:phone_configuration, user: user, phone: phone) result = subject.submit(params) @@ -167,7 +167,7 @@ raw_phone = '+1 954 5251262' phone = PhoneFormatter.format(raw_phone, country_code: 'US') params[:phone] = phone - phone_configuration = create(:phone_configuration, user: user, phone: raw_phone) + create(:phone_configuration, user: user, phone: raw_phone) result = subject.submit(params) diff --git a/spec/forms/otp_verification_form_spec.rb b/spec/forms/otp_verification_form_spec.rb index 9350e9aad95..4ea05acc98c 100644 --- a/spec/forms/otp_verification_form_spec.rb +++ b/spec/forms/otp_verification_form_spec.rb @@ -44,7 +44,6 @@ invalid_codes.each do |code| form = OtpVerificationForm.new(user, code) - result = instance_double(FormResponse) allow(user).to receive(:authenticate_direct_otp).with(code).and_return(true) result = FormResponse.new( diff --git a/spec/forms/register_user_email_form_spec.rb b/spec/forms/register_user_email_form_spec.rb index bb543e0b63f..4f93cff2c23 100644 --- a/spec/forms/register_user_email_form_spec.rb +++ b/spec/forms/register_user_email_form_spec.rb @@ -33,7 +33,7 @@ end it 'creates throttle events after reaching throttle limit' do - existing_user = create(:user, :signed_up, email: 'taken@example.com') + create(:user, :signed_up, email: 'taken@example.com') (IdentityConfig.store.reg_confirmed_email_max_attempts + 1).times do subject.submit(email: 'TAKEN@example.com', terms_accepted: '1') @@ -72,7 +72,7 @@ end it 'creates throttle events after reaching throttle limit' do - user = create(:user, email: 'test@example.com', confirmed_at: nil, uuid: '123') + create(:user, email: 'test@example.com', confirmed_at: nil, uuid: '123') (IdentityConfig.store.reg_unconfirmed_email_max_attempts + 1).times do subject.submit(email: 'test@example.com', terms_accepted: '1') end diff --git a/spec/forms/verify_password_form_spec.rb b/spec/forms/verify_password_form_spec.rb index 59660899be1..b46008443f3 100644 --- a/spec/forms/verify_password_form_spec.rb +++ b/spec/forms/verify_password_form_spec.rb @@ -7,7 +7,7 @@ password = 'cab123DZN456' user = create(:user, password: password) pii = { ssn: '111111111' } - profile = create(:profile, user: user, deactivation_reason: :password_reset, pii: pii) + create(:profile, user: user, deactivation_reason: :password_reset, pii: pii) form = VerifyPasswordForm.new( user: user, password: password, @@ -25,7 +25,7 @@ password = 'cab123DZN456' user = create(:user, password: password) pii = { ssn: '111111111' } - profile = create(:profile, user: user, deactivation_reason: :password_reset, pii: pii) + create(:profile, user: user, deactivation_reason: :password_reset, pii: pii) form = VerifyPasswordForm.new( user: user, password: "#{password}a", diff --git a/spec/jobs/remove_old_throttles_job_spec.rb b/spec/jobs/remove_old_throttles_job_spec.rb index eda7cf330ab..a42dd95aa5d 100644 --- a/spec/jobs/remove_old_throttles_job_spec.rb +++ b/spec/jobs/remove_old_throttles_job_spec.rb @@ -11,7 +11,7 @@ subject(:perform) { job.perform(now, limit: limit, total_limit: total_limit) } it 'deletes throttles that are older than WINDOW' do - old_throttle = create(:throttle, target: SecureRandom.hex, updated_at: now - 45.days) + _old_throttle = create(:throttle, target: SecureRandom.hex, updated_at: now - 45.days) new_throttle = create(:throttle, target: SecureRandom.hex, updated_at: now) perform diff --git a/spec/jobs/reports/agency_invoice_iaa_supplement_report_spec.rb b/spec/jobs/reports/agency_invoice_iaa_supplement_report_spec.rb index 5c8b635d59b..bf659fe3bb8 100644 --- a/spec/jobs/reports/agency_invoice_iaa_supplement_report_spec.rb +++ b/spec/jobs/reports/agency_invoice_iaa_supplement_report_spec.rb @@ -164,6 +164,8 @@ iaa_end_date: iaa2_range.end.to_s, }, ] + + expect(results).to match_array(rows) end end diff --git a/spec/lib/telephony/otp_sender_spec.rb b/spec/lib/telephony/otp_sender_spec.rb index 00e74223419..dcf4ecf3e79 100644 --- a/spec/lib/telephony/otp_sender_spec.rb +++ b/spec/lib/telephony/otp_sender_spec.rb @@ -258,7 +258,7 @@ describe '#authentication_message' do let(:sender) do - sender = Telephony::OtpSender.new( + Telephony::OtpSender.new( to: '+18888675309', otp: 'ABC123', channel: 'sms', @@ -306,7 +306,7 @@ describe '#confirmation_message' do let(:sender) do - sender = Telephony::OtpSender.new( + Telephony::OtpSender.new( to: '+18888675309', otp: 'ABC123', channel: 'sms', diff --git a/spec/lib/telephony/pinpoint/aws_credential_builder_spec.rb b/spec/lib/telephony/pinpoint/aws_credential_builder_spec.rb index 282a6aedb34..a5448aadf70 100644 --- a/spec/lib/telephony/pinpoint/aws_credential_builder_spec.rb +++ b/spec/lib/telephony/pinpoint/aws_credential_builder_spec.rb @@ -43,7 +43,6 @@ end it 'returns nil if STS raises a Seahorse::Client::NetworkingError' do - expected_credential = instance_double(Aws::AssumeRoleCredentials) expect(Aws::STS::Client).to receive(:new).and_raise( Seahorse::Client::NetworkingError.new(Net::ReadTimeout.new), ) diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 26de8a68908..878879d46c9 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -300,7 +300,6 @@ def expect_email_body_to_have_help_and_contact_links end it 'renders the body' do - reset_text = t('user_mailer.account_reset_granted.cancel_link_text') expect(mail.html_part.body).to have_content( strip_tags( t('user_mailer.account_reset_request.intro_html', app_name: APP_NAME), diff --git a/spec/models/phone_number_opt_out_spec.rb b/spec/models/phone_number_opt_out_spec.rb index 3c64f6162d2..942681208af 100644 --- a/spec/models/phone_number_opt_out_spec.rb +++ b/spec/models/phone_number_opt_out_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' RSpec.describe PhoneNumberOptOut do - let(:phone) { phone = Faker::PhoneNumber.cell_phone } + let(:phone) { Faker::PhoneNumber.cell_phone } describe '.create_or_find_by_phone' do it 'creates a record for the phone' do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5cfd7e011f5..a0bb7410793 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -93,7 +93,6 @@ class Analytics config.before(:each) do DocAuth::Mock::DocAuthMockClient.reset! - original_queue_adapter = ActiveJob::Base.queue_adapter descendants = ActiveJob::Base.descendants + [ActiveJob::Base] ActiveJob::Base.queue_adapter = :inline diff --git a/spec/services/analytics_spec.rb b/spec/services/analytics_spec.rb index 2403cdd4129..bb6134eb9c8 100644 --- a/spec/services/analytics_spec.rb +++ b/spec/services/analytics_spec.rb @@ -82,7 +82,6 @@ end it 'tracks the user passed in to the track_event method' do - current_user = build_stubbed(:user, uuid: '123') tracked_user = build_stubbed(:user, uuid: '456') analytics_hash = { diff --git a/spec/services/idv/actions/verify_document_status_action_spec.rb b/spec/services/idv/actions/verify_document_status_action_spec.rb index 1299dae6eab..776a929b040 100644 --- a/spec/services/idv/actions/verify_document_status_action_spec.rb +++ b/spec/services/idv/actions/verify_document_status_action_spec.rb @@ -46,7 +46,7 @@ end it 'calls analytics if missing from no document capture session' do - response = subject.call + subject.call expect(analytics).to have_logged_event('Proofing Document Result Missing', {}) expect(analytics).to have_logged_event( @@ -65,7 +65,7 @@ expect(subject).to receive(:verify_document_capture_session). and_return(verify_document_capture_session).at_least(:once) - response = subject.call + subject.call expect(analytics).to have_logged_event('Proofing Document Result Missing', {}) expect(analytics).to have_logged_event( diff --git a/spec/services/phone_confirmation/confirmaton_session_spec.rb b/spec/services/phone_confirmation/confirmaton_session_spec.rb index 694073b412a..82d10a9d42e 100644 --- a/spec/services/phone_confirmation/confirmaton_session_spec.rb +++ b/spec/services/phone_confirmation/confirmaton_session_spec.rb @@ -74,7 +74,7 @@ it 'returns false if the code does not match' do bad_code = '1' * (TwoFactorAuthenticatable::DIRECT_OTP_LENGTH - 1) - expect(subject.matches_code?('11111')).to eq(false) + expect(subject.matches_code?(bad_code)).to eq(false) end it 'uses a secure comparison' do diff --git a/spec/services/proofing/base_spec.rb b/spec/services/proofing/base_spec.rb index eba20a37924..4b5f9e8715f 100644 --- a/spec/services/proofing/base_spec.rb +++ b/spec/services/proofing/base_spec.rb @@ -274,7 +274,7 @@ def hello(applicant, results) it 'does not affect the other proofer' do # This is an explicit check for class-level side effects - impl2 = Class.new(Proofing::Base) do + _impl2 = Class.new(Proofing::Base) do required_attributes :foobarbaz end expect(subject.exception?).to eq(false) diff --git a/spec/support/deprecated_classes.rb b/spec/support/deprecated_classes.rb index d1af3047353..333b672b558 100644 --- a/spec/support/deprecated_classes.rb +++ b/spec/support/deprecated_classes.rb @@ -11,7 +11,7 @@ def self.deprecated_classes def modified_tag_option(key, value, *rest) original_result = original_tag_option(key, value, *rest) return original_result unless key.to_s == 'class' - attribute, classes = original_result.split('=') + _attribute, classes = original_result.split('=') classes = classes.tr('"', '').split(/ +/) regex = self.class.deprecated_classes.find { |r| classes.any? { |c| r =~ c } } raise "CSS class '#{value}' matched regex for deprecated classes #{regex}" if regex diff --git a/spec/support/features/document_capture_step_helper.rb b/spec/support/features/document_capture_step_helper.rb index f09fb49e2df..cbff3582439 100644 --- a/spec/support/features/document_capture_step_helper.rb +++ b/spec/support/features/document_capture_step_helper.rb @@ -46,7 +46,7 @@ def simulate_image_upload_api_submission connection = Faraday.new(url: document_capture_endpoint_host) do |conn| conn.request(:multipart) end - response = connection.post document_capture_endpoint_path, image_upload_api_payload + connection.post document_capture_endpoint_path, image_upload_api_payload page.execute_script('document.querySelector(".js-document-capture-form").submit();') end @@ -59,7 +59,7 @@ def document_capture_session_uuid end def document_capture_endpoint_uri - URI.parse(endpoint = document_capture_form['data-endpoint']) + URI.parse(document_capture_form['data-endpoint']) end def document_capture_endpoint_host diff --git a/spec/support/shared_examples/sign_in.rb b/spec/support/shared_examples/sign_in.rb index 40d203411d6..99792304e4d 100644 --- a/spec/support/shared_examples/sign_in.rb +++ b/spec/support/shared_examples/sign_in.rb @@ -62,7 +62,6 @@ shared_examples 'signing in as IAL2 with personal key' do |sp| it 'does not present personal key as an MFA option', :email do user = create_ial2_account_go_back_to_sp_and_sign_out(sp) - pii = { ssn: '666-66-1234', dob: '1920-01-01', first_name: 'alice' } Capybara.reset_sessions!