MAKENTNU/web

View on GitHub

Showing 86 of 230 total issues

Function validate has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

def validate(self):
# User needs to be able to print, for it to be able to reserve the printers
if not self.machine.can_user_use(self.user):
return False
 
 
Severity: Minor
Found in src/make_queue/models/reservation.py - About 4 hrs to fix

Function showDetailedMemberInformation has 96 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function showDetailedMemberInformation(member) {
/**
* Displays the selected members' information in a popup modal.
*/
const textAttributeNamesToValues = {
Severity: Major
Found in src/internal/static/internal/js/member_list.js - About 3 hrs to fix

    Function modifyToFirstValid has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    function modifyToFirstValid(rules, startTime, endTime, modificationDirection) {
    /**
    * Modifies either startTime (modificationDirection 0) or endTime (modificationDirection 1) until the period
    * [startTime, endTime] is valid for the given set of rules.
    */
    Severity: Minor
    Found in src/make_queue/static/make_queue/js/reservation_rule_utils.js - About 3 hrs to fix

    Function setup has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function setup() {
    /**
    * Setup of the global state and actions.
    */
    $filterStatusInput.change(() => {
    Severity: Major
    Found in src/internal/static/internal/js/member_list.js - About 3 hrs to fix

      Function compile_fieldsets has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      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 - About 2 hrs to fix

      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

        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

        Function modifyToFirstValid has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function modifyToFirstValid(rules, startTime, endTime, modificationDirection) {
        /**
        * Modifies either startTime (modificationDirection 0) or endTime (modificationDirection 1) until the period
        * [startTime, endTime] is valid for the given set of rules.
        */
        Severity: Minor
        Found in src/make_queue/static/make_queue/js/reservation_rule_utils.js - About 1 hr to fix

          Function mazeMapSearch has 45 lines of code (exceeds 25 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");
          Severity: Minor
          Found in src/web/static/web/js/forms/widgets/mazemap_search.js - About 1 hr to fix

            Function updateDisplay has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function updateDisplay() {
            const startIndex = state.page * state.elementsPerPage;
            const endIndex = (state.page + 1) * state.elementsPerPage;
             
            let numRegistrationsFiltered = 0;
            Severity: Minor
            Found in src/make_queue/static/make_queue/js/printer_3d_course_list.js - About 1 hr to fix

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

              def clean(self, data: InMemoryUploadedFile | bool | None, initial: ImageFieldFile = None):
              cleaned_data: ImageFieldFile | InMemoryUploadedFile | TemporaryUploadedFile | bool | None = super().clean(data, initial=initial)
              if data and cleaned_data:
              try:
              if initial and file_contents_equal(cleaned_data, initial):
              Severity: Minor
              Found in src/util/formfields.py - About 1 hr to fix

              Function updateDisplay has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              function updateDisplay() {
              const startIndex = state.page * state.elementsPerPage;
              const endIndex = (state.page + 1) * state.elementsPerPage;
               
              let numRegistrationsFiltered = 0;
              Severity: Minor
              Found in src/make_queue/static/make_queue/js/printer_3d_course_list.js - About 1 hr to fix

              Function setUpState has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function setUpState() {
              $("tbody tr").each(function () {
              state.elements.push({
              pk: $(this).data("pk"),
              name: $(this).data("name").toLowerCase(),
              Severity: Minor
              Found in src/make_queue/static/make_queue/js/printer_3d_course_list.js - About 1 hr to fix

                Function updateSelection has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                ReservationCalendar.prototype.updateSelection = function () {
                /**
                * Updates the shown selection.
                */
                const calendar = this;
                Severity: Minor
                Found in src/make_queue/static/make_queue/js/calendar.js - About 1 hr to fix

                  Function registerProfilePost has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function registerProfilePost($element) {
                  $.ajaxSetup({
                  beforeSend: function (xhr, settings) {
                  xhr.setRequestHeader("X-CSRFToken", csrfToken);
                  },
                  Severity: Minor
                  Found in src/checkin/static/checkin/js/profile_detail.js - About 1 hr to fix

                    Function getPeriodIn has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function getPeriodIn(rules, date, direction) {
                    date = (date.getDay() + 6) % 7 + date.getHours() / 24 + date.getMinutes() / (24 * 60);
                    for (const rule of rules) {
                    for (const period of rule.periods) {
                    if (direction === 1 && period[0] === date) {
                    Severity: Minor
                    Found in src/make_queue/static/make_queue/js/reservation_rule_utils.js - About 1 hr to fix

                    Function get_error_message has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def get_error_message(self, form, reservation):
                    """
                    Generates the correct error message for the given form.
                     
                    :param reservation: The reservation to generate an error message for
                    Severity: Minor
                    Found in src/make_queue/views/reservation.py - About 1 hr to fix

                    Function selectionPopupContent has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    ReservationCalendar.prototype.selectionPopupContent = function () {
                    /**
                    * Creates the default content for the popup after selection is finished. The content produced is a simple card with
                    * information about the selection and a button to create a reservation using the selection.
                    */
                    Severity: Minor
                    Found in src/make_queue/static/make_queue/js/calendar.js - About 1 hr to fix

                      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
                      Severity
                      Category
                      Status
                      Source
                      Language