18F/crime-data-api

View on GitHub

Showing 91 of 91 total issues

Cyclomatic complexity is too high in method verify_api_key. (8)
Open

def verify_api_key(self, args):
if os.getenv('VCAP_SERVICES'):
service_env = json.loads(os.getenv('VCAP_SERVICES'))
cups_name = 'crime-data-api-creds'
creds = [
Severity: Minor
Found in crime_data/common/base.py by radon

Cyclomatic complexity is too high in method base_query. (8)
Open

def base_query(self, field):
select_query = 'SELECT b.:field, a.count, b.year FROM (SELECT :field , count, year::text'
from_query = ' FROM :view_name'
where_query = ' WHERE :field IS NOT NULL'
 
 
Severity: Minor
Found in crime_data/common/cdemodels.py by radon

Cyclomatic complexity is too high in method query. (8)
Open

def query(self, args):
base_query = None
qry = None
param_dict = {}
try:
Severity: Minor
Found in crime_data/common/cdemodels.py by radon

Function urls has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def urls(url, order):
"""Display all of the url matching routes for the project.
 
Borrowed from Flask-Script, converted to use Click.
"""
Severity: Minor
Found in crime_data/commands.py - About 2 hrs to fix

Cyclomatic complexity is too high in class AgencySums. (7)
Open

class AgencySums(db.Model):
 
__tablename__ = 'agency_sums_view'
 
id = db.Column(db.BigInteger, autoincrement=True, primary_key=True)
Severity: Minor
Found in crime_data/common/newmodels.py by radon

Cyclomatic complexity is too high in method get. (7)
Open

def get(self, state = None, agency = None, year = None, county = None, explorer_offense = None):
"""Get Agency Sums given a state/year/county/agency ori, etc."""
query = AgencyOffenseCounts.query
 
if state:
Severity: Minor
Found in crime_data/common/newmodels.py by radon

Cyclomatic complexity is too high in method output_serialize. (7)
Open

def output_serialize(self,
data,
schema=None,
format='csv',
aggregate_many=False):
Severity: Minor
Found in crime_data/common/base.py by radon

Cyclomatic complexity is too high in class AgencyOffenseCounts. (7)
Open

class AgencyOffenseCounts(db.Model):
__tablename__ = 'agency_offenses_view'
 
id = db.Column(db.BigInteger, autoincrement=True, primary_key=True)
year = db.Column(db.SmallInteger)
Severity: Minor
Found in crime_data/common/newmodels.py by radon

Cyclomatic complexity is too high in method __init__. (7)
Open

def __init__(self, field, year=None, state_id=None, state_abbr=None, ori=None, as_json=True):
 
self.as_json = as_json
 
if field is None:
Severity: Minor
Found in crime_data/common/cdemodels.py by radon

Cyclomatic complexity is too high in class AgencyClassificationCounts. (7)
Open

class AgencyClassificationCounts(db.Model):
__tablename__ = 'agency_classification_view'
 
id = db.Column(db.BigInteger, autoincrement=True, primary_key=True)
year = db.Column(db.SmallInteger)
Severity: Minor
Found in crime_data/common/newmodels.py by radon

Cyclomatic complexity is too high in class MultiYearCountView. (7)
Open

class MultiYearCountView(object):
"""For materialized views that aren't split by year"""
 
__abstract__ = True
 
 
Severity: Minor
Found in crime_data/common/cdemodels.py by radon

Cyclomatic complexity is too high in method get. (7)
Open

def get(self, state = None, agency = None, year = None, county = None, classification = None):
"""Get Agency Sums given a state/year/county/agency ori, etc."""
query = AgencyClassificationCounts.query
 
if state:
Severity: Minor
Found in crime_data/common/newmodels.py by radon

Cyclomatic complexity is too high in method get. (7)
Open

def get(self, state = None, agency = None, year = None, county = None, explorer_offense = None):
"""Get Agency Sums given a state/year/county/agency ori, etc."""
query = AgencySums.query
 
if state:
Severity: Minor
Found in crime_data/common/newmodels.py by radon

Cyclomatic complexity is too high in method base_query. (7)
Open

def base_query(self, field):
 
query = 'SELECT b.:field, a.count, b.year FROM (SELECT :field ,stolen_value::text, recovered_value::text, year::text, count'
query += ' FROM :view_name '
where_query = ' WHERE :field IS NOT NULL'
Severity: Minor
Found in crime_data/common/cdemodels.py by radon

Cyclomatic complexity is too high in method _parse_inequality_operator. (7)
Open

def _parse_inequality_operator(self, k, v):
"""
Returns (key, value, comparitor)
"""
if v:
Severity: Minor
Found in crime_data/common/base.py by radon

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

def get_field_table(self, field):
if field in ['weapon_name']:
return ('nibrs_weapon_type','weapon_name')
 
if field in ['method_entry_code']:
Severity: Minor
Found in crime_data/common/cdemodels.py - About 1 hr to fix

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

def get_field_table(self, field):
if field in ['weapon_name']:
return ('nibrs_weapon_type','weapon_name')
 
if field in ['method_entry_code']:
Severity: Minor
Found in crime_data/common/cdemodels.py - About 1 hr to fix

Cyclomatic complexity is too high in function lint. (6)
Open

@click.command()
@click.option('-f',
'--fix-imports',
default=False,
is_flag=True,
Severity: Minor
Found in crime_data/commands.py by radon

Function base_query has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def base_query(self, field):
if self.explorer_offense:
query = 'SELECT b.:field, SUM(a.count)::int AS count, SUM(a.stolen_value)::text AS stolen_value, SUM(a.recovered_value)::text AS recovered_value, :explorer_offense AS offense_name, b.year FROM (SELECT year::text, offense_name, :field, '
query += 'count, stolen_value, recovered_value'
else:
Severity: Minor
Found in crime_data/common/cdemodels.py - About 1 hr to fix

Function base_query has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def base_query(self, field):
 
 
if self.explorer_offense:
query = 'SELECT b.year, :explorer_offense AS offense_name, b.:field, SUM(a.count)::int AS count from (SELECT year::text, offense_name, :field, count'
Severity: Minor
Found in crime_data/common/cdemodels.py - About 1 hr to fix
Severity
Category
Status
Source
Language