mikezaby/my_data

View on GitHub

Showing 4 of 6 total issues

Method flatten has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def flatten(hash, resource)
    return {} unless hash

    hash.each_with_object({}) do |(k, v), h|
      next if resource.attributes.none?(k) || !v
Severity: Minor
Found in lib/my_data/xml_parser.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 inspect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def inspect
        format_attrs = attributes.map do |name|
          mapping = mappings[name]
          type = mapping[:type] == :resource ? mapping[:resource].name : mapping[:type]
          type = "[#{type}]" if mapping[:collection]
Severity: Minor
Found in lib/my_data/resource.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

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

  def value_mapping(value, mappings)
    return value if mappings[:resource].nil?

    if mappings[:collection]
      value = [value] unless value.is_a?(Array)
Severity: Minor
Found in lib/my_data/xml_parser.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 type_mapping has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def type_mapping(type)
    if ["xs:byte", "xs:long", "xs:int"].include?(type)
      :integer
    elsif type == "xs:decimal"
      :float
Severity: Minor
Found in lib/my_data/xsd/structure.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

Severity
Category
Status
Source
Language