bencao/acts_as_brand_new_copy

View on GitHub
lib/acts_as_brand_new_copy/builder.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method calculate_save_order has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def calculate_save_order
      constraints, klasses = Set.new, Set.new
      traverse do |current_hash|
        klasses.add(current_hash['klass']) unless klasses.include?(current_hash['klass'])

Severity: Minor
Found in lib/acts_as_brand_new_copy/builder.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

Class Builder has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Builder
    def initialize(serialized_hash)
      @hash_origin  = serialized_hash
      @hash_copy    = JSON.parse(serialized_hash.to_json) # a way to do deep clone
      @save_order   = calculate_save_order
Severity: Minor
Found in lib/acts_as_brand_new_copy/builder.rb - About 2 hrs to fix

    Method calculate_save_order has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def calculate_save_order
          constraints, klasses = Set.new, Set.new
          traverse do |current_hash|
            klasses.add(current_hash['klass']) unless klasses.include?(current_hash['klass'])
    
    
    Severity: Minor
    Found in lib/acts_as_brand_new_copy/builder.rb - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status