File cba_service.py
has 675 lines of code (exceeds 250 allowed). Consider refactoring. Open
import datetime
import logging
import os
import sys, traceback
Function average_prot
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def average_prot(self, m, year, risk_data_input):
#logging.debug('[CBA, average_prot]: start')
idx = int(year) - self.implementation_start
#logging.debug(f'[CBA, average_prot, idx]: {idx} ==> {year} {self.implementation_start}')
clm = "histor" if year == '2010' else self.clim
- 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 __init__
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self, user_selections):
### DBConexion
self.engine = sqlalchemy.create_engine(os.getenv('POSTGRES_URL'))
self.metadata = sqlalchemy.MetaData(bind=self.engine)
self.metadata.reflect(self.engine)
Function analyze
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def analyze(self):
# allStartTime = time.time()
##--------------------------------------------------------
### ANALYSIS ###
##--------------------------------------------------------
- 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 precalc_present_benefits
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def precalc_present_benefits(self, model):
"""
Inputs:
prot_start_unit = present_day protection standard (assumed to beong to 0th year in list of years)
Output:
- 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 compute_benefits
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def compute_benefits(self, model, annual_risk_pres, annual_risk_fut, annual_pop_pres, annual_pop_fut,
Function compute_rp_change
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def compute_rp_change(self, rps, ref_impact, target_impact, rp, min_rp=2, max_rp=1000):
Function risk_evolution
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def risk_evolution(self, impact_cc, impact_urb, impact_pop, impact_gdp, prot, prot_idx):
Function user_selections
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def user_selections(self):
"""
Purpose: Gather all neccesary inputs to run any analysis
Output:
- 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 execute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def execute(self):
try:
inspector = sqlalchemy.inspect(self.engine)
logging.info('[CBAICache]: Getting cba default...')
if 'cache_cba' in inspector.get_table_names():
- 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"