aaronFranssell/cacheable_kdtree

View on GitHub
lib/cacheable_kdtree/latitude_longitude_tree.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

  def closest(lat, long, distance, units = :miles)
    fail 'Input must be numeric.' unless lat.is_a?(Numeric) && long.is_a?(Numeric) && distance.is_a?(Numeric)
    fail 'Units must be either :kilometers or :miles.' unless %i(miles kilometers).include?(units)
    bounding_box = if units == :miles
                     CacheableKdtree::Util.bounding_box_miles(lat, long, distance)
Severity: Minor
Found in lib/cacheable_kdtree/latitude_longitude_tree.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 nearest_nodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def nearest_nodes(bounding_box, node = @root, result = [])
    return result if node.nil?
    result << node if bounding_box.point_in_region?(node.latitude, node.longitude)
    nearest_nodes(bounding_box, node.left, result) if search_child?(node.left, bounding_box)
    nearest_nodes(bounding_box, node.right, result) if search_child?(node.right, bounding_box)
Severity: Minor
Found in lib/cacheable_kdtree/latitude_longitude_tree.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 find_regions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def find_regions(node)
    return unless node
    left_region = find_regions(node.left)
    left_region = CacheableKdtree::LatitudeLongitudeNode.create_or_merge_regions(node, node.left) if node.left
    right_region = find_regions(node.right)
Severity: Minor
Found in lib/cacheable_kdtree/latitude_longitude_tree.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