unepwcmc/SAPI

View on GitHub
lib/modules/trade/formatted_codes/base.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method generate_mapping_table_rows has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def generate_mapping_table_rows(rule)
    formatted_input = input_flattening(rule)
    formatted_input.delete_if { |_, v| v.empty? }
    output = rule['output']
    modifier = output['quantity_modifier'] ? "'#{output['quantity_modifier']}'" : 'NULL'
Severity: Minor
Found in lib/modules/trade/formatted_codes/base.rb - About 1 hr to fix

    Method generate_mapping_table_rows has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def generate_mapping_table_rows(rule)
        formatted_input = input_flattening(rule)
        formatted_input.delete_if { |_, v| v.empty? }
        output = rule['output']
        modifier = output['quantity_modifier'] ? "'#{output['quantity_modifier']}'" : 'NULL'
    Severity: Minor
    Found in lib/modules/trade/formatted_codes/base.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 slice_values has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def slice_values(trade_code, code_type)
        return ("NULL," * 3).chop unless trade_code
        # When code value is 'NULL' it means that this is
        # an actual condition to be met for the mapping.
        # This is why the id is -1 instead of NULL.
    Severity: Minor
    Found in lib/modules/trade/formatted_codes/base.rb - About 25 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

    Method format_taxa_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def format_taxa_fields(taxa_fields)
        return 'NULL' unless taxa_fields.present?
    
        taxa_fields.keys.map do |key|
          next unless taxa_fields[key].is_a?(Array)
    Severity: Minor
    Found in lib/modules/trade/formatted_codes/base.rb - About 25 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