resource-watch/prep-nexgddp

View on GitHub

Showing 34 of 34 total issues

File nexgddp_router.py has 510 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""API ROUTER"""
import io
import logging
import os

Severity: Major
Found in nexgddp/routes/api/v1/nexgddp_router.py - About 1 day to fix

    Function query has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

    def query(dataset_id, bbox, dataset):
        """NEXGDDP QUERY ENDPOINT"""
        logging.info('[ROUTER] Doing Query of dataset ' + dataset_id)
        # Get and deserialize
        table_name = dataset.get('tableName')
    Severity: Minor
    Found in nexgddp/routes/api/v1/nexgddp_router.py - About 6 hrs 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

    File query_service.py has 373 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """QUERY SERVICE"""
    
    import logging
    import os
    import tempfile
    Severity: Minor
    Found in nexgddp/services/query_service.py - About 4 hrs to fix

      Function get_fields has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_fields(xml):
              logging.info('[XMLService] Parsing XML fields')
              fields = {}
              try:
                  root = ET.fromstring(xml)
      Severity: Minor
      Found in nexgddp/services/xml_service.py - About 3 hrs 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 get_tile has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def get_tile(z, x, y, model, scenario, year, style, indicator, layer, compare_year=None, dset_b=None, no_data=None):
      Severity: Major
      Found in nexgddp/routes/api/v1/nexgddp_router.py - About 1 hr to fix

        Function get_sql_select has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_sql_select(json_sql):
            select_sql = json_sql.get('select')
            logging.debug(f"select_sql: {select_sql}")
            select_sql
            select = None
        Severity: Minor
        Found in nexgddp/routes/api/v1/nexgddp_router.py - About 1 hr 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 get_domain has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_domain(xml):
                logging.info('[XMLService] Parsing XML domain info')
                domain = {}
                try:
                    root = ET.fromstring(xml)
        Severity: Minor
        Found in nexgddp/services/xml_service.py - About 1 hr 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 get_tile_diff_query has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get_tile_diff_query(bbox, year, model, scenario, indicator, bounds, year_b, dset_b):
        Severity: Major
        Found in nexgddp/services/query_service.py - About 50 mins to fix

          Function diff has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def diff(dset_a, date_a, date_b, lat, lon, varnames, dset_b=None):
          Severity: Major
          Found in nexgddp/routes/api/v1/nexgddp_router.py - About 50 mins to fix

            Function upload_file has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def upload_file(filename, layer, z, x, y, year, compare_year, dset_b):
            Severity: Major
            Found in nexgddp/services/storage_service.py - About 50 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          for field_spec in field.findall('{http://www.opengis.net/swe/2.0}Quantity'):
                                              for field_spec_uom in field_spec.findall('{http://www.opengis.net/swe/2.0}uom'):
                                                  fields[field_name] = {
                                                      'type': 'number',
                                                      'uom': field_spec_uom.get('code')
              Severity: Major
              Found in nexgddp/services/xml_service.py - About 45 mins to fix

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

                    def get_diff_value(dset_a, date_a, date_b, lat, lon, varnames, dset_b):
                Severity: Minor
                Found in nexgddp/services/diff_service.py - About 45 mins to fix

                  Function get_all_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_all_data(scenario, model, years, bbox):
                          logging.info('[QueryService] Getting * data from rasdaman')
                          year_min = sorted(years)[0]
                          year_max = sorted(years)[-1]
                          results = []
                  Severity: Minor
                  Found in nexgddp/services/query_service.py - About 45 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 make_tile_cache_key has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def make_tile_cache_key(layer, z, x, y, year, compare_year=None, dset_b=None):
                  Severity: Minor
                  Found in nexgddp/services/storage_service.py - About 45 mins to fix

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

                        def get_stats(scenario, model, years, indicator, bbox, function):
                    Severity: Minor
                    Found in nexgddp/services/query_service.py - About 35 mins to fix

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

                          def get_tile_query(bbox, year, model, scenario, indicator, bounds):
                      Severity: Minor
                      Found in nexgddp/services/query_service.py - About 35 mins to fix

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

                            def get_tile_mask_query(bbox, year, model, scenario, indicator, no_data):
                        Severity: Minor
                        Found in nexgddp/services/query_service.py - About 35 mins to fix

                          Function get_dataset_from_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def get_dataset_from_id(func):
                              @wraps(func)
                              def wrapper(*args, **kwargs):
                                  logging.debug("Getting dataset from id")
                          
                          
                          Severity: Minor
                          Found in nexgddp/middleware.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

                          Function get_tile_attrs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def get_tile_attrs(func):
                              """Get style"""
                          
                              @wraps(func)
                              def wrapper(*args, **kwargs):
                          Severity: Minor
                          Found in nexgddp/middleware.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

                          Function get_tile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def get_tile(z, x, y, model, scenario, year, style, indicator, layer, compare_year=None, dset_b=None, no_data=None):
                              logging.info(f'Getting tile for {z} {x} {y}')
                              logging.debug(compare_year)
                              bbox = TileService.get_bbox(x, y, z)
                              logging.debug(f"bbox: {bbox}")
                          Severity: Minor
                          Found in nexgddp/routes/api/v1/nexgddp_router.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

                          Severity
                          Category
                          Status
                          Source
                          Language