Showing 160 of 166 total issues
Class Export
has 43 methods (exceeds 40 allowed). Consider refactoring. Open
class Export < ApplicationRecord
PROGRESS_ENUM = %i[pending ongoing finished errored].freeze
VALID_KINDS = %i[organization stolen manufacturer].freeze
VALID_FILE_FORMATS = %i[csv xlsx].freeze
DEFAULT_HEADERS = %w[link registered_at manufacturer model color serial is_stolen].freeze
Method search_organization_bikes
has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring. Open
def search_organization_bikes
@permitted_org_bike_search_params = permitted_org_bike_search_params.except(:stolenness, :timezone, :period).values.reject(&:blank?)
@search_query_present = permitted_org_bike_search_params.except(:stolenness, :timezone, :period).values.reject(&:blank?).any?
@interpreted_params = Bike.searchable_interpreted_params(permitted_org_bike_search_params, ip: forwarded_ip_address)
org = current_organization || passive_organization
- 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 resolve_token
has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring. Open
def resolve_token
if params[:token_type] == "graduated_notification"
matching_notification = GraduatedNotification.where(bike_id: @bike.id, marked_remaining_link_token: params[:token]).first
if matching_notification.present? && matching_notification.processed?
if matching_notification.marked_remaining_at.blank?
- 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 23 (exceeds 10 allowed). Consider refactoring. Open
def set_calculated_attributes
self.kind ||= calculated_kind
if imported_tweet?
self.body_html ||= self.class.auto_link_text(trh[:text]) if trh.dig(:text).present?
self.alignment ||= VALID_ALIGNMENTS.first
- 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 23 (exceeds 10 allowed). Consider refactoring. Open
def perform(bike_id)
bike = Bike.unscoped.find_by_id(bike_id)
return true if bike.blank?
should_delete = bike.blank? || bike.deleted_at.present? || bike.example ||
- 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 bikes_header_tags
has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring. Open
def bikes_header_tags
meta_overrides = {}
if (action_name == "new" || action_name == "create") && @bike.status_stolen?
self.page_title = translation_title(location: "meta_titles.bikes_new_stolen")
self.page_description = translation_description(location: "meta_descriptions.bikes_new_stolen")
- 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
Class Invoice
has 42 methods (exceeds 40 allowed). Consider refactoring. Open
class Invoice < ApplicationRecord
include Amountable # included for formatting stuff
belongs_to :organization
belongs_to :first_invoice, class_name: "Invoice" # Use subscription_first_invoice_id + subscription_first_invoice, NOT THIS
Method set_calculated_attributes
has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring. Open
def set_calculated_attributes
return true unless name.present?
self.name = strip_name_tags(name)
self.name = "Stop messing about" unless name[/\d|\w/].present?
self.website = Urlifyer.urlify(website) if website.present?
- 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 searched_theft_alerts
has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring. Open
def searched_theft_alerts
@search_recovered = InputNormalizer.boolean(params[:search_recovered])
theft_alerts = if @search_recovered
stolen_record_ids = StolenRecord.recovered.with_theft_alerts
.where(theft_alerts: {created_at: @time_range}).pluck(: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 perform
has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring. Open
def perform(user_id, user = nil, skip_bike_update = false)
user ||= User.find_by_id(user_id)
return false unless user.present?
# Bump updated_at to bust cache
user.update(updated_at: Time.current, skip_update: 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"
Further reading
Method matching_payments
has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring. Open
def matching_payments
return @matching_payments if defined?(@matching_payments)
matching_payments = Payment
if sort_column == "invoice_id"
matching_payments = matching_payments.where.not(invoice_id: nil)
- 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 22 (exceeds 10 allowed). Consider refactoring. Open
def perform(impound_record_id)
impound_record = ImpoundRecord.find(impound_record_id)
bike = impound_record.bike
if impound_record.organized?
impound_configuration = impound_record.impound_configuration
- 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 BinxAdminImageUploader
has 77 lines of code (exceeds 50 allowed). Consider refactoring. Open
function BinxAdminImageUploader() {
return {
init() {
this.uppyFileUpload();
},
Method clean_frame_size
has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring. Open
def clean_frame_size
return true unless frame_size.present? || frame_size_number.present?
if frame_size.present? && frame_size.match(/\d+\.?\d*/).present?
# Don't overwrite frame_size_number if frame_size_number was passed
if frame_size_number.blank? || !frame_size_number_changed?
- 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 clean_frame_size
has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring. Open
def clean_frame_size
return true unless frame_size.present? || frame_size_number.present?
if frame_size.present? && frame_size.match(/\d+\.?\d*/).present?
# Don't overwrite frame_size_number if frame_size_number was passed
if frame_size_number.blank? || !frame_size_number_changed?
- 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 creation_badges
has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring. Open
def self.creation_badges(ownership = nil, bike = nil)
return [] unless ownership.present?
return [:example_bike] if bike&.example?
return [:created_at_point_of_sale] if ownership.pos?
c_badges = [creation_age_badge(bike || ownership.bike)].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 add_bike_book_data
has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring. Open
def add_bike_book_data(b_param = nil)
return nil unless b_param&.bike.present? && b_param.manufacturer_id.present?
return nil unless b_param.bike["frame_model"].present? && b_param.bike["year"].present?
bb_data = BikeBookIntegration.new.get_model({
manufacturer: Manufacturer.find(b_param.bike["manufacturer_id"]).name,
- 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 index
has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring. Open
def index
@page = params[:page] || 1
set_period
@bike_sticker = BikeSticker.lookup_with_fallback(params[:bike_sticker], organization_id: current_organization.id) if params[:bike_sticker].present?
if current_organization.enabled?("bike_search")
- 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_bulk_imports
has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring. Open
def matching_bulk_imports
return @matching_bulk_imports if defined?(@matching_bulk_imports)
bulk_imports = BulkImport
if params[:search_ascend].present?
bulk_imports = bulk_imports.ascend
- 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
@user = current_user
if @user.present? && params[:user].present? && @user.update(permitted_parameters)
if params.dig(:user, :terms_of_service).present?
if InputNormalizer.boolean(params.dig(:user, :terms_of_service))
- 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"