Noosfero/noosfero

View on GitHub
plugins/suppliers/lib/suppliers_plugin/import.rb

Summary

Maintainability
D
2 days
Test Coverage

Method products has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
Open

  def self.products(consumer, csv)
    default_product_category = consumer.environment.product_categories.find_by slug: "software-livre"

    detection = CharlockHolmes::EncodingDetector.detect csv
    csv = CharlockHolmes::Converter.convert csv, detection[:encoding], "UTF-8"
Severity: Minor
Found in plugins/suppliers/lib/suppliers_plugin/import.rb - About 1 day to fix

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 products has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.products(consumer, csv)
    default_product_category = consumer.environment.product_categories.find_by slug: "software-livre"

    detection = CharlockHolmes::EncodingDetector.detect csv
    csv = CharlockHolmes::Converter.convert csv, detection[:encoding], "UTF-8"
Severity: Major
Found in plugins/suppliers/lib/suppliers_plugin/import.rb - About 3 hrs to fix

    Method product_columns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.product_columns(header)
        keys = I18n.t "suppliers_plugin.lib.import.keys"
        columns = []
        header.each do |name|
          c = nil; keys.each do |key, regex|
    Severity: Minor
    Found in plugins/suppliers/lib/suppliers_plugin/import.rb - About 45 mins to fix

    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

    There are no issues that match your filters.

    Category
    Status