gfw-api/gfw-analysis-gee

View on GitHub

Showing 59 of 93 total issues

File geodescriber.py has 1586 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import asyncio
import logging

import ee
from googletrans import Translator
Severity: Major
Found in gfwanalysis/services/analysis/geodescriber.py - About 4 days to fix

    File geo.py has 402 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import asyncio
    import functools as funct
    import logging
    
    import ee
    Severity: Minor
    Found in gfwanalysis/utils/geo.py - About 5 hrs to fix

      Function get_composite_params has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_composite_params(func):
          """Get instrument"""
      
          @wraps(func)
          def wrapper(*args, **kwargs):
      Severity: Minor
      Found in gfwanalysis/middleware.py - About 5 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 middleware.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """MIDDLEWARE"""
      
      import json
      import logging
      from functools import wraps
      Severity: Minor
      Found in gfwanalysis/middleware.py - About 4 hrs to fix

        File serializers.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Serializers"""
        import logging
        
        
        def serialize_umd(analysis, type):
        Severity: Minor
        Found in gfwanalysis/serializers.py - About 3 hrs to fix

          Function analyze has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def analyze(geojson, area_ha=None, lang='en', app='gfw', template=False):
                  """Recieve a geostore_id, language, and app argument and return a
                  json serialised dic object response.
                  """
                  logging.info(f'[Geodescriber]: app={app}, lang={lang}, template={template}, for geojson={geojson}')
          Severity: Minor
          Found in gfwanalysis/services/analysis/geodescriber.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

          File recent_tiles.py has 300 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """EE SENTINEL TILE URL SERVICE"""
          
          import asyncio
          import collections
          import functools as funct
          Severity: Minor
          Found in gfwanalysis/services/analysis/recent_tiles.py - About 3 hrs to fix

            Function create_title has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                def create_title(title_elements, land_sea):
                    tmp_config = {'items': {}, 'sentence': ""}
            
                    truth_dict = {
                        'country': None,
            Severity: Minor
            Found in gfwanalysis/services/analysis/geodescriber.py - About 2 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 gen_area_sentence has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def gen_area_sentence(area_ha, app, mountain_sentence, title_elements, stats):
                    tmp_config = {'items': {}, 'sentence': ""}
                    if title_elements:
                        try:
                            title_ele = ' in ' + title_elements[0]
            Severity: Minor
            Found in gfwanalysis/services/analysis/geodescriber.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_geo_by_hash has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_geo_by_hash(func):
                """Get geodata"""
            
                @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_mc_info has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_mc_info(func):
                @wraps(func)
                def wrapper(*args, **kwargs):
                    if request.method == 'POST':
                        data_array = request.get_json().get('timeseries')
            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 recent_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def recent_data(lat, lon, start, end, sort_by):
                    logging.info("[RECENT>DATA] function initiated")
                    try:
                        point = ee.Geometry.Point(float(lon), float(lat))
                        S2 = (
            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 recent_tiles has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def recent_tiles(col_data, bands, bmin, bmax, opacity):
                    """Takes collection data array and fetches tiles"""
                    logging.info(f"[RECENT>TILE] {col_data.get('source')}")
            
                    source = col_data["source"]
            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 recent_thumbs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def recent_thumbs(col_data, bands, bmin, bmax, opacity):
                    """Takes collection data array and fetches thumbs"""
                    source = col_data["source"]
                    logging.info(f"[RECENT>THUMB] {source}")
            
            
            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 get_by_geom has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def get_by_geom(geojson, area_ha, instrument, date_range, thumb_size, classify, band_viz, get_dem, get_stats,
            Severity: Major
            Found in gfwanalysis/routes/api/v1/composite_service_router.py - About 1 hr to fix

              Function get_by_hash has 11 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def get_by_hash(geojson, area_ha, instrument, date_range, thumb_size, classify, band_viz, get_dem, get_stats,
              Severity: Major
              Found in gfwanalysis/routes/api/v1/composite_service_router.py - About 1 hr to fix

                Function analyze has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def analyze(timeseries, window, bin_number, mc_number):
                        """This is the Monte Carlo Analysis Service
                        """
                        if not window:
                            window = 5
                Severity: Minor
                Found in gfwanalysis/services/analysis/mc_analysis_service.py - About 1 hr to fix

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

                      def gen_land_sea_sentence(stats):
                          tmp_config = {'items': {}, 'sentence': ""}
                  
                          land = stats.get('seaLandFreshwater').get('0', 0)
                          sea = stats.get('seaLandFreshwater').get('1', 0)
                  Severity: Minor
                  Found in gfwanalysis/services/analysis/geodescriber.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 composite has 10 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def composite(geojson, instrument, date_range, thumb_size, classify, band_viz, get_dem, get_stats, show_bounds,
                  Severity: Major
                  Found in gfwanalysis/routes/api/v1/composite_service_router.py - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language