Function word_wrap
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def word_wrap(image, draw, text, roi_width, roi_height):
"""Break long text to multiple lines, and reduce point size
until all text fits within a bounding box."""
mutable_message = text
iteration_attempts = 100
- 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 word_wrap
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def word_wrap(image, draw, text, roi_width, roi_height):
Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed. Open
def word_wrap(image, draw, text, roi_width, roi_height):
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Unnecessary else
after return
Open
if width > height:
- Read upRead up
- Exclude checks
Used in order to highlight an unnecessary block of code following an if containing a return statement. As such, it will warn when it encounters an else following a chain of ifs, all of them containing a return statement.
Unable to import 'requests' Open
import requests
- Read upRead up
- Exclude checks
Used when pylint has been unable to import a module.
Unable to import 'wand.color' Open
from wand.color import Color
- Read upRead up
- Exclude checks
Used when pylint has been unable to import a module.
Unable to import 'wand.image' Open
from wand.image import Image
- Read upRead up
- Exclude checks
Used when pylint has been unable to import a module.
Unable to import 'wand.drawing' Open
from wand.drawing import Drawing
- Read upRead up
- Exclude checks
Used when pylint has been unable to import a module.
Line too long (103/100) Open
kingdom = word_wrap(self.img, draw, self.data['alternate_kingdom'], kingdom_width + 10,
- Read upRead up
- Exclude checks
Used when a line is longer than a given number of characters.
Variable name x
doesn't conform to snake_case naming style Open
x = int(self.img.width - 2 * (kingdom_width + 15) - 15 + 0.5 * kingdom_width)
- 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 scale_down(width, height, max_size):
- Read upRead up
- Exclude checks
Used when a function or method has no docstring.Some special methods like init do not require a docstring.
Missing class docstring Open
class BasePreview:
- Read upRead up
- Exclude checks
Used when a class has no docstring.Even an empty class must have a docstring.
Line too long (116/100) Open
kingdom = word_wrap(self.img, draw, self.data['kingdom'], kingdom_width + 10, int(1.5 * draw.font_size))
- Read upRead up
- Exclude checks
Used when a line is longer than a given number of characters.
Line too long (108/100) Open
left=(300 - switch_logo.height) // 2 - 15, top=300 - switch_logo.height - 15,
- Read upRead up
- Exclude checks
Used when a line is longer than a given number of characters.
Variable name y
doesn't conform to snake_case naming style Open
y = kingdom_logo.height + int(1.5 * base_font_size)
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Variable name r
doesn't conform to snake_case naming style Open
r = requests.get(url)
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Variable name f
doesn't conform to snake_case naming style Open
f = open(cache_filename, 'rb')
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Variable name f
doesn't conform to snake_case naming style Open
f = io.BytesIO(r.content)
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Line too long (104/100) Open
kingdom_width, kingdom_height = scale_down(kingdom_logo.width, kingdom_logo.height, 220)
- Read upRead up
- Exclude checks
Used when a line is longer than a given number of characters.
Variable name y
doesn't conform to snake_case naming style Open
y = kingdom_logo.height + int(1.5 * base_font_size)
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Missing module docstring Open
import io
- Read upRead up
- Exclude checks
Used when a module has no docstring.Empty modules do not require a docstring.
Variable name x
doesn't conform to snake_case naming style Open
x = self.img.width - kingdom_width // 2 - 15
- 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 download_image(path):
- Read upRead up
- Exclude checks
Used when a function or method has no docstring.Some special methods like init do not require a docstring.
Missing function or method docstring Open
def render_background(self, title):
- Read upRead up
- Exclude checks
Used when a function or method has no docstring.Some special methods like init do not require a docstring.
Missing function or method docstring Open
def draw_watermark(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.