gfw-api/gfw-analysis-gee

View on GitHub
gfwanalysis/middleware.py

Summary

Maintainability
D
2 days
Test Coverage
F
19%

Function get_composite_params has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

def get_composite_params(func):
    """Get instrument"""

    @wraps(func)
    def wrapper(*args, **kwargs):
Severity: Minor
Found in gfwanalysis/middleware.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 middleware.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""MIDDLEWARE"""

import json
import logging
from functools import wraps
Severity: Minor
Found in gfwanalysis/middleware.py - About 4 hrs to fix

    Function get_geo_by_hash has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_geo_by_hash(func):
        """Get geodata"""
    
        @wraps(func)
        def wrapper(*args, **kwargs):
    Severity: Minor
    Found in gfwanalysis/middleware.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 get_mc_info has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_mc_info(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if request.method == 'POST':
                data_array = request.get_json().get('timeseries')
    Severity: Minor
    Found in gfwanalysis/middleware.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 get_geo_by_geom has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_geo_by_geom(func):
        """Get geometry data"""
    
        @wraps(func)
        def wrapper(*args, **kwargs):
    Severity: Minor
    Found in gfwanalysis/middleware.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 get_recent_thumbs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_recent_thumbs(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
    
            if request.method == 'POST':
    Severity: Minor
    Found in gfwanalysis/middleware.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 get_recent_tiles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_recent_tiles(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if request.method == 'POST':
                data_array = request.get_json().get('source_data', [])
    Severity: Minor
    Found in gfwanalysis/middleware.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 get_sentinel_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_sentinel_params(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if request.method == 'GET':
                lat = request.args.get('lat')
    Severity: Minor
    Found in gfwanalysis/middleware.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