Showing 161 of 167 total issues
Method find_or_new_from_token
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
def self.find_or_new_from_token(toke = nil, user_id: nil, organization_id: nil, bike_sticker: nil)
b = where(creator_id: user_id, id_token: toke).first if toke.present? && user_id.present?
b ||= with_organization_or_no_creator(toke)
b ||= BParam.new(creator_id: user_id, params: {revised_new: true}.as_json)
b.creator_id ||= user_id
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method calculated_enabled_feature_slugs
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
def calculated_enabled_feature_slugs
fslugs = current_invoices.feature_slugs
# If part of a region with bike_stickers, the organization receives the stickers organization feature
if regional_parents.any?
if regional_parents.any? { |o| o.enabled?("bike_stickers") }
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method update
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
def update
@user_alert = current_user.user_alerts.find_by_id(params[:id])
if @user_alert.present?
if params[:alert_action] == "dismiss"
if @user_alert.dismissable?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method user_info
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
def user_info
return {} unless current_scopes.include?("read_user")
{
user: {
username: current_user.username,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method perform
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
def perform(graduated_notification_id, marked_remaining_by_id = nil)
graduated_notification = GraduatedNotification.find(graduated_notification_id)
if graduated_notification.marked_remaining?
return unless graduated_notification.user_registration_organization&.deleted_at.present?
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method sortable
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def sortable(column, title = nil, html_options = {})
if title.is_a?(Hash) # If title is a hash, it wasn't passed
html_options = title
title = nil
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if str_length < 15
vowel_percent
elsif str_length < 30
vowel_percent + 15
else
Avoid deeply nested control flow statements. Open
elsif feedback_type.match?("bike_recovery")
recover_bike(bike, feedback)
Avoid deeply nested control flow statements. Open
if bike.manufacturer_id.present?
bike.save
feedback.feedback_hash[:new_manufacturer] = bike.manufacturer.name
end
Method user_badges
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def self.user_badges(user)
return [] unless user.present?
return [:user_banned] if user.banned
return [:user_ambassador] if user.ambassador?
badges = []
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method matching_notifications
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def matching_notifications
notifications = Notification
if permitted_scopes.include?(params[:search_kind])
@kind = params[:search_kind]
notifications = notifications.send(@kind)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
flash[:success] = if @user.memberships.any?
translation(:you_can_use_bike_index_as_org, org_name: @user.memberships.first.organization.name)
else
translation(:thanks_for_accepting_tos)
end
Avoid deeply nested control flow statements. Open
if bike.manufacturer_other.present?
feedback.feedback_hash[:old_manufacturer] += " (#{bike.manufacturer_other})"
bike.manufacturer_other = nil
end
Method searchable_query_items_colors
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def searchable_query_items_colors(query_params)
# params[:colors] should be an array (or a comma delineated string) - otherwise we parse out of the query string
if query_params[:colors].present?
colors = query_params[:colors].is_a?(String) ? query_params[:colors].split(",") : query_params[:colors]
return {colors: colors.map { |id| Color.friendly_find_id(id) }.compact}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method v2_params
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def self.v2_params(hash)
h = hash["bike"].present? ? hash : {"bike" => hash.with_indifferent_access}
# Only assign if the key hasn't been assigned - since it's boolean, can't use conditional assignment
h["bike"]["serial_number"] = h["bike"].delete "serial" if h["bike"].key?("serial")
h["bike"]["send_email"] = !(h["bike"].delete "no_notify") unless h["bike"].key?("send_email")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method current_page_skeleton
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def current_page_skeleton
return "organized_skeleton" if controller_namespace == "organized" && action_name != "landing"
return nil if @force_landing_page_render
case controller_name
when "bikes"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method set_calculated_attributes
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def set_calculated_attributes
self.initial_record_id ||= potential_initial_record&.id if is_repeat
self.repeat_number ||= calculated_repeat_number
self.resolved_at ||= calculated_resolved_at # Used by by calculated_status, so must come first
self.status = calculated_status
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method update
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def update
if params[:resend_confirmation].present?
if @user_phone.confirmed?
flash[:error] = "That phone number is already confirmed!"
else
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
elsif vowel_percent > 40
vowel_percent - 40
else
0
Function PeriodSelector
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
function PeriodSelector() {
return {
init() {
this.autoSubmit = !(
$("#timeSelectionBtnGroup").attr("data-nosubmit") == "true"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"