resource-watch/aqueduct-analysis-microservice

View on GitHub

Showing 49 of 49 total issues

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