gfw-api/gfw-analysis-gee

View on GitHub

Showing 59 of 93 total issues

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

def get_by_regional(iso, id1, id2, geojson, area_ha):
Severity: Minor
Found in gfwanalysis/routes/api/v1/soil_carbon_router.py - About 35 mins to fix

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

    def get_by_regional(iso, id1, id2, geojson, area_ha):
    Severity: Minor
    Found in gfwanalysis/routes/api/v1/population_service_router.py - About 35 mins to fix

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

      def get_by_regional(iso, id1, id2, geojson, area_ha):
      Severity: Minor
      Found in gfwanalysis/routes/api/v1/forma250_router.py - About 35 mins to fix

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

        def analyze(year, z, x, y, map_object):
        Severity: Minor
        Found in gfwanalysis/routes/api/v2/landsat_router.py - About 35 mins to fix

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

          def analyze_recent_tiles(data_array, bands, bmin, bmax, opacity):
          Severity: Minor
          Found in gfwanalysis/routes/api/v1/recent_router.py - About 35 mins to fix

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

            def get_by_regional(iso, id1, id2, geojson, area_ha):
            Severity: Minor
            Found in gfwanalysis/routes/api/v1/biomass_loss_router.py - About 35 mins to fix

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

              def get_by_regional(iso, id1, id2, geojson, area_ha):
              Severity: Minor
              Found in gfwanalysis/routes/api/v1/whrc_biomass_router.py - About 35 mins to fix

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

                def get_tile(year, z, x, y, map_object=None):
                Severity: Minor
                Found in gfwanalysis/routes/api/v2/landsat_router.py - About 35 mins to fix

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

                  def get_by_regional(iso, id1, id2, geojson, area_ha):
                  Severity: Minor
                  Found in gfwanalysis/routes/api/v2/nlcd_landcover_router.py - About 35 mins to fix

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

                    def get_by_thumb(data_array, bands, bmin, bmax, opacity):
                    Severity: Minor
                    Found in gfwanalysis/routes/api/v1/recent_router.py - About 35 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return jsonify(data=serialize_biomass_v1(data, 'biomasses')), 200
                      Severity: Major
                      Found in gfwanalysis/routes/api/v1/biomass_loss_router.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return jsonify(data=serialize_biomass_v2(data, 'biomass-loss')), 200
                        Severity: Major
                        Found in gfwanalysis/routes/api/v2/biomass_loss_router.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return jsonify(data=serialize_umd(data, 'umd')), 200
                          Severity: Major
                          Found in gfwanalysis/routes/api/v1/hansen_router.py - About 30 mins to fix

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

                            def get_sentinel_params(func):
                                @wraps(func)
                                def wrapper(*args, **kwargs):
                                    if request.method == 'GET':
                                        lat = request.args.get('lat')
                            Severity: Minor
                            Found in gfwanalysis/middleware.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 return_pixel_count has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def return_pixel_count():
                                if request.method == 'GET':
                                    pixel_count = request.args.get('pixel_count', None)
                                else:
                                    pixel_count = request.get_json().get('pixel_count', None) if request.get_json() else None
                            Severity: Minor
                            Found in gfwanalysis/routes/api/__init__.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 serialize_recent_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def serialize_recent_url(analysis, type):
                                logging.info("[SERIALISER] Initiating")
                                """Convert output of images to json"""
                                tmp_output = []
                                output = {}
                            Severity: Minor
                            Found in gfwanalysis/serializers.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 gen_mountain_sentence has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def gen_mountain_sentence(stats):
                                    is_mountain = stats.get('isMountain').get('1', 0)
                                    not_mountain = stats.get('isMountain').get('0', 0)
                                    total_mountain = not_mountain + is_mountain
                                    mountain_sentence = None
                            Severity: Minor
                            Found in gfwanalysis/services/analysis/geodescriber.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 decode_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def decode_response(begin, end, gee_response, layer):
                                    requested_years = range(int(begin + 2000), int(end + 2000) + 1)
                            
                                    lulc_vals = valid_lulc_codes(layer)
                            
                            
                            Severity: Minor
                            Found in gfwanalysis/services/analysis/histogram_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