MAKENTNU/web

View on GitHub

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

Severity: Minor
Found in src/news/models.py - About 45 mins to fix

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}"
Severity: Minor
Found in src/util/templatetags/permission_tags.py - About 45 mins to fix

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
Severity: Minor
Found in src/make_queue/forms/reservation.py - About 45 mins to fix

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");
Severity: Minor
Found in src/web/static/web/js/forms/widgets/mazemap_search.js - About 45 mins to fix

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);
        }
Severity: Major
Found in src/make_queue/static/make_queue/js/reservation_form.js - About 40 mins to fix

    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:
    Severity: Minor
    Found in src/web/management/commands/test.py - About 35 mins to fix

    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)
    Severity: Minor
    Found in src/make_queue/models/course.py - About 35 mins to fix

    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():
    Severity: Minor
    Found in src/web/management/commands/makemessages.py - About 35 mins to fix

    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")
    Severity: Minor
    Found in src/internal/static/internal/js/member_list.js - About 35 mins to fix

    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')
    Severity: Minor
    Found in src/make_queue/forms/machine.py - About 35 mins to fix

    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 = [];
    Severity: Minor
    Found in src/make_queue/static/make_queue/js/reservation_form.js - About 35 mins to fix

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

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

    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:
    Severity: Minor
    Found in src/web/multilingual/formfields.py - About 35 mins to fix

    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.
    Severity: Minor
    Found in src/util/url_utils.py - About 35 mins to fix

    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;
    Severity: Major
    Found in src/make_queue/static/make_queue/js/reservation_form.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return False
      Severity: Major
      Found in src/make_queue/models/reservation.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return _("The reservation exceeds your quota")
        Severity: Major
        Found in src/make_queue/views/reservation.py - About 30 mins to fix

          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")
          Severity: Major
          Found in src/make_queue/views/reservation.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                                return False
            Severity: Major
            Found in src/make_queue/models/reservation.py - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language