enkessler/cql

View on GitHub
lib/cql/map_reduce.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method gather_objects has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def self.gather_objects(current_object, target_classes, filters)
      gathered_objects = [].tap { |objects| collect_all_in(target_classes, current_object, objects) }

      if filters
        filters.each do |filter|
Severity: Minor
Found in lib/cql/map_reduce.rb - About 3 hrs 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 gather_objects has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.gather_objects(current_object, target_classes, filters)
      gathered_objects = [].tap { |objects| collect_all_in(target_classes, current_object, objects) }

      if filters
        filters.each do |filter|
Severity: Minor
Found in lib/cql/map_reduce.rb - About 1 hr to fix

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

          def collect_all_in(targeted_classes, current_object, accumulated_objects)
            accumulated_objects << current_object if targeted_classes.any? { |targeted_class| (targeted_class == :all) || current_object.is_a?(targeted_class) }
    
            method_for_children = Gem.loaded_specs['cuke_modeler'].version.version[/^0/] ? :contains : :children
    
    
    Severity: Minor
    Found in lib/cql/map_reduce.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