princelab/mspire

View on GitHub
lib/mspire/bin.rb

Summary

Maintainability
C
1 day
Test Coverage

Method bin has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def self.bin(bins, objects, *data_capture_obj, &block)
      data_capture = data_capture_obj.first || bins

      if objects.size > 0
        obj_e = objects.each ; obj = obj_e.next  
Severity: Minor
Found in lib/mspire/bin.rb - About 6 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

Avoid deeply nested control flow statements.
Open

              obj=obj_e.next rescue done=true && break
Severity: Major
Found in lib/mspire/bin.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                  value = (block.nil? ? obj : block.call(obj))
    Severity: Major
    Found in lib/mspire/bin.rb - About 45 mins to fix

      Consider simplifying this complex logical expression.
      Open

                if cbin.begin <= value
                  until cbin === value && data_capture[bin_i] << obj
                    bin_i += 1
                    cbin=bins[bin_i] || (done=true && break)
                  end
      Severity: Major
      Found in lib/mspire/bin.rb - About 40 mins to fix

        There are no issues that match your filters.

        Category
        Status