diff --git a/.rubocop.yml b/.rubocop.yml index 094be9f7f57..30a60d3f67c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -690,6 +690,15 @@ Naming/MemoizedInstanceVariableName: Naming/MethodParameterName: MinNameLength: 2 +Naming/PredicateName: + Enabled: true + AllowedMethods: + - is_a? + ForbiddenPrefixes: + # overriding to allow "has_" + - is_ + - have_ + Naming/VariableName: Exclude: - spec/services/pii/nist_encryption_spec.rb diff --git a/app/components/tab_navigation_component.html.erb b/app/components/tab_navigation_component.html.erb index 894cc9d0d29..82723d7cd99 100644 --- a/app/components/tab_navigation_component.html.erb +++ b/app/components/tab_navigation_component.html.erb @@ -5,8 +5,8 @@ <%= render ButtonComponent.new( url: route[:path], big: true, - outline: !is_current_path?(route[:path]), - aria: { current: is_current_path?(route[:path]) ? 'page' : nil }, + outline: !current_path?(route[:path]), + aria: { current: current_path?(route[:path]) ? 'page' : nil }, ).with_content(route[:text]) %> <% end %> diff --git a/app/components/tab_navigation_component.rb b/app/components/tab_navigation_component.rb index 633182bea89..5fdf9678067 100644 --- a/app/components/tab_navigation_component.rb +++ b/app/components/tab_navigation_component.rb @@ -9,7 +9,7 @@ def initialize(label:, routes:, **tag_options) @tag_options = tag_options end - def is_current_path?(path) + def current_path?(path) recognized_path = Rails.application.routes.recognize_path(path, method: request.method) request.params[:controller] == recognized_path[:controller] && request.params[:action] == recognized_path[:action] diff --git a/app/controllers/idv/in_person/usps_locations_controller.rb b/app/controllers/idv/in_person/usps_locations_controller.rb index 9dcb0070307..24d421e52a6 100644 --- a/app/controllers/idv/in_person/usps_locations_controller.rb +++ b/app/controllers/idv/in_person/usps_locations_controller.rb @@ -26,7 +26,7 @@ def index city: search_params['city'], state: search_params['state'], zip_code: search_params['zip_code'] ) - locations = proofer.request_facilities(candidate, is_authn_context_enhanced_ipp?) + locations = proofer.request_facilities(candidate, authn_context_enhanced_ipp?) if locations.length > 0 analytics.idv_in_person_locations_searched( success: true, @@ -124,12 +124,12 @@ def enrollment end def enrollment_sponsor_id - is_authn_context_enhanced_ipp? ? + authn_context_enhanced_ipp? ? IdentityConfig.store.usps_eipp_sponsor_id : IdentityConfig.store.usps_ipp_sponsor_id end - def is_authn_context_enhanced_ipp? + def authn_context_enhanced_ipp? resolved_authn_context_result.enhanced_ipp? end diff --git a/app/controllers/idv/phone_controller.rb b/app/controllers/idv/phone_controller.rb index ed676b6ad94..5e50af67ce5 100644 --- a/app/controllers/idv/phone_controller.rb +++ b/app/controllers/idv/phone_controller.rb @@ -199,16 +199,16 @@ def async_state_done(async_state) end end - def is_req_from_frontend? + def frontend_request? request.headers['HTTP_X_FORM_STEPS_WAIT'] == '1' end - def is_req_from_verify_step? + def verify_step_request? request.referer == idv_verify_info_url end def should_keep_flash_success? - is_req_from_frontend? && is_req_from_verify_step? + frontend_request? && verify_step_request? end def new_phone_added? diff --git a/app/controllers/users/two_factor_authentication_setup_controller.rb b/app/controllers/users/two_factor_authentication_setup_controller.rb index c6c16fd86fe..7804b188d15 100644 --- a/app/controllers/users/two_factor_authentication_setup_controller.rb +++ b/app/controllers/users/two_factor_authentication_setup_controller.rb @@ -16,7 +16,7 @@ def index @presenter = two_factor_options_presenter analytics.user_registration_2fa_setup_visit( enabled_mfa_methods_count:, - gov_or_mil_email: gov_or_mil_email?, + gov_or_mil_email: has_gov_or_mil_email?, ) end @@ -44,7 +44,7 @@ def two_factor_options_form private - def gov_or_mil_email? + def has_gov_or_mil_email? current_user.confirmed_email_addresses.any?(&:gov_or_mil?) end diff --git a/app/forms/recaptcha_form.rb b/app/forms/recaptcha_form.rb index 1ddd6fa9ee9..b4bf38dff53 100644 --- a/app/forms/recaptcha_form.rb +++ b/app/forms/recaptcha_form.rb @@ -83,7 +83,7 @@ def recaptcha_result end success, score, error_codes = response.body.values_at('success', 'score', 'error-codes') - errors, reasons = error_codes.to_a.partition { |error_code| is_result_error?(error_code) } + errors, reasons = error_codes.to_a.partition { |error_code| result_error?(error_code) } RecaptchaResult.new(success:, score:, errors:, reasons:) end @@ -105,7 +105,7 @@ def recaptcha_result_valid?(result) end end - def is_result_error?(error_code) + def result_error?(error_code) RESULT_ERRORS.include?(error_code) end diff --git a/app/models/in_person_enrollment.rb b/app/models/in_person_enrollment.rb index 971b354a509..e15ecd41222 100644 --- a/app/models/in_person_enrollment.rb +++ b/app/models/in_person_enrollment.rb @@ -37,14 +37,14 @@ class InPersonEnrollment < ApplicationRecord class << self def needs_early_email_reminder(early_benchmark, late_benchmark) - is_pending_and_established_between( + pending_and_established_between( early_benchmark, late_benchmark, ).where(early_reminder_sent: false) end def needs_late_email_reminder(early_benchmark, late_benchmark) - is_pending_and_established_between( + pending_and_established_between( early_benchmark, late_benchmark, ).where(late_reminder_sent: false) @@ -84,7 +84,7 @@ def generate_unique_id private - def is_pending_and_established_between(early_benchmark, late_benchmark) + def pending_and_established_between(early_benchmark, late_benchmark) where(status: :pending). and( where(enrollment_established_at: late_benchmark...(early_benchmark.end_of_day)), diff --git a/app/models/profile.rb b/app/models/profile.rb index 1b7b2caeb44..2b455e41000 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -82,7 +82,7 @@ def gpo_verification_pending? def pending_reasons [ *(:gpo_verification_pending if gpo_verification_pending?), - *(:fraud_check_pending if has_fraud_deactivation_reason?), + *(:fraud_check_pending if fraud_deactivation_reason?), *(:in_person_verification_pending if in_person_verification_pending?), ] end @@ -179,7 +179,7 @@ def deactivate(reason) update!(active: false, deactivation_reason: reason) end - def has_fraud_deactivation_reason? + def fraud_deactivation_reason? fraud_review_pending? || fraud_rejection? end diff --git a/app/presenters/two_factor_options_presenter.rb b/app/presenters/two_factor_options_presenter.rb index 83a0d4434f7..76e8c3b361a 100644 --- a/app/presenters/two_factor_options_presenter.rb +++ b/app/presenters/two_factor_options_presenter.rb @@ -11,7 +11,6 @@ class TwoFactorOptionsPresenter :user_agent delegate :two_factor_enabled?, to: :mfa_policy - delegate :has_gov_or_mil_email?, to: :user, prefix: :user def initialize( user_agent:, diff --git a/app/services/doc_auth/error_generator.rb b/app/services/doc_auth/error_generator.rb index 51b5033c1ac..5dc35d1627f 100644 --- a/app/services/doc_auth/error_generator.rb +++ b/app/services/doc_auth/error_generator.rb @@ -172,7 +172,7 @@ def handle(response_info) liveness_enabled = response_info[:liveness_enabled] selfie_error = get_selfie_error(liveness_enabled, response_info) - if is_generic_selfie_error?(selfie_error) + if generic_selfie_error?(selfie_error) selfie_general_failure_error else error = selfie_error @@ -181,7 +181,7 @@ def handle(response_info) end end - def is_generic_selfie_error?(error) + def generic_selfie_error?(error) error == Errors::SELFIE_FAILURE end diff --git a/lib/reporting/cloudwatch_client.rb b/lib/reporting/cloudwatch_client.rb index 3404726d7d4..68c403b7e87 100644 --- a/lib/reporting/cloudwatch_client.rb +++ b/lib/reporting/cloudwatch_client.rb @@ -97,7 +97,7 @@ def fetch(query:, from: nil, to: nil, time_slices: nil) response = fetch_one(query:, start_time:, end_time:) with_progress_bar(&:increment) - if ensure_complete_logs? && has_more_results?(response.results.size) + if ensure_complete_logs? && more_results?(response.results.size) log(:info, "more results, bisecting: start_time=#{start_time} end_time=#{end_time}") mid = midpoint(start_time:, end_time:) @@ -228,7 +228,7 @@ def log(level, message) # somehow sample responses returned 10,001 rows when we request 10,000 # so we check for more than the limit - def has_more_results?(size) + def more_results?(size) size >= MAX_RESULTS_LIMIT end