ppa/archive/management/commands/index_pages.py
Function handle
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
Open
def handle(self, *args, **kwargs):
self.verbosity = kwargs.get("verbosity", self.v_normal)
if self.verbosity >= self.v_normal:
self.stdout.write(
"Indexing with %d processes" % max(2, kwargs["processes"])
- Read upRead up
- Create a ticketCreate a ticket
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
Open
if digwork.page_count > solr_page_count:
diff_msg = f"missing {digwork.page_count - solr_page_count}"
else:
diff_msg = f"extra {solr_page_count - digwork.page_count}"
- Create a ticketCreate a ticket
Function process_index_queue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def process_index_queue(index_data_q, total_to_index, work_q):
"""Function to send index data to Solr. Takes a
queue to poll for index data, a total of the items
to be indexed (for use with progess bar), and a work queue
as a way of checking that all indexing is complete."""
- Read upRead up
- Create a ticketCreate a ticket
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"