Showing 40 of 49 total issues
File food_supply_chain_service.py
has 693 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/local/bin/python
"""
Name: AqFood_Supply_Chain_Analyzer.py
Project: Aqueduct Food Tool Enhancements
Description:
File cba_service.py
has 675 lines of code (exceeds 250 allowed). Consider refactoring. Open
import datetime
import logging
import os
import sys, traceback
File risk_service.py
has 497 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
import os
import numpy as np
import pandas as pd
File ps_router.py
has 459 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""API ROUTER"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
File validators.py
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""VALIDATORS"""
import json
import logging
from functools import wraps
Function find_locations
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_locations(self, water_unit):
"""
:param water_unit: Geometry ID associated with the selected indicator. AQID for aquifers or PFAF_ID for watersheds
:return: dataframe with that matches each supply location to its watersheds and crops (close to final product); dataframe with all errors logged
"""
RiskService
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class RiskService(object):
def __init__(self, user_selections):
# DB Connection
self.engine = sqlalchemy.create_engine(os.getenv('POSTGRES_URL'))
self.metadata = sqlalchemy.MetaData(bind=self.engine)
Function calc_risk
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def calc_risk(self):
"""
Purpose: Runs analysis on the fly instead of using precalcuted results
(For when users define current protection level, find annual impact themselves)
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 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 prepare_payload
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def prepare_payload(self, payload):
new_payload = {}
for key in payload:
new_key = self.output_lookup.get(key)
- 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 analyze
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def analyze(**kwargs):
"""Analyze water risk data
---
get:
summary: Allow water risk atlas analysis. Pasing this params as 'application/json' on a Post
- 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_table
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_table(points, analysis_type, wscheme, month, year, change_type, indicator, scenario,
Function get_supply_chain_analysis
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_supply_chain_analysis(user_indicator, threshold, **kwargs):
try:
# check if the post request has the file part
if "data" not in request.files:
logging.error("[ROUTER]: No input file provided")
- 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 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 run_stats
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def run_stats(self, dataframe):
"""
Purpose: Finds the average, min, and max impact for all impact types
Input:
dataframe: Data associated with flood, geography, exposure type for all climate models
- 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 run
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def run(self):
try:
# b = os.path.getsize(self.user_input)
# f = open(self.user_input, 'rb')
# first_bytes = f.read(50)
- 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_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):