MAKENTNU/web

View on GitHub

Showing 230 of 230 total issues

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 all(rule.valid_time_in_rule(start_time, end_time, len(rules) > 1) for rule in rules)
    Severity: Major
    Found in src/make_queue/models/reservation.py - About 30 mins to fix

      Function isValidForRules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function isValidForRules(rules, startTime, endTime) {
      /**
      * Checks if the period [startTime, endTime] is valid for the given set of rules
      */
      const coveredRules = getRulesCovered(rules, startTime, endTime);
      Severity: Minor
      Found in src/make_queue/static/make_queue/js/reservation_rule_utils.js - About 25 mins to fix

      Function mock_module_attrs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def mock_module_attrs(module_and_attrname_to_newattr: dict[tuple[Any, str], Any]):
      """
      A decorator for monkey patching attributes of modules while the decorated function is executed;
      the original module attributes are monkey patched back after execution.
       
       
      Severity: Minor
      Found in src/util/test_utils.py - About 25 mins to fix

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

      def post(self, request):
      """
      Handles the request from the RFID card reader.
      Does a basic check for a valid card id.
       
       
      Severity: Minor
      Found in src/card/views.py - About 25 mins to fix

      Function addVoterPost has a Cognitive Complexity of 6 (exceeds 5 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 25 mins to fix

      Function form_invalid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def form_invalid(self, form):
      if '__all__' in form.errors:
      for error in form.errors['__all__'].data:
      if error.code == 'warning_message':
      messages.add_message(self.request, messages.WARNING, error.message)
      Severity: Minor
      Found in src/internal/views.py - About 25 mins to fix

      Function inner_run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def inner_run(self, *args, **options):
      if not settings.DEBUG:
      super().inner_run(*args, **options)
       
      addr_regex = r"(?:127\.0\.0\.1|localhost)"
      Severity: Minor
      Found in src/web/management/commands/runserver.py - About 25 mins to fix

      Function _do_request_assertion_for_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def _do_request_assertion_for_path(self, path: str, language_prefix: str, client: Client, is_superuser: bool, test_case: SimpleTestCase):
      response = client.get(path)
       
      if self.redirect:
      test_case.assertIn(response.status_code, {HTTPStatus.MOVED_PERMANENTLY, HTTPStatus.FOUND},
      Severity: Minor
      Found in src/util/test_utils.py - About 25 mins to fix

      Function block_join has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def block_join(object_collection: Sequence | QuerySet, sep="<b>&bull;</b>", multiline=True):
      if len(object_collection) == 0:
      return ""
       
      tag = '<div style="display: inline-block; white-space: nowrap;">'
      Severity: Minor
      Found in src/util/html_utils.py - About 25 mins to fix

      Function get_context_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      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 - About 25 mins to fix

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

      def post(self, request):
      scan_exists = RegisterProfile.objects.exists()
      response_dict = {
      'scan_exists': scan_exists,
      'scan_is_recent': False,
      Severity: Minor
      Found in src/checkin/api/views.py - About 25 mins to fix

      Use of mark_safe() may expose cross-site scripting vulnerabilities and should be reviewed.
      Open

      mark_safe(
      f"{time_place.ticket_count}/{time_place.number_of_tickets}&emsp;"
      + link_to_admin_change_form(time_place, text=f"({short_datetime_format(time_place.start_time)})")
      Severity: Minor
      Found in src/news/admin.py by bandit

      TODO found
      Open

      # TODO: remove the "repeating" and "standalone" parentheses and rename the choice variables to `STANDARD` and `MULTIPART`,
      Severity: Minor
      Found in src/news/models.py by fixme

      TODO found
      Open

      // TODO: refactor to reduce code duplication with other parts of the file

      Merge this if statement with the enclosing one.
      Open

      if enable_changing_rich_text_source and request.user.has_perm('internal.can_change_rich_text_source'):
      Severity: Major
      Found in src/web/multilingual/admin.py by sonar-python

      Potential XSS on mark_safe function.
      Open

      return mark_safe(f"- <i>({standalone_notice})</i>")
      Severity: Minor
      Found in src/news/admin.py by bandit

      Potential XSS on mark_safe function.
      Open

      message = mark_safe(trim_whitespace(message))
      Severity: Minor
      Found in src/news/views/event.py by bandit

      Use of mark_safe() may expose cross-site scripting vulnerabilities and should be reviewed.
      Open

      return mark_safe(tag) + escape(object_collection[0]) + mark_safe("</div>") + everything_except_first
      Severity: Minor
      Found in src/util/html_utils.py by bandit

      Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
      Open

      assert issubclass(new_widget_type, MultiLingualTextEdit)
      Severity: Info
      Found in src/web/multilingual/admin.py by bandit
      Severity
      Category
      Status
      Source
      Language