Showing 86 of 230 total issues
Function can_register
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def can_register(self, user: User, *, fail_if_not_standalone):
# Registering for an event with no time places should never be allowed - no matter the `event_type`
if not self.timeplaces.exists():
return False
- 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 has_any_permissions_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def has_any_permissions_for(user: User, model__or__app_and_model: Type[models.Model] | str):
"""
:param user: the user to check permissions for
:param model__or__app_and_model: either a model type, a string with the name of a uniquely named model,
or a string of the format "{app_label}.{model_name}"
- 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 clean
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def clean(self):
"""
Cleans and validates the given form.
:return: A dictionary of clean data
- 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 mazeMapSearch
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
mazeMapSearch: function () {
// Data attributes set by the widget
const campusID = this.data("campus-id");
const maxResults = this.data("max-results");
const urlField = this.data("url-field");
- 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
Consider simplifying this complex logical expression. Open
if ((reservation.startTime <= start && reservation.endTime > start) ||
(reservation.startTime > start && reservation.endTime < end) ||
(reservation.startTime < end && reservation.endTime > end)) {
reservationsInPeriod.push(reservation);
}
Function execute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def execute(self, *args, **options):
relative_tests_dir = settings.TESTS_DIR.relative_to(settings.REPO_DIR)
if not args:
args = (str(relative_tests_dir),)
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 save
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
if self.pk is None: # Creation of new object
self._connect_to_user()
else:
old = Printer3DCourse.objects.get(pk=self.pk)
- 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 execute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def execute(self, *args, **options):
ignore_patterns = options['ignore_patterns']
if not ignore_patterns:
# Ignore all top-level directories that are not the `BASE_DIR`
for path in settings.REPO_DIR.iterdir():
- 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 compareElements
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function compareElements(a, b) {
/**
* Compares `a` and `b`, either using `localCompare()` for strings, or element by element for arrays.
*/
if (typeof a === "string")
- 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 clean
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def clean(self):
cleaned_data = super().clean()
machine_type = cleaned_data.get('machine_type')
stream_name = cleaned_data.get('stream_name')
- 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 getReservationsInPeriod
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function getReservationsInPeriod(start, end) {
/**
* Returns all reservations that are at least partially within the given time period.
*/
let reservationsInPeriod = [];
- 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 post
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def post(self, request, *args, **kwargs):
reservation = self.get_object()
if not can_mark_reservation_finished(reservation):
now = timezone.now()
if reservation.start_time > now:
- 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 getFirstReservableTimeSlot
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function getFirstReservableTimeSlot(date) {
/**
* Finds the first reservable time slot on or after the supplied date
*/
let found = false;
- 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 should_bleach
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def should_bleach(self):
# If at least one of the subwidgets use the edit source config, do not bleach
if isinstance(self.widget, forms.MultiWidget):
for subwidget in self.widget.widgets:
if isinstance(subwidget, CKEditorWidget) and subwidget.config_name == settings.CKEDITOR_EDIT_SOURCE_CONFIG_NAME:
- 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 permission_required_else_denied
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def permission_required_else_denied(perm, login_url=None):
"""
Decorator for views that checks whether a user has a particular permission.
When the user does not have the permission, they will be redirected to the login page if not logged in,
and a ``PermissionDenied`` will be raised if already logged in.
- 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 too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return _("The reservation exceeds your quota")
Avoid too many return
statements within this function. Open
return _("It is not possible to reserve the machine during these hours. Check the rules for when the machine is reservable")
Avoid too many return
statements within this function. Open
return False