fedspendingtransparency/usaspending-api

View on GitHub
usaspending_api/awards/v2/filters/filter_helpers.py

Summary

Maintainability
A
1 hr
Test Coverage
D
68%

File filter_helpers.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

import logging

from collections import namedtuple
from copy import deepcopy
from datetime import datetime
Severity: Minor
Found in usaspending_api/awards/v2/filters/filter_helpers.py - About 2 hrs to fix

    Function total_obligation_queryset has a Cognitive Complexity of 20 (exceeds 15 allowed). Consider refactoring.
    Open

    def total_obligation_queryset(amount_obj, model, filters, is_subaward=False):
        if can_use_total_obligation_enum(amount_obj):
            bins = []
            for v in amount_obj:
                lower_bound = v.get("lower_bound")
    Severity: Minor
    Found in usaspending_api/awards/v2/filters/filter_helpers.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

    There are no issues that match your filters.

    Category
    Status