Showing 160 of 166 total issues
Method update
has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring. Open
def update
if params[:bike].present?
begin
@bike = BikeUpdator.new(user: current_user, bike: @bike, b_params: permitted_bike_params.as_json, current_ownership: @current_ownership).update_available_attributes
rescue => e
- 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 19 (exceeds 10 allowed). Consider refactoring. Open
def update
error_message = []
if params[:ownership]
if params[:ownership][:user_email].present?
params[:ownership][:user_id] = User.friendly_find_id(params[:ownership].delete(:user_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 matching_invoices
has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring. Open
def matching_invoices
@query = params[:query]
invoices = if @query == "active"
Invoice.active
elsif @query == "inactive"
- 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
Function BinxAppOrgBikes
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
function BinxAppOrgBikes() {
return {
init() {
// If there aren't search settings on the page, don't do anything
if ($("#organizedSearchSettings").length) {
Method paint_name_parser
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
def self.paint_name_parser(str)
paint_str = str.clone.downcase
paint_str.gsub!(/[\\\/"\-()?,&+;.]/, " ")
# RAL colors. See wikipedia table for rough groupings. Many of the reds are pink, greys are brown, etc. by whatever
Method available_impound_records
has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring. Open
def available_impound_records
return @available_impound_records if defined?(@available_impound_records)
if params[:search_status] == "all"
@search_status = "all"
a_impound_records = impound_records
- 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 18 (exceeds 10 allowed). Consider refactoring. Open
def update
@user = current_user
if params.dig(:user, :password).present?
unless @user.authenticate(params.dig(:user, :current_password))
@user.errors.add(:base, translation(:current_password_doesnt_match))
- 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 registered_state
has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring. Open
def registered_state(bike = nil)
state = bike&.status&.gsub("status_", "")
if state.present?
return state if state == "stolen"
if %w[abandoned impounded unregistered_parking_notification].include?(state)
- 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 authenticate_user
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def authenticate_user(translation_key: nil, translation_args: {}, flash_type: :error)
translation_key ||= :you_have_to_log_in
# Make absolutely sure the current user is confirmed - mainly for testing
if current_user&.confirmed?
- 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 find_sym
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def find_sym(str)
return if str.blank?
return str if str.is_a?(Symbol) && self::SLUGS.key?(str)
str = str.to_s.downcase.strip if str.is_a?(String) || str.is_a?(Symbol)
if str.is_a?(Integer) || str.match?(/\A\d+\z/)
- 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 available_recoveries
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def available_recoveries
recoveries = StolenRecord.recovered
if params[:search_recovery_display_status] == "all"
@recovery_display_status = "all"
- 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_parking_notifications
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def matching_parking_notifications
return @matching_parking_notifications if defined?(@matching_parking_notifications)
notifications = parking_notifications
if params[:search_bike_id].present?
notifications = notifications.where(bike_id: params[:search_bike_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 process_csv
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def process_csv(open_file)
@line_errors = @bulk_import.line_errors || [] # We always need line_errors
return false if @bulk_import.finished? # If url fails to load, this will catch
# Grab the first line of the csv (which is the header line) and transform it
- 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 row_to_b_param_hash
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def row_to_b_param_hash(row_with_whitespaces)
# remove whitespace from the values in the row
row = row_with_whitespaces.map { |k, v|
next [k, v] unless v.is_a?(String)
- 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
Consider simplifying this complex logical expression. Open
if session[:return_to].present? || cookies[:return_to].present? || params[:return_to]
# NOTE: This is duplicated in permitted_return_to
target = session[:return_to] || cookies[:return_to] || params[:return_to]
session[:return_to] = nil
cookies[:return_to] = nil
Function BinxAdminBlogs
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
function BinxAdminBlogs() {
return {
init() {
this.initializeBlogInfoToggling();
this.initializePrimaryPhotoFunctionality();
Method update
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def update
if !@impound_claim.submitting?
flash[:error] = if @impound_claim.responded?
"That claim has already been responded to"
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
Method update
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def update
@organization = Organization.friendly_find(params[:id])
if @organization.blank?
redirect_to(api_v1_not_found_url) && return
elsif params[:access_token] == @organization.access_token
- 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 16 (exceeds 10 allowed). Consider refactoring. Open
def update
if !@impound_claim.submitting?
flash[:error] = if @impound_claim.responded?
"That claim has already been responded to"
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
Method calculated_pos_kind
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def self.calculated_pos_kind(organization)
return organization.manual_pos_kind if organization.manual_pos_kind.present?
bikes = organization.created_bikes # NOTE: Only created, so regional orgs don't get them
recent_bikes = bikes.where(created_at: (Time.current - 1.week)..Time.current)
if organization.ascend_name.present? || recent_bikes.ascend_pos.count > 0
- 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"