dontfidget/chartnado

View on GitHub
lib/chartnado/series/wrap.rb

Summary

Maintainability
C
1 day
Test Coverage

Method times has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def times(factor, precision: 2)
        factor = wrap(factor)

        return factor.times(self, precision: precision) if factor.dimensions > dimensions
        return with_precision(precision, factor.to_f * to_f) unless dimensions > 1
Severity: Minor
Found in lib/chartnado/series/wrap.rb - About 2 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 over has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def over(bottom, multiplier: 1.0, precision: 2)
        bottom = wrap(bottom)
        return times(1.0 * multiplier / bottom, precision: precision) if bottom.dimensions == 1

        if dimensions > bottom.dimensions
Severity: Minor
Found in lib/chartnado/series/wrap.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 over has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def over(bottom, multiplier: 1.0, precision: 2)
        bottom = wrap(bottom)
        return times(1.0 * multiplier / bottom, precision: precision) if bottom.dimensions == 1

        if dimensions > bottom.dimensions
Severity: Minor
Found in lib/chartnado/series/wrap.rb - About 1 hr to fix

    Method dimensions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def dimensions
            return 1 unless respond_to?(:length)
            if hash?
              if keys.first && keys.first.is_a?(Array) || hash_of_named_series?
                3
    Severity: Minor
    Found in lib/chartnado/series/wrap.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 add has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def add(*series, scalar_sum: 0.0)
            (series, scalars) = [__getobj__, *series].partition { |s| s.respond_to?(:map) }
            scalar_sum += scalars.reduce(:+) || 0.0
            return wrap(scalar_sum) unless series.present?
    
    
    Severity: Minor
    Found in lib/chartnado/series/wrap.rb - About 1 hr to fix

      Method times has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def times(factor, precision: 2)
              factor = wrap(factor)
      
              return factor.times(self, precision: precision) if factor.dimensions > dimensions
              return with_precision(precision, factor.to_f * to_f) unless dimensions > 1
      Severity: Minor
      Found in lib/chartnado/series/wrap.rb - About 1 hr to fix

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

              def add(*series, scalar_sum: 0.0)
                (series, scalars) = [__getobj__, *series].partition { |s| s.respond_to?(:map) }
                scalar_sum += scalars.reduce(:+) || 0.0
                return wrap(scalar_sum) unless series.present?
        
        
        Severity: Minor
        Found in lib/chartnado/series/wrap.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