tubedude/xirr

View on GitHub

Showing 4 of 4 total issues

Class Cashflow has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Cashflow < Array
    attr_reader :raise_exception, :fallback, :iteration_limit, :options

    # @param args [Transaction]
    # @example Creating a Cashflow
Severity: Minor
Found in lib/xirr/cashflow.rb - About 2 hrs to fix

    Method xirr has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def xirr(guess: nil, method: nil, ** options)
          method, options = process_options(method, options)
          if invalid?
            raise ArgumentError, invalid_message if options[:raise_exception]
            BigDecimal(0, Xirr.config.precision)
    Severity: Minor
    Found in lib/xirr/cashflow.rb - About 55 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 loop_rates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def loop_rates(left, midpoint, right, iteration_limit)
          runs = 0
          while (right - left).abs > Xirr.config.eps && runs < iteration_limit do
            runs += 1
            left, midpoint, right, should_stop = bisection(left, midpoint, right)
    Severity: Minor
    Found in lib/xirr/bisection.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

    Method bisection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def bisection(left, midpoint, right)
          _left = xnpv(left).positive?
          _mid = xnpv(midpoint).positive?
          if _left && _mid
            return left, left, left, true if xnpv(right).positive? # Not Enough Precision in the left to find the IRR
    Severity: Minor
    Found in lib/xirr/bisection.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