gfw-api/fires-summary-stats

View on GitHub

Showing 8 of 12 total issues

Function format_dataset_query has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    def format_dataset_query(dataset_name, params):

        agg_by = params['aggregate_by']
        agg_values = params['aggregate_values']
        agg_admin = params['aggregate_admin']
Severity: Minor
Found in fireSummary/services/query_constructor_service.py - About 6 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_time_table has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    def create_time_table(dataset_name, data, params):
        agg_by = params["aggregate_by"]
        agg_values = params["aggregate_values"]
        agg_admin = params["aggregate_admin"]
        agg_time = params["aggregate_time"]
Severity: Minor
Found in fireSummary/services/summary_service.py - About 6 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 validate_period has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

def validate_period(minYear, params):
    # validate period
    today = datetime.datetime.now()
    period = request.args.get("period", None)

Severity: Minor
Found in fireSummary/validators.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 validate_aggregate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def validate_aggregate(params):
    # validate aggregate
    agg_values = request.args.get("aggregate_values")
    agg_by = request.args.get("aggregate_by")
    agg_admin = request.args.get("aggregate_admin")
Severity: Minor
Found in fireSummary/validators.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 validate_args_fires has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def validate_args_fires(func):
    """Validate user arguments"""

    @wraps(func)
    def wrapper(*args, **kwargs):
Severity: Minor
Found in fireSummary/validators.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 summarize_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def summarize_data(dataset_name, params, is_valid_combo):

    # we've already validated that the input iso/adm1/adm2 exists, and the
    # polyname (if applicable) exists. Now time to see if the full combo
    # (like - wdpa/BRA/1/1) exists in the world
Severity: Minor
Found in fireSummary/routes/api/v1/fires_router.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 worker_int has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def worker_int(worker):
    worker.log.info("worker received INT or QUIT signal")

    ## get traceback info
    import threading, sys, traceback
Severity: Minor
Found in gunicorn.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 load_adm_rows has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def load_adm_rows(dataset_name, params):

    valid_rows = load_valid_poly_iso(dataset_name)

    # looks like [<iso>] or [iso, adm1] or [iso, adm1, adm2]
Severity: Minor
Found in fireSummary/utils/util.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