fedspendingtransparency/usaspending-api

View on GitHub
usaspending_api/database_scripts/job_archive/backfill_per_transaction_exec_comp.py

Summary

Maintainability
F
4 days
Test Coverage
F
0%

File backfill_per_transaction_exec_comp.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

"""
Jira Ticket Number(s): DEV-3331

    As a user/developer/tester I want the FABS and FPDS executive compensation data to match Broker.

    Avoid deeply nested control flow statements.
    Wontfix

                        if broker_fabs_data:
                            updated_row_count = run_spending_update_query(
                                SPENDING_FABS_UPDATE_SQL, "FABS", broker_fabs_data
                            )
                            fabs_row_count += updated_row_count

      Avoid deeply nested control flow statements.
      Wontfix

                          if broker_fpds_data:
                              updated_row_count = run_spending_update_query(
                                  SPENDING_FPDS_UPDATE_SQL, "FPDS", broker_fpds_data
                              )
                              fpds_row_count += updated_row_count

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        class Timer:
            def __enter__(self):
                self.start = time.perf_counter()
                return self
        
        
        usaspending_api/database_scripts/job_archive/backfill_solicitation_date.py on lines 75..96

        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 199.

        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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        def run_spending_update_query(transaction_sql, transaction_type, broker_data):
            with spending_connection.cursor() as update_cursor:
                update_query = build_spending_update_query(transaction_sql, broker_data)
                with Timer() as t:
                    update_cursor.execute(update_query, [col for row in broker_data for col in row])
        usaspending_api/database_scripts/job_archive/backfill_solicitation_date.py on lines 120..133

        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 180.

        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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        def build_spending_update_query(query_base, update_data):
            values_string = ""
            for count, row in enumerate(update_data, 1):
                values_string += "("
                values_string += ",".join(["%s"] * len(row))
        usaspending_api/database_scripts/job_archive/backfill_solicitation_date.py on lines 99..107

        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 95.

        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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        def run_broker_select_query(transaction_sql, id_tuple):
            with broker_connection.cursor() as select_cursor:
                select_cursor.execute(transaction_sql, [id_tuple])
                return select_cursor.fetchall()
        usaspending_api/database_scripts/job_archive/backfill_solicitation_date.py on lines 114..117

        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 36.

        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