danielpclark/PolyBelongsTo

View on GitHub

Showing 4 of 6 total issues

Method pbt_dup_build has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def self.pbt_dup_build(item_to_build_on, item_to_duplicate)
        singleton_record = yield if block_given?
        if PolyBelongsTo::Pbt::IsReflected[item_to_build_on, item_to_duplicate]
          PolyBelongsTo::Pbt::AsCollectionProxy[item_to_build_on, item_to_duplicate].
            build PolyBelongsTo::Pbt::AttrSanitizer[item_to_duplicate] if
Severity: Minor
Found in lib/poly_belongs_to/dup.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 pbt_deep_dup_build has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def self.pbt_deep_dup_build(item_to_build_on, item_to_duplicate)
        singleton_record = (block_given? ? yield : PolyBelongsTo::SingletonSet.new)
        pbt_dup_build(item_to_build_on, item_to_duplicate) {singleton_record}
        PolyBelongsTo::Pbt::Reflects[item_to_duplicate].each do |ref|
          child = item_to_duplicate.send(ref)
Severity: Minor
Found in lib/poly_belongs_to/dup.rb - About 45 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(obj = nil, child = nil)
      @obj = obj
      @child = child
      if obj.nil? || child.nil?
        @instance = nil
Severity: Minor
Found in lib/poly_belongs_to/faked_collection.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 pbt_orphans has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def self.pbt_orphans
        return nil unless pbts.present?
        poly? ? _pbt_polymorphic_orphans : _pbt_nonpolymorphic_orphans
      end
Severity: Minor
Found in lib/poly_belongs_to/core.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

Severity
Category
Status
Source
Language