fossasia/open-event-orga-server

View on GitHub
app/api/helpers/files.py

Summary

Maintainability
C
1 day
Test Coverage

File files.py has 374 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import base64
import io
import os
import urllib.parse
import urllib.request
Severity: Minor
Found in app/api/helpers/files.py - About 5 hrs to fix

Function create_save_image_sizes has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def create_save_image_sizes(
    image_file, image_sizes_type, unique_identifier=None, folder=None
):
    """
    Save the resized version of the background image
Severity: Minor
Found in app/api/helpers/files.py - About 3 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 create_save_resized_image has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def create_save_resized_image(
Severity: Major
Found in app/api/helpers/files.py - About 1 hr to fix

Function create_save_resized_image has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def create_save_resized_image(
    image_file,
    basewidth=None,
    maintain_aspect=None,
    height_size=None,
Severity: Minor
Found in app/api/helpers/files.py - About 55 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 uploaded_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def uploaded_file(files, multiple=False):
    if multiple:
        files_uploaded = []
        for file in files:
            extension = file.filename.split('.')[1]
Severity: Minor
Found in app/api/helpers/files.py - About 55 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 create_save_pdf has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def create_save_pdf(
Severity: Major
Found in app/api/helpers/files.py - About 50 mins to fix

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

def create_system_image(
    image_file=None, upload_path=None, unique_identifier=None, ext='jpg'
):
    """
    Create System Images for Event Topics
Severity: Minor
Found in app/api/helpers/files.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

There are no issues that match your filters.

Category
Status