Function draw
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def draw(self, page, x, y):
final_x, final_y = x, y - self.box.height
style = self.box.style
width = self.box.width - self.frame_width
txt = page.begin_text(x, y)
- 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
File box.py
has 356 lines of code (exceeds 250 allowed). Consider refactoring. Open
from copy import copy
from string import whitespace
from reportlab.pdfbase.pdfmetrics import stringWidth, getFont, getAscentDescent
from .style import TextAlign, default as default_style, VerticalAlign
Function boxes
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def boxes(self):
words = []
word_open = False
for box, parent in self.traverse():
if isinstance(box, str):
- 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 split
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def split(self, top_parent, bottom_parent, available_height, css):
if not self.box.lines:
return (
self.clone(top_parent, [], css),
- 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 wrap
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def wrap(self, page, available_width):
self.box.width = available_width
available_width -= self.frame_width
self.box.height = 0
- 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 deeply nested control flow statements. Open
for part in word.parts:
if style != part.style:
if fragments:
txt.draw(''.join(fragments))
fragments = []
Avoid too many return
statements within this function. Open
return (
Function clone
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def clone(self, parent, lines, css):
box = Box(parent or self.box.parent, self.box.tag, self.box.attrs)
box.behavior = copy(self)
box.behavior.box = box
box.position = self.box.position
- 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"