meysam81/timeframe

View on GitHub

Showing 14 of 14 total issues

File timeframe.py has 282 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import abc
import warnings
from datetime import datetime, timedelta
from functools import reduce
from typing import Iterable, Union
Severity: Minor
Found in timeframe/timeframe.py - About 2 hrs to fix

    Function includes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def includes(self, tf: BaseTimeFrame) -> bool:
            warnings.warn(
                INCLUDES_DEPRECATION_WARNING,
                DeprecationWarning,
            )
    Severity: Minor
    Found in timeframe/timeframe.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 __contains__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def __contains__(self, dt: Union[datetime, "BaseTimeFrame"]) -> bool:
            if not isinstance(dt, (datetime, BaseTimeFrame)):
                raise TypeError(f"{dt} should be either a datetime or a BaseTimeFrame")
    
            if isinstance(dt, datetime):
    Severity: Minor
    Found in timeframe/timeframe.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 __sub__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def __sub__(self, tf: BaseTimeFrame) -> BaseTimeFrame:
            """Remove the portion of the time specified in tf"""
            if not isinstance(tf, BaseTimeFrame):
                raise TypeError(f"{tf} should be either a BaseTimeFrame")
    
    
    Severity: Minor
    Found in timeframe/timeframe.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 __mul__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def __mul__(self, tf: BaseTimeFrame) -> "BatchTimeFrame":
            if not isinstance(tf, BaseTimeFrame):
                raise TypeError(f"{tf} should be a BaseTimeFrame")
    
            if not isinstance(tf, BatchTimeFrame):
    Severity: Minor
    Found in timeframe/timeframe.py - 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

    Function __sub__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def __sub__(self, tf: BaseTimeFrame) -> "BatchTimeFrame":
            if not isinstance(tf, BaseTimeFrame):
                raise TypeError(f"{tf} should be a BaseTimeFrame")
    
            if not isinstance(tf, BatchTimeFrame):
    Severity: Minor
    Found in timeframe/timeframe.py - 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

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

        def includes(self, dt: Union[datetime, BaseTimeFrame]) -> bool:
            warnings.warn(
                INCLUDES_DEPRECATION_WARNING,
                DeprecationWarning,
            )
    Severity: Minor
    Found in timeframe/timeframe.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 __add__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def __add__(self, tf: BaseTimeFrame) -> BaseTimeFrame:
            """Return the summation of two timeframes"""
    
            if not isinstance(tf, BaseTimeFrame):
                raise TypeError(f"{tf} should be a BaseTimeFrame")
    Severity: Minor
    Found in timeframe/timeframe.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

    Avoid too many return statements within this function.
    Open

                return TimeFrame(tf.start, self.end)
    Severity: Major
    Found in timeframe/timeframe.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return False
      Severity: Major
      Found in timeframe/timeframe.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return self
        Severity: Major
        Found in timeframe/timeframe.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return True
          Severity: Major
          Found in timeframe/timeframe.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return BatchTimeFrame([self, tf])
            Severity: Major
            Found in timeframe/timeframe.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return TimeFrame(lower, upper)
              Severity: Major
              Found in timeframe/timeframe.py - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language