gfw-api/forest-change-analysis-elastic

View on GitHub
gladanalysis/services/query_constructor_service.py

Summary

Maintainability
A
3 hrs
Test Coverage
A
90%

Function format_dataset_query has 13 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def format_dataset_query(day_value, confidence, from_year, from_date, to_year, to_date, count_sql, from_sql,
Severity: Major
Found in gladanalysis/services/query_constructor_service.py - About 1 hr to fix

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

        def format_dataset_query(day_value, confidence, from_year, from_date, to_year, to_date, count_sql, from_sql,
                                 select_sql, order_sql, groupby_sql, iso=None, state=None, dist=None):
    
            if (int(from_year) == int(to_year)):
                where_template = 'WHERE ((year = {y1} and {day} >= {d1} and {day} <= {d2}))' + confidence
    Severity: Minor
    Found in gladanalysis/services/query_constructor_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 format_terrai_sql has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def format_terrai_sql(from_year, from_date, to_year, to_date, iso=None, state=None, dist=None, agg_values=False):
    Severity: Major
    Found in gladanalysis/services/query_constructor_service.py - About 50 mins to fix

      There are no issues that match your filters.

      Category
      Status