Showing 53 of 73 total issues
Function import_digitizedwork
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def import_digitizedwork(
self, gale_id, log_msg_src="", user=None, collections=None, **kwargs
):
"""Import a single work into the database.
Retrieves bibliographic data from Gale API."""
- 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
Function handle
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **kwargs):
self.verbosity = kwargs.get("verbosity", self.verbosity)
source_ids = kwargs.get("source_ids", [])
# page count does not affect solr indexing, so disconnect signal handler
IndexableSignalHandler.disconnect()
- 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
Function handle
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **kwargs):
# disconnect signal handler for on-demand indexing, for efficiency
# (index in bulk after an update, not one at a time)
self.verbosity = kwargs.get("verbosity", self.v_normal)
- 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
Function get_queryset
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_queryset(self):
# get default queryset and filter by source id
source_qs = (
super().get_queryset().filter(source_id=self.kwargs.get("source_id"))
)
- 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
Function checkScroll
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
checkScroll() {
let scrolled = $('.pusher').scrollTop()
if (scrolled - this.scroll > 25 && scrolled > this.scroll && scrolled > 90) { // scroll down
if (!this.pitbar.hasClass('hidden')) {
if (this.mobileNav && !this.mobileNav.hasClass('visible')) {
- 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
Function add_from_hathi
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_from_hathi(htid, bib_api=None, update=False, log_msg_src=None, user=None):
"""Add or update a HathiTrust work in the database.
Retrieves bibliographic data from Hathi api, retrieves or creates
a :class:`DigitizedWork` record, and populates the metadata if
this is a new record, if the Hathi metadata has changed, or
- 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
Function excerpt
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def excerpt(self, row):
"""Process a row of the spreadsheet, and either convert an existing full
work to an excerpt or create a new excerpt."""
# volume id in spreadsheet is our source id
- 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
Function change_view
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def change_view(self, request, object_id, form_url="", extra_context=None):
# customize behavior when copying a record and saving as new
if request.POST.get("_saveasnew"):
# if source is unset, this means we are loading the "save as new"
# form for a hathitrust record
- 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
Function handle
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **kwargs):
if not (kwargs["ids"] or kwargs["csv"]):
raise CommandError("A list of IDs or CSV file for is required for import")
# error handling in case user forgets to specify csv file correctly
- 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
Function submitForm
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function submitForm(state) {
if (!validate()) return // don't submit an invalid form
state = state.filter(field => field.value != '') // filter out empty fields
if (state.filter(field => field.name == 'collections').length == 0) { // if the user manually turned off all collections...
state.push({ name: "collections", value: "" }) // add a blank value to indicate that specific case
- Create a ticketCreate a ticket
Function import_digitizedwork
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def import_digitizedwork(self, htid):
"""Import a single work into the database.
Retrieves bibliographic data from Hathi api. If the record already
exists in the database, it is only updated if the hathi record
has changed or if an update is requested by the user.
- 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
Function page_contents
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def page_contents(self):
"""generator of text strings between this page beginning tag and
the next one"""
# strictly speaking we are returning lxml "smart strings"
- 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
Function get_version_labels
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_version_labels(htids, wait_time=1):
"""
Extracts the HathiTrust "version label" for each record within htids.
Returns a list of the extracted htid-timestamp pairs.
"""
- 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
Function create_option
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_option(
- Create a ticketCreate a ticket
Function create_option
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_option(
- Create a ticketCreate a ticket
Function keydownHandler
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
keydownHandler(ev) {
// if down arrow, target the next link element
if (ev.keyCode === 40) {
// using raw JS to determine we're on a link element
if (ev.target.nodeName === 'A') {
- 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
Function get_metadata
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_metadata(self, metadata_format):
"""Get metadata for this item in the specified format.
Currently only supports marc."""
if metadata_format == "marc":
# get metadata from hathi bib api and serialize
- 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
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 _make_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _make_request(
- Create a ticketCreate a ticket
Function import_digitizedwork
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def import_digitizedwork(
- Create a ticketCreate a ticket