Showing 13 of 13 total issues
Function validate_period
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def validate_period():
# validate period
today = datetime.datetime.now()
period = request.args.get('period', None)
minYear = 2015
- Read upRead up
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_geojson
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def validate_geojson(func):
"""validate input geojson"""
@wraps(func)
def wrapper(*args, **kwargs):
- Read upRead up
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 calc_stats
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def calc_stats(geojson, request, geostore_id):
"""Given an input geojson and (optionally) some params
(period, agg_by, etc), calculate the # of alerts in an AOI"""
geom = shape(geojson['features'][0]['geometry'])
- Read upRead up
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 format_alerts_admin
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def format_alerts_admin(request, glad_alerts):
# take the glad alerts format and strip out some attributes
agg_by = request.args.get('aggregate_by', None)
for elem in glad_alerts['data']['attributes']['value']:
- Read upRead up
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_geojson
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_geojson(func):
"""Grab geojson any way it comes - with geostore ID,
with wdpa ID or use ID, or just POSTed geojson.
Convert this into a dictionary object and return
it as the variable `geojson`
- Read upRead up
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 process_tile
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process_tile(tile_list, aoi):
# main function to compare a list of tiles to an input geometry
# will eventually return a list of tiles completely within the aoi (all zoom levels possible)
# and tiles that intersect the aoi (must be of max_z because that's as low as we go)
- Read upRead up
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 build_download_urls
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def build_download_urls(id_tuple, geostore_id, agg_values, agg_by, period, conf):
# id_tuple looks like this: (iso, adm1, adm2)
if id_tuple:
# unpack it
- Read upRead up
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 build_download_urls
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_download_urls(id_tuple, geostore_id, agg_values, agg_by, period, conf):
Function serialize_response
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def serialize_response(request, glad_alerts, aoi_area_ha, geostore_id=None, id_tuple=None):
Function format_alerts_geom
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def format_alerts_geom(rows, request):
agg_by = request.args.get('aggregate_by')
# pull first row from sql response [(<alert_date>, <alert_count>), ()]
if rows:
- Read upRead up
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 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_aggregate():
# validate aggregate
agg_by = request.args.get('aggregate_by')
agg_values = request.args.get('aggregate_values')
- Read upRead up
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 grouped_and_to_rows
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def grouped_and_to_rows(keys, vals, agg_type):
# source: https://jakevdp.github.io/blog/2017/03/22/group-by-from-scratch/
count = defaultdict(int)
for key, val in zip(keys, vals):
count[key] += val
- Read upRead up
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
- Read upRead up
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"