Skip to content
Merged
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
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/components/tab_navigation_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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]) %>
</li>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/components/tab_navigation_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/idv/in_person/usps_locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/idv/phone_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/forms/recaptcha_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions app/models/in_person_enrollment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes a lot more sense to me and is more in keeping with the spirit. The "is" for something that's not a boolean is confusing; this makes it much clearer. 👍

where(status: :pending).
and(
where(enrollment_established_at: late_benchmark...(early_benchmark.end_of_day)),
Expand Down
4 changes: 2 additions & 2 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion app/presenters/two_factor_options_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this was complete unused


def initialize(
user_agent:,
Expand Down
4 changes: 2 additions & 2 deletions app/services/doc_auth/error_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/reporting/cloudwatch_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:)

Expand Down Expand Up @@ -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

Expand Down