lib/modules/trade/grouping/trade_plus_static.rb
Class TradePlusStatic
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Trade::Grouping::TradePlusStatic < Trade::Grouping::Base
attr_reader :country_ids, :locale
def initialize(attributes, opts={})
# exporter or importer
File trade_plus_static.rb
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
class Trade::Grouping::TradePlusStatic < Trade::Grouping::Base
attr_reader :country_ids, :locale
def initialize(attributes, opts={})
# exporter or importer
Method sanitise_column_names
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def sanitise_column_names
return '' if @attributes.blank?
@attributes.map do |attribute|
next if attribute == 'year' || attribute.nil?
name = attribute.include?('id') ? 'id' : attribute.include?('iso') ? 'iso2' : attribute.include?('code') ? 'code' : '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 entity_quantity
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def entity_quantity
reported_by_party = sanitise_boolean(@reported_by_party)
if (reported_by_party && (@reported_by == 'importer')) || (!reported_by_party && (@reported_by == 'exporter'))
'importer'
elsif (reported_by_party && (@reported_by == 'exporter')) || (!reported_by_party && (@reported_by == 'importer'))
- 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"