thumbor/thumbor

View on GitHub

Showing 64 of 69 total issues

Function import_modules has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def import_modules(self):
        if (
            self.config.COMPATIBILITY_LEGACY_LOADER
            or self.config.COMPATIBILITY_LEGACY_STORAGE
            or self.config.COMPATIBILITY_LEGACY_RESULT_STORAGE
Severity: Minor
Found in thumbor/importer.py - About 45 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

Function import_item has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def import_item(
Severity: Minor
Found in thumbor/importer.py - About 45 mins to fix

    Function signal_handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def signal_handler(server, config, sig, _):
        io_loop = tornado.ioloop.IOLoop.instance()
    
        def stop_loop(now, deadline):
            if now < deadline and (
    Severity: Minor
    Found in thumbor/signal_handler.py - About 45 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

    Function reload_to_fit_in_kb has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def reload_to_fit_in_kb(
    Severity: Minor
    Found in thumbor/handlers/__init__.py - About 35 mins to fix

      Function draw_rectangle has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def draw_rectangle(self, x, y, width, height):
      Severity: Minor
      Found in thumbor/engines/gif.py - About 35 mins to fix

        Function apply_blur has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def apply_blur(mode, data, size, radius, sigma=0):
        Severity: Minor
        Found in thumbor/filters/blur.py - About 35 mins to fix

          Function load_multiple_item has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def load_multiple_item(
          Severity: Minor
          Found in thumbor/importer.py - About 35 mins to fix

            Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(
            Severity: Minor
            Found in thumbor/handlers/__init__.py - About 35 mins to fix

              Function crop has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def crop(self, left, top, right, bottom):
              Severity: Minor
              Found in thumbor/engines/gif.py - About 35 mins to fix

                Function from_square has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def from_square(
                Severity: Minor
                Found in thumbor/point.py - About 35 mins to fix

                  Function __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __init__(self, context, importer):
                          self.context = context
                          self.importer = importer
                  
                          self.engine = None
                  Severity: Minor
                  Found in thumbor/context.py - About 35 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

                  Function reload_to_fit_in_kb has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def reload_to_fit_in_kb(
                          engine, initial_results, extension, initial_quality, max_bytes
                      ):
                          if (
                              extension not in [".webp", ".jpg", ".jpeg"]
                  Severity: Minor
                  Found in thumbor/handlers/__init__.py - About 35 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

                  Function normalize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def normalize(self):
                          width, height = self.size
                          self.source_width = width
                          self.source_height = height
                  
                  
                  Severity: Minor
                  Found in thumbor/engines/__init__.py - About 35 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

                  Function validate_config has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def validate_config(config, server_parameters):
                      if server_parameters.security_key is None:
                          server_parameters.security_key = config.SECURITY_KEY
                  
                      if not isinstance(server_parameters.security_key, (bytes, str)):
                  Severity: Minor
                  Found in thumbor/server.py - About 35 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

                  Function import_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def import_item(
                          self,
                          config_key=None,
                          class_name=None,
                          is_multiple=False,
                  Severity: Minor
                  Found in thumbor/importer.py - About 35 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

                  Avoid too many return statements within this function.
                  Open

                      return dst_im
                  Severity: Major
                  Found in thumbor/utils.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return None
                    Severity: Major
                    Found in thumbor/utils.py - About 30 mins to fix

                      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

                      Function ensure_dir has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def ensure_dir(self, path):
                              if not exists(path):
                                  try:
                                      os.makedirs(path)
                                  except OSError as err:
                      Severity: Minor
                      Found in thumbor/storages/__init__.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

                      Function image_data_as_rgb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def image_data_as_rgb(self, update_image=True):
                              converted_image = self.image
                      
                              if converted_image.mode not in ["RGB", "RGBA"]:
                                  if "A" in converted_image.mode:
                      Severity: Minor
                      Found in thumbor/engines/pil.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

                      Severity
                      Category
                      Status
                      Source
                      Language