thumbor/thumbor

View on GitHub

Showing 64 of 69 total issues

File config.py has 849 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: Major
Found in thumbor/config.py - About 2 days to fix

    File __init__.py has 834 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: Major
    Found in thumbor/handlers/__init__.py - About 2 days to fix

      Function read has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring.
      Open

          def read(  # noqa
              self, extension=None, quality=None
          ):  # noqa pylint: disable=too-many-statements,too-many-branches
              # returns image buffer in byte format.
      
      
      Severity: Minor
      Found in thumbor/engines/pil.py - About 1 day 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

      File pil.py has 415 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/engines/pil.py - About 5 hrs to fix

        BaseEngine has 43 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class BaseEngine:
            def __init__(self, context):
                self.context = context
                self.image = None
                self.extension = None
        Severity: Minor
        Found in thumbor/engines/__init__.py - About 5 hrs to fix

          Function on_image_ready has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              def on_image_ready(  # pylint: disable=too-many-statements,too-many-branches,too-many-locals
                  self, buffer
              ):
                  self.watermark_engine.load(buffer, None)
                  self.watermark_engine.enable_alpha()
          Severity: Minor
          Found in thumbor/filters/watermark.py - About 5 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

          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 __init__ has 35 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(
            Severity: Major
            Found in thumbor/context.py - About 4 hrs to fix

              File __init__.py has 331 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/engines/__init__.py - About 3 hrs to fix

                JSONEngine has 29 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class JSONEngine(BaseEngine):
                    def __init__(self, engine, path, callback_name=None):
                        super().__init__(engine.context)
                        self.engine = engine
                        self.extension = engine.extension
                Severity: Minor
                Found in thumbor/engines/json_engine.py - About 3 hrs to fix

                  Engine has 27 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Engine(BaseEngine):
                      def __init__(self, context):
                          super().__init__(context)
                          self.subsampling = None
                          self.qtables = None
                  Severity: Minor
                  Found in thumbor/engines/pil.py - About 3 hrs to fix

                    Function load_multiple_item has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def load_multiple_item(
                            self,
                            config_key,
                            conf_value,
                            class_name,
                    Severity: Minor
                    Found in thumbor/importer.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 _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 define_image_type has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def define_image_type(self, context, result):
                            if result is not None:
                                if isinstance(result, ResultStorageResult):
                                    buffer = result.buffer
                                else:
                    Severity: Minor
                    Found in thumbor/handlers/__init__.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 __init__ has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def __init__(
                            self,
                            debug=False,
                            meta=False,
                            trim=None,
                    Severity: Minor
                    Found in thumbor/context.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 is_animated_gif has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def is_animated_gif(self, data):
                            if data[:6] not in [b"GIF87a", b"GIF89a"]:
                                return False
                            i = 10  # skip header
                            frames = 0
                    Severity: Minor
                    Found in thumbor/handlers/__init__.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 load has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def load(self, buffer, extension):
                            self.extension = extension
                    
                            if extension is None:
                                mime = self.get_mimetype(buffer)
                    Severity: Minor
                    Found in thumbor/engines/__init__.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 __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(
                    Severity: Major
                    Found in thumbor/context.py - About 1 hr to fix

                      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 reorientate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def reorientate(self, override_exif=True):
                              """
                              Rotates the image in the buffer so that it is oriented correctly.
                              If override_exif is True (default) then the metadata
                              orientation is adjusted as well.
                      Severity: Minor
                      Found in thumbor/engines/__init__.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

                      Severity
                      Category
                      Status
                      Source
                      Language