Showing 38 of 48 total issues
Method write_attribute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def write_attribute(attribute, value) #:nodoc:
attribute = attribute.to_s
attr_regex = taxable_class_info.all_args.map{|a| a.to_s }.join('|')
@taxed_or_untaxed ||= {}
@taxed_attributes ||= {}
- 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 expand_hash_conditions_for_aggregates
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def expand_hash_conditions_for_aggregates(attrs)
new_attrs = {}
attrs.each_pair do |attr, value|
attr = attr_base = attr.to_s
- 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 merge_conditions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def merge_conditions(*conditions)
segments = []
conditions.each do |condition|
unless condition.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 record_at
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def record_at(point_in_time)
valid_from = time_dependent_class_info.get(self, :valid_from)
valid_until = time_dependent_class_info.get(self, :valid_until)
if valid_from > point_in_time
- 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 calculate_total_amount
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def calculate_total_amount
line_items = ledger_item_class_info.get(self, :line_items)
return if self.class.is_payment && line_items.empty?
net_total = tax_total = BigDecimal('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"
Further reading
Method convert_taxable_value
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def convert_taxable_value(attr) #:nodoc:
attr = attr.to_s
attr_without_suffix = attr.sub(/(_taxed)$/, '')
to_status = ($1 == '_taxed') ? :taxed : :untaxed
- 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 convert
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def convert(object, attr_without_suffix, value, from_status, to_status)
Method currency_info
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def currency_info(code, options={})
code = code.to_s.upcase
valid_options = [:symbol, :round, :suffix, :space, :digits]
info = {:code => code, :symbol => code, :round => 0.01, :suffix => nil, :space => nil, :digits => nil}
if ::Invoicing::CurrencyValue::CURRENCIES.has_key? code
- 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 load_all_subclasses_found_in_database
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def load_all_subclasses_found_in_database(table = table_name, type_column = inheritance_column)
quoted_table_name = connection.quote_table_name(table)
quoted_inheritance_column = connection.quote_column_name(type_column)
query = "SELECT DISTINCT #{quoted_inheritance_column} FROM #{quoted_table_name}"
for subclass_name in connection.select_all(query).map{|record| record[type_column]}
- 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 debit?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def debit?(self_id)
sender_is_self = sent_by?(self_id)
recipient_is_self = received_by?(self_id)
raise ArgumentError, "self_id #{self_id.inspect} is neither sender nor recipient" unless sender_is_self || recipient_is_self
raise ArgumentError, "self_id #{self_id.inspect} is both sender and recipient" if sender_is_self && recipient_is_self
- 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 default_line_items_header
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def default_line_items_header(params)
html = "#{indent*1}<tr>\n"
html << "#{indent*2}<th class=\"tax-point\">#{ params[:line_tax_point_label] }</th>\n" if options[:tax_point_column]
html << "#{indent*2}<th class=\"quantity\">#{ params[:line_quantity_label] }</th>\n" if options[:quantity_column]
html << "#{indent*2}<th class=\"description\">#{ params[:line_description_label] }</th>\n" if options[:description_column]
- 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 default_line_items_subtotal
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def default_line_items_subtotal(params)
colspan = 0
colspan += 1 if options[:tax_point_column]
colspan += 1 if options[:quantity_column]
colspan += 1 if options[:description_column]
- 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 acts_as_taxable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def acts_as_taxable(*args)
Invoicing::ClassInfo.acts_as(Invoicing::Taxable, self, args)
attrs = taxable_class_info.new_args.map{|a| a.to_s }
currency_attrs = attrs + attrs.map{|attr| "#{attr}_taxed"}
- 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_from_ids
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_from_ids(ids, options)
expects_array = ids.first.kind_of?(Array)
return ids.first if expects_array && ids.first.empty?
ids = ids.flatten.compact.uniq
- 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 attr_conversion_input
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def attr_conversion_input(object, attr)
value = nil
if callback = all_options[:conversion_input]
value = object.send(callback, attr)
- 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 build_line_item
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build_line_item(invoice_line, line_item)
invoice_line.cbc :ID, id_of(line_item)
invoice_line.cbc :UUID, uuid_of(line_item) if uuid_of(line_item)
quantity_tag = [:Invoice, :SelfBilledInvoice].include?(doc_type) ? :InvoicedQuantity : :CreditedQuantity
invoice_line.cbc quantity_tag, quantity_of(line_item) if quantity_of(line_item)
- 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 default_line_items_total
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def default_line_items_total(params)
colspan = -1
colspan += 1 if options[:tax_point_column]
colspan += 1 if options[:quantity_column]
colspan += 1 if options[:description_column]
- 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 default_line_item
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def default_line_item(params)
html = "#{indent*1}<tr>\n"
html << "#{indent*2}<td class=\"tax-point\">#{ params[:line_tax_point] }</td>\n" if options[:tax_point_column]
html << "#{indent*2}<td class=\"quantity\">#{ params[:line_quantity] }</td>\n" if options[:quantity_column]
html << "#{indent*2}<td class=\"description\">#{ params[:line_description] }</td>\n" if options[:description_column]
- 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"