resource-watch/aqueduct-analysis-microservice

View on GitHub

Showing 40 of 49 total issues

Function fuzzy_merge has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def fuzzy_merge(self, df_1, df_2, key1, key2, threshold=90, limit=1):
Severity: Minor
Found in aqueduct/services/food_supply_chain_service.py - About 45 mins to fix

    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):
    Severity: Minor
    Found in aqueduct/services/cba_service.py - About 45 mins to fix

      Function find_impact has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def find_impact(self, impact_cc, impact_soc, impact_sub, impact_cc_soc, impact_urb, model):
      Severity: Minor
      Found in aqueduct/services/risk_service.py - About 45 mins to fix

        Function select_projection_data has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def select_projection_data(self, dataframe, climate, model, socioecon, year):
        Severity: Minor
        Found in aqueduct/services/risk_service.py - About 35 mins to fix

          Function compute_rp_change has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def compute_rp_change(self, ref_impact, target_impact, rp, min_rp=2, max_rp=1000):
          Severity: Minor
          Found in aqueduct/services/risk_service.py - About 35 mins to fix

            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:
            Severity: Minor
            Found in aqueduct/services/cba_service.py - About 35 mins to fix

            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

            Avoid too many return statements within this function.
            Open

                    return error(status=500, detail=str(e))
            Severity: Major
            Found in aqueduct/routes/api/v1/ps_router.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return error(
              Severity: Major
              Found in aqueduct/routes/api/v1/ps_router.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return jsonify(payload), 500, {}
                Severity: Major
                Found in aqueduct/routes/api/v1/ps_router.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return error(status=500, detail=str(e))
                  Severity: Major
                  Found in aqueduct/routes/api/v1/ps_router.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return error(status=500, detail="Generic Error")
                    Severity: Major
                    Found in aqueduct/routes/api/v1/ps_router.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return jsonify(analyzer.results()), 200, {}
                      Severity: Major
                      Found in aqueduct/routes/api/v1/ps_router.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return error(status=500, detail=str(e))
                        Severity: Major
                        Found in aqueduct/routes/api/v1/ps_router.py - About 30 mins to fix

                          Function clean_buffer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def clean_buffer(self, row):
                                  """
                                  :param row: individual row (1 coordinate + material type)
                                  :return: buffer radius in decimal degrees
                                  """
                          Severity: Minor
                          Found in aqueduct/services/food_supply_chain_service.py - About 25 mins to fix

                          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 user_selections has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def user_selections(self):
                                  """
                                  Purpose: Gather all necessary inputs to run any analysis
                                  Input:
                                      flood: Riverine of Coastal (User must select)
                          Severity: Minor
                          Found in aqueduct/services/risk_service.py - About 25 mins to fix

                          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
                          Severity: Minor
                          Found in gunicorn.py - About 25 mins to fix

                          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('[CBADCache]: Getting cba default...')
                                      if 'cache_d_cba' in inspector.get_table_names():
                          Severity: Minor
                          Found in aqueduct/services/cba_defaults_service.py - About 25 mins to fix

                          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(uri, api_key):
                                  try:
                                      response = request_to_microservice(uri=uri, api_key=api_key, method="GET")
                                      if not response or response.get("errors"):
                                          raise GeostoreNotFound
                          Severity: Minor
                          Found in aqueduct/services/geostore_service.py - About 25 mins to fix

                          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():
                          Severity: Minor
                          Found in aqueduct/services/cba_service.py - About 25 mins to fix

                          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 bench has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def bench(self):
                                  defaultfn = "precalc_agg_{0}_{1}_{2}".format(self.flood, self.geogunit_type, self.sub_abb)
                                  print(defaultfn)
                          
                                  # cols = ['{0} as {1}'.format(col, col.replace(self.exposure, 'bench').replace('urban_damage_v2', 'bench').replace("_"+ self.scen_abb, '')) for col in sqlalchemy.Table(defaultfn, self.metadata).columns.keys() if ((self.exposure in col) or ('urban_damage_v2' in col)) and (self.scen_abb in col) and ("cc" not in col) and ("soc" not in col) and ("sub" not in col) and ("avg" in col)]
                          Severity: Minor
                          Found in aqueduct/services/risk_service.py - About 25 mins to fix

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language