unepwcmc/SAPI

View on GitHub
lib/modules/trade/grouping/trade_plus_static.rb

Summary

Maintainability
C
1 day
Test Coverage

Class TradePlusStatic has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class Trade::Grouping::TradePlusStatic < Trade::Grouping::Base
  attr_reader :country_ids, :locale

  def initialize(attributes, opts={})
    # exporter or importer
Severity: Minor
Found in lib/modules/trade/grouping/trade_plus_static.rb - About 4 hrs to fix

    File trade_plus_static.rb has 309 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Trade::Grouping::TradePlusStatic < Trade::Grouping::Base
      attr_reader :country_ids, :locale
    
      def initialize(attributes, opts={})
        # exporter or importer
    Severity: Minor
    Found in lib/modules/trade/grouping/trade_plus_static.rb - About 3 hrs to fix

      Method sanitise_column_names has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      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'
      Severity: Minor
      Found in lib/modules/trade/grouping/trade_plus_static.rb - About 1 hr 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 entity_quantity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      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'))
      Severity: Minor
      Found in lib/modules/trade/grouping/trade_plus_static.rb - About 35 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