MAKENTNU/web

View on GitHub
src/make_queue/views/reservation.py

Summary

Maintainability
B
5 hrs
Test Coverage

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

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.

Severity: Minor
Found in src/make_queue/views/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

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 _("The reservation cannot start and end at the same time")
      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 _("The start time can't be after the end time")
        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 _("The reservation can't start in the past")
          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 _("The time slot is not available")
            Severity: Major
            Found in src/make_queue/views/reservation.py - About 30 mins to fix

              Error: invalid syntax (<unknown>, line 273)</unknown>
              Open

                      match self.query_params['owner']:
              Severity: Minor
              Found in src/make_queue/views/reservation.py by radon

              We encountered an error attempting to analyze this line.

              TODO found
              Open

              # TODO: rewrite this whole view (and everything that uses it), so that it's more extendable,
              Severity: Minor
              Found in src/make_queue/views/reservation.py by fixme

              There are no issues that match your filters.

              Category
              Status