Function do_profile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def do_profile(follow=(), follow_all_methods=False):
"""
Decorator to profile a function or class method
It uses line_profiler to give detailed reports on time spent on each
- 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
This 'tryexcept' is too complex. The McCabe rating is 16 Open
try:
- Read upRead up
- Exclude checks
Used when a method or function is too complex based on McCabe Complexity Cyclomatic
Unused argument 'follow' Open
def do_profile(follow=(), follow_all_methods=False):
- Read upRead up
- Exclude checks
Used when a function or method argument is not used.
Unused argument 'follow_all_methods' Open
def do_profile(follow=(), follow_all_methods=False):
- Read upRead up
- Exclude checks
Used when a function or method argument is not used.
Redefining built-in 'type' Open
def __exit__(self, type, value, traceback):
- Read upRead up
- Exclude checks
Used when a variable or function override a built-in.
Missing function or method docstring Open
def checkpoint(self, name=''):
- Read upRead up
- Exclude checks
Used when a function or method has no docstring. Some special methods like init do not require a docstring.
Formatting a regular string which could be a f-string Open
print('{timer} {checkpoint} took {elapsed} seconds'.format(timer=self.name,
- Read upRead up
- Exclude checks
Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6
.
Variable name t2
doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern) Open
t2 = timer()
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Variable name t1
doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern) Open
t1 = timer()
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Missing function or method docstring Open
def elapsed(self):
- Read upRead up
- Exclude checks
Used when a function or method has no docstring. Some special methods like init do not require a docstring.