Showing 86 of 230 total issues
Function dirty
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.dirty = function(options) {
if (typeof options === "string" && /^(isDirty|isClean|refreshEvents|resetForm|setAsClean|setAsDirty|showDirtyFields)$/i.test(options)) {
//Check if we have an instance of dirty for this form
// TODO: check if this is DOM or jQuery object
Function getFutureReservations
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getFutureReservations(machineID, forceNewTime) {
/**
* Retrieves future reservations and all reservation rules from the server.
*/
let jsonUrl = `${LANG_PREFIX}/api/reservation/machines/${machineID}/data/`;
Function getSelectionTimes
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
ReservationCalendar.prototype.getSelectionTimes = function () {
/**
* Calculates the start and end time of the selection, so that they fit within the given rules and restrictions
* given for reservations.
*/
Function addVoterPost
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addVoterPost($element, pk, forced) {
$.ajaxSetup({
beforeSend: function (xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", csrfToken);
},
Function togglePost
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function togglePost($element, postURL, model, toggle) {
$.ajaxSetup({
beforeSend: function (xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", csrfToken);
},
Function get_users_matching_search
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_users_matching_search(cls, search_string: str) -> tuple[list[User], list[User]]:
query = Q()
for search_fragment in search_string.split():
user_search_field_subquery = Q()
for field in cls.user_search_fields:
- 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 delete
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def delete(self, request, *args, **kwargs):
reservation = self.get_object()
if not can_delete_reservation(reservation, self.request.user):
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 get_best_quota
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_best_quota(cls, reservation: 'Reservation') -> Optional['Quota']:
"""
Selects the best quota for the given reservation,
by preferring non-diminishing quotas that do not ignore the rules.
- 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 togglePost
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function togglePost($element, postURL, model, toggle) {
$.ajaxSetup({
beforeSend: function (xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", csrfToken);
},
- 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 drawReservation
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
ReservationCalendar.prototype.drawReservation = function (startDate, endDate, classes, callback, linkToDisplay = null) {
/**
* Draws a reservation in the calendar. The `classes` parameter is the CSS classes given to each block displayed in
* the calendar. The `callback` parameter is a function that is called with the given HTML element and date as
* arguments each time this function creates a new HTML element for the reservation.
- 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 get_context_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
queryset: EventQuerySet[Event] = self.get_queryset()
future = queryset.future().prefetch_related(
- 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 registerProfilePost
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function registerProfilePost($element) {
$.ajaxSetup({
beforeSend: function (xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", csrfToken);
},
- 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 create_multi_lingual_admin_formfield
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_multi_lingual_admin_formfield(db_field, request, *, enable_changing_rich_text_source=False, **kwargs):
"""
Django admin does not render the MultiLingual fields correctly. This function creates a working widget for
rendering the MultiLingual fields.
"""
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
def post(self, request):
try:
rating = int(request.POST.get('rating'))
skill_id = int(request.POST.get('skill'))
except ValueError:
- 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 filter
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function filter() {
let numRegistrationsFiltered = 0;
for (const element of state.elements) {
if (state.onlyShowSelectedUsers) {
element.display = element.$element.hasClass(SELECTED_ROW_CLASS);
- 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 get_context_data
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_context_data(self, **kwargs):
"""
Creates the context data required for the make reservation template.
If reservation is given as a keyword argument, the view is made for that reservation.
- 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 get_context_data
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_context_data(self, **kwargs):
"""
Creates dict with skill titles as keys and
the highest corresponding skill level as its pair value (quick fix) to show on website.
"""
- 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 getMaxDateReservation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getMaxDateReservation(date) {
/**
* Finds the latest date at which a reservation which starts at the given date can end and still be valid.
*/
let maxDate = new Date(date.valueOf());
- 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 formfield_for_dbfield
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def formfield_for_dbfield(self, db_field, request, **kwargs):
multi_lingual_admin_formfield = create_multi_lingual_admin_formfield(
db_field, request, **kwargs,
enable_changing_rich_text_source=self.enable_changing_rich_text_source,
)
- 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 rename_files_of_created_instances
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def rename_files_of_created_instances(cls, instance: models.Model, created, raw, update_fields: Collection | None, **kwargs):
"""
This signal receiver renames the files belonging to ``FileField``s (or subclasses) of model instances when they're created,
if the filename matches the token regex used by ``get_pk_prefixed_filename_func()``.
"""
- 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"