MAKENTNU/web

View on GitHub

Showing 230 of 230 total issues

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

specific_machine_urlpatterns = [
path("", machine_views.MachineDetailView.as_view(), name='machine_detail'),
path("reservations/add/", login_required(reservation_views.ReservationCreateView.as_view()), name='reservation_create'),
Severity: Major
Found in src/make_queue/urls.py and 1 other location - About 1 hr to fix
src/news/urls.py on lines 31..33

Function clean has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def clean(self):
cleaned_data = super().clean()
start_time = cleaned_data.get('start_time')
end_time = cleaned_data.get('end_time')
days_changed = cleaned_data.get('days_changed')
Severity: Minor
Found in src/make_queue/forms/reservation_rule.py - About 1 hr to fix

Function _get_user_details_from_user_field has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
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 - About 1 hr to fix

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
Severity: Minor
Found in src/web/static/lib/jquery/jquery.dirty.js - About 1 hr to fix

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

    class AdminCommitteeListView(PermissionRequiredMixin, ListView):
    permission_required = ('groups.change_committee',)
    model = Committee
    queryset = Committee.objects.select_related('group')
    template_name = 'groups/admin_committee_list.html'
    Severity: Major
    Found in src/groups/views.py and 1 other location - About 1 hr to fix
    src/announcements/views.py on lines 13..18

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

    class AdminAnnouncementListView(PermissionRequiredMixin, ListView):
    permission_required = ('announcements.change_announcement',)
    model = Announcement
    queryset = Announcement.objects.order_by('-display_from')
    template_name = 'announcements/admin_announcement_list.html'
    Severity: Major
    Found in src/announcements/views.py and 1 other location - About 1 hr to fix
    src/groups/views.py on lines 37..42

    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/`;
    Severity: Minor
    Found in src/make_queue/static/make_queue/js/reservation_form.js - About 1 hr to fix

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

      Date.prototype.nextWeek = function () {
      /**
      * Returns the date one week ahead in time
      */
      const date = new Date(this);
      Severity: Major
      Found in src/web/static/web/js/date_utils.js and 1 other location - About 1 hr to fix
      src/web/static/web/js/date_utils.js on lines 77..84

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

      Date.prototype.previousWeek = function () {
      /**
      * Returns the date one week behind in time
      */
      const date = new Date(this);
      Severity: Major
      Found in src/web/static/web/js/date_utils.js and 1 other location - About 1 hr to fix
      src/web/static/web/js/date_utils.js on lines 68..75

      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);
      },
      Severity: Minor
      Found in src/checkin/static/checkin/js/suggest_skill.js - About 1 hr to fix

        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);
        },
        Severity: Minor
        Found in src/news/static/news/js/event/admin_event_detail.js - About 1 hr to fix

          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.
          */
          Severity: Minor
          Found in src/make_queue/static/make_queue/js/calendar.js - About 1 hr to fix

            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.
             
             
            Severity: Minor
            Found in src/make_queue/models/reservation.py - About 1 hr to fix

            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:
            Severity: Minor
            Found in src/make_queue/api/views.py - About 1 hr to fix

            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);
            },
            Severity: Minor
            Found in src/news/static/news/js/event/admin_event_detail.js - About 1 hr to fix

            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:
            Severity: Minor
            Found in src/news/views/event.py - About 1 hr to fix

            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.
            Severity: Minor
            Found in src/make_queue/static/make_queue/js/calendar.js - About 1 hr to fix

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

            $memberCommitteesElement.append(member.data.committees.map(
            committee => $(
            `<div class="ui ${committee.color} label">${committee.name}</div>`,
            ),
            ));
            Severity: Major
            Found in src/internal/static/internal/js/member_list.js and 1 other location - About 1 hr to fix
            src/internal/static/internal/js/member_list.js on lines 136..140

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

            $memberStatusElement.append(member.data.status.map(
            status => $(
            `<div class="ui ${status.color} label">${status.name}</div>`,
            ),
            ));
            Severity: Major
            Found in src/internal/static/internal/js/member_list.js and 1 other location - About 1 hr to fix
            src/internal/static/internal/js/member_list.js on lines 170..174

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

            specific_reservation_apipatterns = [
            path("finish/", api_views.APIReservationMarkFinishedView.as_view(), name='api_reservation_mark_finished'),
            path("delete/", api_views.APIReservationDeleteView.as_view(), name='api_reservation_delete'),
            Severity: Major
            Found in src/make_queue/urls.py and 16 other locations - About 1 hr to fix
            src/announcements/urls.py on lines 11..13
            src/faq/urls.py on lines 12..14
            src/faq/urls.py on lines 22..24
            src/groups/urls.py on lines 6..8
            src/groups/urls.py on lines 13..15
            src/make_queue/urls.py on lines 12..14
            src/make_queue/urls.py on lines 47..49
            src/make_queue/urls.py on lines 65..67
            src/make_queue/urls.py on lines 78..80
            src/make_queue/urls.py on lines 87..89
            src/make_queue/urls.py on lines 99..101
            src/makerspace/urls.py on lines 7..9
            src/makerspace/urls.py on lines 20..22
            src/news/urls.py on lines 9..11
            src/news/urls.py on lines 48..50
            src/news/urls.py on lines 93..95
            Severity
            Category
            Status
            Source
            Language