Showing 66 of 66 total issues
Assignment Branch Condition size for associate_product_with_taxon is too high. [55.69/15] Open
def associate_product_with_taxon(product, taxon_hierarchy, putInTop)
return if product.nil? || taxon_hierarchy.nil?
taxon_hierarchy.split(/\s*\|\s*/).each do |hierarchy|
hierarchy = hierarchy.split(/\s*>\s*/)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for call is too high. [41.3/15] Open
def call(args = { product: nil, product_information: nil })
self.logger = SolidusImportProducts::Logger.instance
self.product_information = args[:product_information]
self.product = args[:product]
return if product_information.nil?
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for call is too high. [41.3/15] Open
def call(args = { product: nil, product_information: nil })
self.logger = SolidusImportProducts::Logger.instance
self.product_information = args[:product_information]
self.product = args[:product]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for extract_product_information is too high. [40.42/15] Open
def extract_product_information
col.each do |key, value|
row[value].try :strip!
if parser.variant_option_field?(key)
product_information[:variant_options][key] = row[value]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method associate_product_with_taxon
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def associate_product_with_taxon(product, taxon_hierarchy, putInTop)
return if product.nil? || taxon_hierarchy.nil?
taxon_hierarchy.split(/\s*\|\s*/).each do |hierarchy|
hierarchy = hierarchy.split(/\s*>\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
Assignment Branch Condition size for call is too high. [34.26/15] Open
def call
extract_product_information
product_information_default_values
logger.log(product_information.to_s, :debug)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Block has too many lines. [67/25] Open
included do
### IMAGE HELPERS ###
# find_and_attach_image_to
# This method attaches images to products. The images may come
# from a local source (i.e. on disk), or they may be online (HTTP/HTTPS).
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Assignment Branch Condition size for stock_items is too high. [32.62/15] Open
def stock_items
source_location = Spree::StockLocation.find_by(default: true)
unless source_location
logger.log('Seems that there are no SourceLocation set right?, so stock will not set.', :warn) if product_information[:attributes][:stock] || product_information[:attributes][:backorderable]
return
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for call is too high. [31.8/15] Open
def call(args = { product: nil, product_information: nil })
self.logger = SolidusImportProducts::Logger.instance
self.product_information = args[:product_information]
self.product = args[:product]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for load_or_initialize_variant is too high. [30.13/15] Open
def load_or_initialize_variant
self.variant = Spree::Variant.find_by(sku: product_information[:attributes][:sku])
if variant
if variant.product != product
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for product_information_default_values is too high. [24.66/15] Open
def product_information_default_values
product_information[:attributes][:available_on] = Time.zone.today - 1.day if product_information[:attributes][:available_on].nil?
if product_information[:attributes][:shipping_category_id].nil?
sc = Spree::ShippingCategory.first
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for extract_column_mappings is too high. [24.6/15] Open
def extract_column_mappings
rows[0].each_with_index do |heading, index|
break if heading.blank?
field_name = heading.downcase.gsub(/\A\s*/, '').chomp.gsub(/\s/, '_')
if field_name.include?('[opt]')
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Cyclomatic complexity for associate_product_with_taxon is too high. [12/6] Open
def associate_product_with_taxon(product, taxon_hierarchy, putInTop)
return if product.nil? || taxon_hierarchy.nil?
taxon_hierarchy.split(/\s*\|\s*/).each do |hierarchy|
hierarchy = hierarchy.split(/\s*>\s*/)
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Perceived complexity for associate_product_with_taxon is too high. [12/7] Open
def associate_product_with_taxon(product, taxon_hierarchy, putInTop)
return if product.nil? || taxon_hierarchy.nil?
taxon_hierarchy.split(/\s*\|\s*/).each do |hierarchy|
hierarchy = hierarchy.split(/\s*>\s*/)
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Assignment Branch Condition size for activate is too high. [18.11/15] Open
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), '../app/**/*_decorator*.rb')) do |c|
Rails.env.production? ? require(c) : load(c)
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [32/30] Open
def associate_product_with_taxon(product, taxon_hierarchy, putInTop)
return if product.nil? || taxon_hierarchy.nil?
taxon_hierarchy.split(/\s*\|\s*/).each do |hierarchy|
hierarchy = hierarchy.split(/\s*>\s*/)
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for call is too high. [17.49/15] Open
def call
skus_of_products_before_import = Spree::Product.all.map(&:sku)
parser = product_imports.parse
col = parser.column_mappings
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Cyclomatic complexity for stock_items is too high. [7/6] Open
def stock_items
source_location = Spree::StockLocation.find_by(default: true)
unless source_location
logger.log('Seems that there are no SourceLocation set right?, so stock will not set.', :warn) if product_information[:attributes][:stock] || product_information[:attributes][:backorderable]
return
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method associate_product_with_taxon
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def associate_product_with_taxon(product, taxon_hierarchy, putInTop)
return if product.nil? || taxon_hierarchy.nil?
taxon_hierarchy.split(/\s*\|\s*/).each do |hierarchy|
hierarchy = hierarchy.split(/\s*>\s*/)
Method call
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def call(args = { product: nil, product_information: nil })
self.logger = SolidusImportProducts::Logger.instance
self.product_information = args[:product_information]
self.product = args[:product]
- 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"