dougyouch/schema

View on GitHub
lib/schema/array_headers.rb

Summary

Maintainability
A
3 hrs
Test Coverage
A
100%

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

      def get_field_names(mapped_headers, header_prefix = nil, mapped = true)
        fields = []
        schema.each do |field_name, field_options|
          next if field_options[:alias_of]

Severity: Minor
Found in lib/schema/array_headers.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 map_headers_to_has_many_associations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def map_headers_to_has_many_associations(headers, mapped_headers)
        schema.each do |field_name, field_options|
          next unless field_options[:type] == :has_many

          get_header_prefixes(field_name, field_options).each do |header_prefix|
Severity: Minor
Found in lib/schema/array_headers.rb - About 55 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 map_headers_to_fields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def map_headers_to_fields(headers, mapped_headers, header_prefix)
        schema.each do |field_name, field_options|
          if header_prefix
            unless (indexes = find_indexes_for_field(headers, field_options, header_prefix)).empty?
              mapped_headers[field_options[:alias_of] || field_name] = { indexes: indexes }
Severity: Minor
Found in lib/schema/array_headers.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

Method get_model_field_names has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def get_model_field_names(field_name, field_options, mapped_headers, header_prefix, mapped)
Severity: Minor
Found in lib/schema/array_headers.rb - About 35 mins to fix

    Method map_headers_to_has_one_associations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def map_headers_to_has_one_associations(headers, mapped_headers, header_prefix)
            schema.each do |field_name, field_options|
              next unless field_options[:type] == :has_one
    
              mapped_model = get_mapped_model(field_options, headers, header_prefix)
    Severity: Minor
    Found in lib/schema/array_headers.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