Showing 164 of 226 total issues
Function log_job_message
has 10 arguments (exceeds 6 allowed). Consider refactoring. Open
def log_job_message(
Function receive_messages
has 10 arguments (exceeds 6 allowed). Consider refactoring. Open
def receive_messages(
Function __init__
has 10 arguments (exceeds 6 allowed). Consider refactoring. Open
def __init__(
Function update_transaction_assistance
has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring. Open
def update_transaction_assistance(db_cursor, fiscal_year=None, page=1, limit=500000):
query = "SELECT * FROM published_fabs"
arguments = []
- Read upRead up
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 build_query_filters
has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring. Open
def build_query_filters(account_type, filters, account_level):
if account_level not in ("treasury_account", "federal_account"):
raise InvalidParameterException(
'Invalid Parameter: account_level must be either "federal_account" or "treasury_account"'
)
- Read upRead up
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 receive_messages
has 9 arguments (exceeds 6 allowed). Consider refactoring. Open
def receive_messages(
Function _download_and_copy
has 9 arguments (exceeds 6 allowed). Consider refactoring. Open
def _download_and_copy(
Function parse_source
has 9 arguments (exceeds 6 allowed). Consider refactoring. Open
def parse_source(
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()
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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()
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function update_transaction_contract
has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring. Open
def update_transaction_contract(db_cursor, fiscal_year=None, page=1, limit=500000):
# logger.info("Getting IDs for what's currently in the DB...")
# current_ids = TransactionFPDS.objects
#
- Read upRead up
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
Avoid deeply nested control flow statements. Open
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
Function generate_elasticsearch_query
has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring. Open
def generate_elasticsearch_query(cls, filter_values: List[str], query_type: _QueryType, **options) -> ES_Q:
nested_path = options.get("nested_path", "")
def_codes_query = []
def_code_field = f"{nested_path}{'.' if nested_path else ''}disaster_emergency_fund_code{'s' if query_type != _QueryType.ACCOUNTS else ''}"
- Read upRead up
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 django_db_setup
has 8 arguments (exceeds 6 allowed). Consider refactoring. Open
def django_db_setup(
Function get_deleted_fpds_data_from_s3
has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring. Open
def get_deleted_fpds_data_from_s3(date):
ids_to_delete = []
regex_str = ".*_delete_records_(IDV|award).*"
if not date:
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if "toptier_name" in v:
funding_subtier |= Q(funding_subtier_agency_name=name) & Q(
funding_toptier_agency_name=v["toptier_name"]
)
else:
Avoid deeply nested control flow statements. Open
if "toptier_name" in v:
awarding_subtier |= Q(awarding_subtier_agency_name=name) & Q(
awarding_toptier_agency_name=v["toptier_name"]
)
else:
Function __init__
has 7 arguments (exceeds 6 allowed). Consider refactoring. Open
def __init__(
Function write_csv_file
has 7 arguments (exceeds 6 allowed). Consider refactoring. Open
def write_csv_file(
Function delete_transactions
has 7 arguments (exceeds 6 allowed). Consider refactoring. Open
def delete_transactions(