File cdemodels.py
has 1454 lines of code (exceeds 250 allowed). Consider refactoring.
import abc
from collections import namedtuple
from flask_restful import abort
from sqlalchemy import and_, func, or_, UniqueConstraint, PrimaryKeyConstraint, Index
from sqlalchemy.exc import ArgumentError
Cyclomatic complexity is too high in method get_field_table. (16)
def get_field_table(self, field):
if field in ['weapon_name']:
return ('nibrs_weapon_type','weapon_name')
if field in ['method_entry_code']:
Cyclomatic complexity is too high in method get_field_table. (16)
def get_field_table(self, field):
if field in ['weapon_name']:
return ('nibrs_weapon_type','weapon_name')
if field in ['method_entry_code']:
Cyclomatic complexity is too high in method base_query. (11)
def base_query(self, field):
if self.explorer_offense:
query = 'SELECT b.:field, SUM(a.count)::int AS count, :explorer_offense AS offense_name, b.year FROM (SELECT year::text, offense_name, :field, count'
else:
Cyclomatic complexity is too high in class OffenseSubCountView. (11)
class OffenseSubCountView(object):
def __init__(self, field, year=None, state_id=None, ori=None,
offense_name=None, state_abbr=None, explorer_offense=None, as_json=True):
Cyclomatic complexity is too high in method base_query. (11)
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'
Cyclomatic complexity is too high in method base_query. (11)
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:
Cyclomatic complexity is too high in method __init__. (9)
def __init__(self, field, year=None, state_id=None, ori=None,
offense_name=None, state_abbr=None, explorer_offense=None, as_json=True):
self.as_json = as_json
Cyclomatic complexity is too high in method base_query. (8)
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'
Cyclomatic complexity is too high in method query. (8)
def query(self, args):
base_query = None
qry = None
param_dict = {}
try:
Cyclomatic complexity is too high in method __init__. (7)
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:
Cyclomatic complexity is too high in class MultiYearCountView. (7)
class MultiYearCountView(object):
"""For materialized views that aren't split by year"""
__abstract__ = True
Cyclomatic complexity is too high in method base_query. (7)
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'
Function get_field_table
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
def get_field_table(self, field):
if field in ['weapon_name']:
return ('nibrs_weapon_type','weapon_name')
if field in ['method_entry_code']:
Function get_field_table
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
def get_field_table(self, field):
if field in ['weapon_name']:
return ('nibrs_weapon_type','weapon_name')
if field in ['method_entry_code']:
Function base_query
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
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:
Function base_query
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
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'
Function base_query
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
def base_query(self, field):
if self.explorer_offense:
query = 'SELECT b.:field, SUM(a.count)::int AS count, :explorer_offense AS offense_name, b.year FROM (SELECT year::text, offense_name, :field, count'
else:
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring.
def __init__(self, field, year=None, state_id=None, ori=None,
Function base_query
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
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'
Function query
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def query(self, args):
base_query = None
qry = None
param_dict = {}
try:
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring.
def __init__(self, field, year=None, state_id=None, state_abbr=None, ori=None, as_json=True):
Function base_query
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
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'
Function __init__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def __init__(self, field, year=None, state_id=None, ori=None,
offense_name=None, state_abbr=None, explorer_offense=None, as_json=True):
self.as_json = as_json
Avoid too many return
statements within this function.
return ('nibrs_relationship','relationship_name')
Avoid too many return
statements within this function.
return ('nibrs_relationship','relationship_name')
Avoid too many return
statements within this function.
return ('nibrs_circumstances', 'circumstances_name')
Avoid too many return
statements within this function.
return (None, None)
Avoid too many return
statements within this function.
return ('nibrs_age_num','age_num')
Avoid too many return
statements within this function.
return ('ref_race','race_code')
Avoid too many return
statements within this function.
return ('nibrs_offense_type','offense_name')
Avoid too many return
statements within this function.
return ('nibrs_location_type','location_name')
Avoid too many return
statements within this function.
return ('nibrs_prop_desc_type','prop_desc_name')
Avoid too many return
statements within this function.
return ('nibrs_ethnicity','ethnicity_name')
Avoid too many return
statements within this function.
return ('nibrs_ethnicity','ethnicity_name')
Avoid too many return
statements within this function.
return ('nibrs_sex_code','sex_code')
Avoid too many return
statements within this function.
return ('nibrs_age_num','age_num')
Avoid too many return
statements within this function.
return ('nibrs_prop_desc_type','prop_desc_name')
Avoid too many return
statements within this function.
return ('nibrs_victim_type','victim_type_name')
Avoid too many return
statements within this function.
return ('nibrs_victim_type','victim_type_name')
Avoid too many return
statements within this function.
return ('nibrs_offense_type','offense_name')
Avoid too many return
statements within this function.
return ('nibrs_location_type','location_name')
Avoid too many return
statements within this function.
return ('nibrs_circumstances', 'circumstances_name')
Avoid too many return
statements within this function.
return ('nibrs_resident_status_code','resident_status_code')
Avoid too many return
statements within this function.
return ('nibrs_resident_status_code','resident_status_code')
Avoid too many return
statements within this function.
return ('ref_race','race_code')
Avoid too many return
statements within this function.
return (None, None)
Avoid too many return
statements within this function.
return ('nibrs_sex_code','sex_code')
There are no issues that match your filters.