gfw-api/gfw-analysis-gee

View on GitHub

Showing 59 of 93 total issues

Function get_geo_by_geom has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def get_geo_by_geom(func):
    """Get geometry data"""

    @wraps(func)
    def wrapper(*args, **kwargs):
Severity: Minor
Found in gfwanalysis/middleware.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_composite_image has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def get_composite_image(geojson, instrument, date_range, thumb_size, \
Severity: Major
Found in gfwanalysis/services/analysis/composite_service.py - About 1 hr to fix

    Function get_by_geostore has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def get_by_geostore(lat, lon, start, end, sort_by, bands, bmin, bmax, opacity):
    Severity: Major
    Found in gfwanalysis/routes/api/v1/recent_router.py - About 1 hr to fix

      Function analyze_recent_data has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def analyze_recent_data(lat, lon, start, end, sort_by, bands, bmin, bmax, opacity):
      Severity: Major
      Found in gfwanalysis/routes/api/v1/recent_router.py - About 1 hr to fix

        Function validate_bands has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate_bands(bands, instrument):
                """Validate and serialide bands"""
                # Format
                if type(bands) == str:
                    bands = bands[1:-1].split(",")
        Severity: Minor
        Found in gfwanalysis/services/analysis/recent_tiles.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 set_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def set_params():
            """-"""
            threshold = int(request.args.get('thresh', 30))
            begin = request.args.get('begin', '2000-01-01')
            end = request.args.get('end', '2019-12-31')
        Severity: Minor
        Found in gfwanalysis/routes/api/__init__.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 analyze has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def analyze(threshold, geojson, begin, end, aggregate_values=True,
        Severity: Major
        Found in gfwanalysis/services/analysis/hansen_service.py - About 1 hr to fix

          Function get_composite_image has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_composite_image(geojson, instrument, date_range, thumb_size, \
                                      classify, band_viz, get_dem, get_stats, show_bounds, cloudscore_thresh):
                  logging.info(f"[COMPOSITE SERVICE]: Creating composite")
                  try:
                      features = geojson.get('features')
          Severity: Minor
          Found in gfwanalysis/services/analysis/composite_service.py - About 55 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_recent_thumbs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

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

          def get_recent_tiles(func):
              @wraps(func)
              def wrapper(*args, **kwargs):
                  if request.method == 'POST':
                      data_array = request.get_json().get('source_data', [])
          Severity: Minor
          Found in gfwanalysis/middleware.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 analyze has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def analyze(geojson, area_ha):
              """Analyze Hansen"""
              if not geojson:
                  return error(status=400, detail='Geojson is required')
              threshold, begin, end, table = set_params()
          Severity: Minor
          Found in gfwanalysis/routes/api/v1/hansen_router.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 get_extent_fc has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def get_extent_fc(image, fc, method='reduce_regions', bestEffort=False, scale=False, numPixels=10000):
          Severity: Minor
          Found in gfwanalysis/utils/geo.py - About 45 mins to fix

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

                def gen_intact_sentence(stats):
                    not_intact = stats.get('intact2016').get('0', 0)
                    is_intact = stats.get('intact2016').get('1', 0)
                    total_intact = not_intact + is_intact
                    intact_sentence = ""
            Severity: Minor
            Found in gfwanalysis/services/analysis/geodescriber.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 lookup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def lookup(layer, result_dict, count_pixels):
                lkp = all_lulc_dict[layer]
            
                if count_pixels:
                    area_type = 'pixelCount'
            Severity: Minor
            Found in gfwanalysis/utils/landcover_lookup.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 create_title_elements has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def create_title_elements(s):
                    """Take reverse geocoding results for upper and lower corners of a polygons bounds,
                        Extract the region, county, country, continent attributes of the locations.
                        Use the overlap to set an appropriate title.
                    """
            Severity: Minor
            Found in gfwanalysis/services/analysis/geodescriber.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 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/biomass_loss_router.py - About 35 mins to fix

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

              def analyze_recent_thumbs(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_tile has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def get_by_tile(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/mangrove_biomass_router.py - About 35 mins to fix

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

                        def analyze(threshold, geojson, begin, end, layer, count_pixels):
                    Severity: Minor
                    Found in gfwanalysis/services/analysis/histogram_service.py - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language