Showing 45 of 45 total issues
File pprint3x.py
has 534 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Author: Fred L. Drake, Jr.
# fdrake@acm.org
#
# This is a simple little module I wrote to make life easier. I didn't
# see anything quite like it in the library, though I may have overlooked
Function _safe_repr
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
def _safe_repr(self, object, context, maxlevels, level):
# Return triple (repr_string, isreadable, isrecursive).
typ = type(object)
if typ in _builtin_scalars:
return repr(object), True, False
- 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 _pprint_str
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def _pprint_str(self, object, stream, indent, allowance, context, level):
write = stream.write
if not len(object):
write(repr(object))
return
- 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
PrettyPrinter
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class PrettyPrinter:
def __init__(self, indent=1, width=80, depth=None, stream=None, *, compact=False, sort_dicts=True, underscore_numbers=False):
"""Handle pretty printing operations onto a stream using a set of
configured parameters.
Function _format_items
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def _format_items(self, items, stream, indent, allowance, context, level):
write = stream.write
indent += self._indent_per_level
if self._indent_per_level > 1:
write((self._indent_per_level - 1) * " ")
- 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 pprint
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def pprint(object, stream=None, indent=1, width=80, depth=None, *, compact=False, sort_dicts=True, underscore_numbers=False):
Function _wrap_bytes_repr
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _wrap_bytes_repr(object, width, allowance):
current = b""
last = len(object) // 4 * 4
for i in range(0, len(object), 4):
part = object[i : i + 4]
- 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 pformat
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def pformat(object, indent=1, width=80, depth=None, *, compact=False, sort_dicts=True, underscore_numbers=False):
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, indent=1, width=80, depth=None, stream=None, *, compact=False, sort_dicts=True, underscore_numbers=False):
Function _format_namespace_items
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _format_namespace_items(self, items, stream, indent, allowance, context, level):
write = stream.write
delimnl = ",\n" + " " * indent
last_index = len(items) - 1
for i, (key, ent) in enumerate(items):
- 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 _pprint_list
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _pprint_list(self, object, stream, indent, allowance, context, level):
Avoid deeply nested control flow statements. Open
if current:
chunks.append(repr(current))
current = part
Function _pprint_bytes
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _pprint_bytes(self, object, stream, indent, allowance, context, level):
Function _pprint_tuple
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _pprint_tuple(self, object, stream, indent, allowance, context, level):
Function _pprint_default_dict
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _pprint_default_dict(self, object, stream, indent, allowance, context, level):
Function _pprint_set
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _pprint_set(self, object, stream, indent, allowance, context, level):
Function _pprint_counter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _pprint_counter(self, object, stream, indent, allowance, context, level):
Function _pprint_chain_map
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _pprint_chain_map(self, object, stream, indent, allowance, context, level):
Function _pprint_dataclass
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _pprint_dataclass(self, object, stream, indent, allowance, context, level):
Function _format_dict_items
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _format_dict_items(self, items, stream, indent, allowance, context, level):