thumbor/thumbor

View on GitHub
thumbor/transformer.py

Summary

Maintainability
C
1 day
Test Coverage

File transformer.py has 358 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/python
# -*- coding: utf-8 -*-

# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki
Severity: Minor
Found in thumbor/transformer.py - About 4 hrs to fix

    Function _calculate_target_dimensions has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def _calculate_target_dimensions(self):
            source_width, source_height = self.engine.size
            source_width = float(source_width)
            source_height = float(source_height)
    
    
    Severity: Minor
    Found in thumbor/transformer.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 adjust_focal_points has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def adjust_focal_points(self):
            source_width, source_height = self.engine.size
    
            self.focal_points = None
    
    
    Severity: Minor
    Found in thumbor/transformer.py - About 1 hr 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 fit_in_resize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def fit_in_resize(self):
            source_width, source_height = self.engine.size
    
            # invert width and height if image orientation is not the
            # same as request orientation and need adaptive
    Severity: Minor
    Found in thumbor/transformer.py - About 1 hr 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 img_operation_worker has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def img_operation_worker(self):
            if (
                self.context.request.engine.extension == ".gif"
                and "cover()" in self.context.request.filters
            ):
    Severity: Minor
    Found in thumbor/transformer.py - About 1 hr 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 debug has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def debug(self):
            if not self.context.request.focal_points:
                return
    
            for point in self.context.request.focal_points:
    Severity: Minor
    Found in thumbor/transformer.py - About 25 mins 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

    There are no issues that match your filters.

    Category
    Status