File malojatime.py
has 392 lines of code (exceeds 250 allowed). Consider refactoring. Open
from datetime import timezone, timedelta, date, time, datetime
from calendar import monthrange
import math
from abc import ABC, abstractmethod
Function time_pad
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def time_pad(f,t,full=False):
if f is None or t is None: return f,t
# week handling
- 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 time_fix
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def time_fix(t):
if t is None or isinstance(t,MTRangeGeneric): return t
if isinstance(t, str):
t = t.lower()
- 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 ranges
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def ranges(since=None,to=None,within=None,timerange=None,step="month",stepn=1,trail=1,max_=None):
Function next
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def next(self,step=1):
if abs(step) == math.inf: return None
if self.precision == 1:
return MTRangeGregorian(self.year + step)
elif self.precision == 2:
- 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 informal_desc
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def informal_desc(self):
# TODO: ignore year when same year etc
now = datetime.now(tz=timezone.utc)
today = date(now.year,now.month,now.day)
if self.precision == 3:
- 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 contextual_desc
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def contextual_desc(self,other):
# TODO: more elegant maybe?
if not isinstance(other, MTRangeGregorian): return self.desc()
relevant = self.desc().split(" ")
- 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 desc
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def desc(self,prefix=False):
if self.since is not None and self.to is not None:
if prefix:
return f"from {self.since.contextual_desc(self.to)} to {self.to.desc()}"
else:
- 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 ""
Function ranges
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ranges(since=None,to=None,within=None,timerange=None,step="month",stepn=1,trail=1,max_=None):
(firstincluded,lastincluded) = time_stamps(since=since,to=to,within=within,range=timerange)
d_start = from_timestamp(firstincluded,step)
- 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"