louismullie/treat

View on GitHub
lib/treat/entities/entity/iterable.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method num_children_with_feature has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def num_children_with_feature(feature, value = nil, recursive = true)
    i = 0
    m = method(recursive ? :each_entity : :each)
    m.call do |c|
      next unless c.has?(feature)
Severity: Minor
Found in lib/treat/entities/entity/iterable.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 each_entity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def each_entity(*types)
    types = [:entity] if types.size == 0
    f = false
    types.each do |t2|
      if is_a?(Treat::Entities.const_get(t2.cc))
Severity: Minor
Found in lib/treat/entities/entity/iterable.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 ancestor_with_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def ancestor_with_type(type)
    return unless has_parent?
    ancestor = @parent
    type_klass = Treat::Entities.const_get(type.cc)
    while not ancestor.is_a?(type_klass)
Severity: Minor
Found in lib/treat/entities/entity/iterable.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