maduck/GoWDiscordTeamBot

View on GitHub
graphic_base_preview.py

Summary

Maintainability
A
2 hrs
Test Coverage

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
Severity: Minor
Found in graphic_base_preview.py - About 2 hrs to fix

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):
Severity: Minor
Found in graphic_base_preview.py - About 35 mins to fix

    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):
    Severity: Critical
    Found in graphic_base_preview.py by sonar-python

    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:
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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
    Severity: Critical
    Found in graphic_base_preview.py by pylint

    Used when pylint has been unable to import a module.

    Unable to import 'wand.color'
    Open

    from wand.color import Color
    Severity: Critical
    Found in graphic_base_preview.py by pylint

    Used when pylint has been unable to import a module.

    Unable to import 'wand.image'
    Open

    from wand.image import Image
    Severity: Critical
    Found in graphic_base_preview.py by pylint

    Used when pylint has been unable to import a module.

    Unable to import 'wand.drawing'
    Open

    from wand.drawing import Drawing
    Severity: Critical
    Found in graphic_base_preview.py by pylint

    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,
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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)
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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):
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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:
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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))
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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,
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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)
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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)
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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')
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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)
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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)
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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)
    Severity: Info
    Found in graphic_base_preview.py by pylint

    Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

    Missing module docstring
    Open

    import io
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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):
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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):
    Severity: Info
    Found in graphic_base_preview.py by pylint

    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):
    Severity: Info
    Found in graphic_base_preview.py by pylint

    Used when a function or method has no docstring.Some special methods like init do not require a docstring.

    There are no issues that match your filters.

    Category
    Status