sonntagsgesicht/dcf

View on GitHub
dcf/cashflows/payoffs.py

Summary

Maintainability
C
1 day
Test Coverage

File payoffs.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

# dcf
# ---
# A Python library for generating discounted cashflows.
Severity: Minor
Found in dcf/cashflows/payoffs.py - About 3 hrs to fix

    Function details has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def details(self, forward_curve=None):
            yf = self.day_count(self.start, self.end)
    
            details = {
                'cashflow': 0.0,
    Severity: Minor
    Found in dcf/cashflows/payoffs.py - 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

    Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, start, end, amount=DEFAULT_AMOUNT,
    Severity: Major
    Found in dcf/cashflows/payoffs.py - About 1 hr to fix

      Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, start, end, amount=DEFAULT_AMOUNT,
      Severity: Minor
      Found in dcf/cashflows/payoffs.py - About 45 mins to fix

        Function details has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def details(self, model=None):
                details = {
                    'cashflow': 0.0
                }
                cf = 0.0
        Severity: Minor
        Found in dcf/cashflows/payoffs.py - 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

        Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, expiry,
        Severity: Minor
        Found in dcf/cashflows/payoffs.py - About 35 mins to fix

          Function details has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def details(self, model=None):
                  # works even if the model is the forward_curve
                  forward_curve = getattr(model, 'forward_curve', model)
                  details = super().details(forward_curve)
                  floorlet = caplet = 0.0
          Severity: Minor
          Found in dcf/cashflows/payoffs.py - 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

          Function details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def details(self, model=None):
                  details = {
                      'cashflow': 0.0,
                      'put/call': 'put' if self.is_put else 'call',
                      'long/short': 'long' if self.amount > 0 else 'short',
          Severity: Minor
          Found in dcf/cashflows/payoffs.py - 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

          There are no issues that match your filters.

          Category
          Status