MAKENTNU/web

View on GitHub

Showing 230 of 230 total issues

Cyclomatic complexity is too high in method get_best_quota. (11)
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.
 
 
Severity: Minor
Found in src/make_queue/models/reservation.py by radon

Cyclomatic complexity is too high in function _get_user_details_from_user_field. (11)
Open

def _get_user_details_from_user_field(field_name: str, field_value: str, use_cached: bool) -> dict[str, str]:
user_details = {}
if use_cached:
user = User.objects.filter(**{field_name: field_value}).first()
if user:
Severity: Minor
Found in src/dataporten/ldap_utils.py by radon

Cyclomatic complexity is too high in method get_context_data. (9)
Open

def get_context_data(self, **kwargs):
user = self.request.user
profile, _created = Profile.objects.get_or_create(user=user)
 
completed_3d_printer = hasattr(user, 'printer_3d_course')
Severity: Minor
Found in src/checkin/views.py by radon

Cyclomatic complexity is too high in function create_multi_lingual_admin_formfield. (9)
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.
"""
Severity: Minor
Found in src/web/multilingual/admin.py by radon

Cyclomatic complexity is too high in class ProfileDetailView. (9)
Open

class ProfileDetailView(TemplateView):
template_name = 'checkin/profile_detail.html'
 
def post(self, request):
try:
Severity: Minor
Found in src/checkin/views.py by radon

Function setUpSelection has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ReservationCalendar.prototype.setUpSelection = function () {
/**
* Creates all object fields required for selection and all event handlers for clicks, touches and drags.
* The selectionStart field holds the first tap and the selectionEnd field holds the hovered value.
*/
Severity: Major
Found in src/make_queue/static/make_queue/js/calendar.js - About 2 hrs to fix

    Cyclomatic complexity is too high in method valid_time. (8)
    Open

    def valid_time(cls, start_time: datetime, end_time: datetime, machine_type: MachineType) -> bool:
    """
    Checks if a reservation in the supplied period is allowed by the rules for the machine type.
     
    :param start_time: The start time of the reservation
    Severity: Minor
    Found in src/make_queue/models/reservation.py by radon

    Cyclomatic complexity is too high in method can_register. (8)
    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
     
     
    Severity: Minor
    Found in src/news/models.py by radon

    Cyclomatic complexity is too high in method rename_files_of_created_instances. (8)
    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()``.
    """
    Severity: Minor
    Found in src/util/storage.py by radon

    Cyclomatic complexity is too high in method compile_fieldsets. (8)
    Open

    def compile_fieldsets(self, custom_fieldsets: Iterable[dict], form: Form):
    fieldsets = []
    for fieldset in copy.deepcopy(custom_fieldsets):
    if not fieldset:
    continue
    Severity: Minor
    Found in src/util/view_utils.py by radon

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    systemAccesses: $row.data("system-accesses").slice(1, -1).replace(/'/g, "").match(/[^()]+/g)
    .filter(access => access !== ", ")
    .map(access => access.split(", "))
    .map(access => ({
    name: access[0],
    Severity: Major
    Found in src/internal/static/internal/js/member_list.js and 1 other location - About 2 hrs to fix
    src/internal/static/internal/js/member_list.js on lines 357..363

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    status: $row.data("status").slice(1, -1).replace(/'/g, "").match(/[^()]+/g)
    .filter(status => status !== ", ")
    .map(status => status.split(", "))
    .map(status => ({
    name: status[0],
    Severity: Major
    Found in src/internal/static/internal/js/member_list.js and 1 other location - About 2 hrs to fix
    src/internal/static/internal/js/member_list.js on lines 365..373

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    def get_all_children(self):
    """Return a queryset of all groups that inherit from this group."""
    children = self.children.all()
     
    for child in self.children.all():
    Severity: Major
    Found in src/groups/models.py and 1 other location - About 2 hrs to fix
    src/groups/models.py on lines 69..76

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    def get_all_parents(self):
    """Return a queryset of all groups that this group inherits from."""
    parents = self.parents.all()
     
    for parent in self.parents.all():
    Severity: Major
    Found in src/groups/models.py and 1 other location - About 2 hrs to fix
    src/groups/models.py on lines 60..67

    Cyclomatic complexity is too high in class QuotaForm. (7)
    Open

    class QuotaForm(forms.ModelForm):
    user = UserModelChoiceField(
    queryset=User.objects.order_by(Concat('first_name', 'last_name'), 'username'),
    widget=SemanticSearchableChoiceInput(prompt_text=_("Select user")),
    # `capfirst()` to avoid duplicate translation differing only in case
    Severity: Minor
    Found in src/make_queue/forms/quota.py by radon

    Cyclomatic complexity is too high in class DefaultAdminWidgetsMixin. (7)
    Open

    class DefaultAdminWidgetsMixin:
    """Overrides the Django admin change forms' widgets with the default ones used in this project."""
    formfield_overrides = {
    models.ImageField: {'widget': AdminImageWidget},
    CardNumberField: {'widget': CardNumberInput},
    Severity: Minor
    Found in src/util/admin_utils.py by radon

    Cyclomatic complexity is too high in method get_context_data. (7)
    Open

    def get_context_data(self, **kwargs):
    context = super().get_context_data(**kwargs)
    queryset: EventQuerySet[Event] = self.get_queryset()
     
    future = queryset.future().prefetch_related(
    Severity: Minor
    Found in src/news/views/event.py by radon

    Function post has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def post(self, request):
    suggestion = request.POST.get('suggested-skill')
    suggestion_english = request.POST.get('suggested-skill-english')
    profile = request.user.profile
    image = request.FILES.get('image')
    Severity: Minor
    Found in src/checkin/views.py - About 1 hr to fix

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

    question_adminpatterns = [
    path("", views.AdminQuestionListView.as_view(), name='admin_question_list'),
    path("add/", views.QuestionCreateView.as_view(), name='question_create'),
    path("<int:pk>/", include(specific_question_adminpatterns)),
    Severity: Major
    Found in src/faq/urls.py and 4 other locations - About 1 hr to fix
    src/announcements/urls.py on lines 16..19
    src/faq/urls.py on lines 26..29
    src/makerspace/urls.py on lines 24..27
    src/news/urls.py on lines 52..55

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

    adminpatterns = [
    path("", views.AdminAnnouncementListView.as_view(), name='admin_announcement_list'),
    path("add/", views.AnnouncementCreateView.as_view(), name='announcement_create'),
    path("<int:pk>/", include(specific_announcement_adminpatterns)),
    Severity: Major
    Found in src/announcements/urls.py and 4 other locations - About 1 hr to fix
    src/faq/urls.py on lines 16..19
    src/faq/urls.py on lines 26..29
    src/makerspace/urls.py on lines 24..27
    src/news/urls.py on lines 52..55
    Severity
    Category
    Status
    Source
    Language