Showing 52 of 72 total issues
File models.py
has 912 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
import re
import time
from zipfile import ZipFile
- Create a ticketCreate a ticket
Function handle
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. 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
File forms.py
has 394 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django import forms
from django.core.cache import cache
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.db.models import Max, Min
- Create a ticketCreate a ticket
File views.py
has 380 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
import requests
from django.contrib import messages
from django.contrib.auth.mixins import PermissionRequiredMixin
- Create a ticketCreate a ticket
File import_util.py
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
Import utility classes for creating :mod:`ppa.archives` records from
external sources.
- Create a ticketCreate a ticket
Function get_queryset
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def get_queryset(self, **kwargs):
form_opts = self.request.GET.copy()
# if relevance sort is requested but there is no keyword search
# term present, clear it out and fallback to default sort
if not self.form_class().has_keyword_query(form_opts):
- 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
DigitizedWork
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class DigitizedWork(ModelIndexable, TrackChangesModel):
"""
Record to manage digitized works included in PPA and store their basic
metadata.
"""
- Create a ticketCreate a ticket
File admin.py
has 296 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.urls import re_path
from django.contrib import admin
from django.db.models import Count
from django.http import HttpResponseRedirect
from django.urls import reverse
- Create a ticketCreate a ticket
File models.py
has 294 lines of code (exceeds 250 allowed). Consider refactoring. Open
import bleach
from django.db import models
from django.template.defaultfilters import striptags, truncatechars_html
from django.utils.text import slugify
from wagtail.admin.panels import FieldPanel
- Create a ticketCreate a ticket
Function metadata_from_marc
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def metadata_from_marc(self, marc_record, populate=True):
"""Get metadata from MARC record and return a dictionary
of the data. When populate is True, calls `populate_fields`
to set values."""
- 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 19 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **kwargs):
self.verbosity = kwargs.get("verbosity", self.verbosity)
# find all excerpted, non-suppressed hathi volumes
hathi_vols = DigitizedWork.objects.filter(
- 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 18 (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)
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 save
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def save(self, *args, **kwargs):
# if status has changed so that object is now suppressed,
# do some cleanup
if self.has_changed("status") and self.status == DigitizedWork.SUPPRESSED:
# remove indexed page content from Solr using index 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 route
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def route(self, request, path_components):
"""Customize editorial page routing to serve editorial pages
by year/month/slug."""
# NOTE: might be able to use RoutablePageMixin for this,
- 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 14 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **kwargs):
self.verbosity = kwargs.get("verbosity", self.v_normal)
self.options = kwargs
# use ids specified via command line when present
- 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 set_choices_from_facets
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def set_choices_from_facets(self, facets):
"""Set choices on field from a dictionary of facets"""
# update collections multiselect based on facets
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **kwargs):
data = self.load_csv(kwargs["csv"])
self.verbosity = kwargs.get("verbosity", self.v_normal)
self.script_user = User.objects.get(username=settings.SCRIPT_USERNAME)
- 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 hathi_page_index_data
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def hathi_page_index_data(cls, digwork):
"""Get page content for the specified digitized work from Hathi
pairtree and return data to be indexed in solr."""
# load mets record to pull metadata about the images
- 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 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"