gfw-api/gfw-analysis-gee

View on GitHub
gfwanalysis/routes/api/v1/soil_carbon_router.py

Summary

Maintainability
C
1 day
Test Coverage
F
50%

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

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    @soil_carbon_endpoints_v1.route('/use/<name>/<id>', strict_slashes=False, methods=['GET'])
    @get_geo_by_use
    def get_by_use(name, id, geojson, area_ha):
        """Use Endpoint"""
        logging.info('[ROUTER]: Getting  soil carbon by use')
    Severity: Major
    Found in gfwanalysis/routes/api/v1/soil_carbon_router.py and 2 other locations - About 1 hr to fix
    gfwanalysis/routes/api/v1/forma250_router.py on lines 71..76
    gfwanalysis/routes/api/v1/soil_carbon_router.py on lines 78..83

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    @soil_carbon_endpoints_v1.route('/admin/<iso>/<id1>', strict_slashes=False, methods=['GET'])
    @get_geo_by_subnational
    def get_by_subnational(iso, id1, geojson, area_ha):
        """Subnational Endpoint"""
        logging.info('[ROUTER]: Getting  soil carbon loss by admin1')
    Severity: Major
    Found in gfwanalysis/routes/api/v1/soil_carbon_router.py and 2 other locations - About 1 hr to fix
    gfwanalysis/routes/api/v1/forma250_router.py on lines 71..76
    gfwanalysis/routes/api/v1/soil_carbon_router.py on lines 54..59

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    @soil_carbon_endpoints_v1.route('/', strict_slashes=False, methods=['GET', 'POST'])
    @validate_geostore
    @get_geo_by_hash
    def get_by_geostore(geojson, area_ha):
        """By Geostore Endpoint"""
    Severity: Major
    Found in gfwanalysis/routes/api/v1/soil_carbon_router.py and 3 other locations - About 1 hr to fix
    gfwanalysis/routes/api/v1/forma250_router.py on lines 62..68
    gfwanalysis/routes/api/v1/histogram_router.py on lines 48..54
    gfwanalysis/routes/api/v1/landcover_router.py on lines 42..48

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    @soil_carbon_endpoints_v1.route('/admin/<iso>', strict_slashes=False, methods=['GET'])
    @get_geo_by_national
    def get_by_national(iso, geojson, area_ha):
        """National Endpoint"""
        logging.info('[ROUTER]: Getting  soil carbon loss by iso')
    Severity: Major
    Found in gfwanalysis/routes/api/v1/soil_carbon_router.py and 2 other locations - About 1 hr to fix
    gfwanalysis/routes/api/v1/forma250_router.py on lines 79..84
    gfwanalysis/routes/api/v1/soil_carbon_router.py on lines 62..67

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 46.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    @soil_carbon_endpoints_v1.route('/wdpa/<id>', strict_slashes=False, methods=['GET'])
    @get_geo_by_wdpa
    def get_by_wdpa(id, geojson, area_ha):
        """Wdpa Endpoint"""
        logging.info('[ROUTER]: Getting  soil carbon by wdpa')
    Severity: Major
    Found in gfwanalysis/routes/api/v1/soil_carbon_router.py and 2 other locations - About 1 hr to fix
    gfwanalysis/routes/api/v1/forma250_router.py on lines 79..84
    gfwanalysis/routes/api/v1/soil_carbon_router.py on lines 70..75

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 46.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    There are no issues that match your filters.

    Category
    Status