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
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,
)
- Read upRead up
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):
- Read upRead up
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")
- Read upRead up
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):
- Read upRead up
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):
- Read upRead up
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,
)
- Read upRead up
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")
- Read upRead up
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)
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return self
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return BatchTimeFrame([self, tf])
Avoid too many return
statements within this function. Open
return TimeFrame(lower, upper)