vaibhav-y/statistical

View on GitHub

Showing 5 of 13 total issues

Method quantile has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def quantile(p)
        raise RangeError, "`p` must be in [0, 1], found: #{p}" if p < 0 || p > 1
        return -Float::INFINITY if p == 0
        return  Float::INFINITY if p == 1
        return  @location if p == 0.5
Severity: Major
Found in lib/statistical/distribution/normal.rb - About 2 hrs to fix

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

      def quantile(p)
        raise RangeError, "`p` must be in [0, 1], found: #{p}" if p < 0 || p > 1
        return -Float::INFINITY if p == 0
        return  Float::INFINITY if p == 1
        return  @location if p == 0.5
Severity: Minor
Found in lib/statistical/distribution/normal.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 <=> has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def <=>(other)
      case other
      when Fixnum, Bignum, Float
        return -1 if other <= @start && !include?(other)
        return  1 if other >= @finish && !include?(other)
Severity: Minor
Found in lib/statistical/helpers.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(prob_success = 0.5, state_failure = 0, state_success = 1)
        if state_failure == state_success
          raise ArgumentError,
                'Success & failure must be two distinct states'
        end
Severity: Minor
Found in lib/statistical/distribution/two_point.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 cdf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def cdf(k)
        return 0.0 if k < @lower
        return 1.0 if k >= @upper

        # Ruby has a Array#bsearch_index already but it supports find-min mode
Severity: Minor
Found in lib/statistical/distribution/uniform_discrete.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