Showing 515 of 5,889 total issues

File models.py has 1510 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# pylint: disable=too-many-lines; Allow more than 1000 lines
import datetime
import logging
import string
from typing import Collection, Iterable, List, Optional, Union
Severity: Major
Found in intranet/apps/eighth/models.py - About 4 days to fix

    Function schedule_activity_view has a Cognitive Complexity of 165 (exceeds 5 allowed). Consider refactoring.
    Open

    def schedule_activity_view(request):
        if request.method == "POST":
            formset = ScheduledActivityFormset(request.POST)
    
            if formset.is_valid():
    Severity: Minor
    Found in intranet/apps/eighth/views/admin/scheduling.py - About 3 days 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 add_user has a Cognitive Complexity of 150 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_user(
            self,
            user: "get_user_model()",
            request: Optional[HttpRequest] = None,
            force: bool = False,
    Severity: Minor
    Found in intranet/apps/eighth/models.py - About 3 days 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

    File models.py has 1102 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # pylint: disable=too-many-lines; Allow more than 1000 lines
    import logging
    from base64 import b64encode
    from datetime import timedelta
    from typing import Collection, Dict, Optional, Union
    Severity: Major
    Found in intranet/apps/users/models.py - About 2 days to fix

      Function poll_vote_view has a Cognitive Complexity of 112 (exceeds 5 allowed). Consider refactoring.
      Open

      def poll_vote_view(request, poll_id):
          poll = get_object_or_404(Poll, id=poll_id)
      
          user = request.user
          is_polls_admin = user.has_admin_permission("polls")
      Severity: Minor
      Found in intranet/apps/polls/views.py - About 2 days 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 eighth_signup_view has a Cognitive Complexity of 111 (exceeds 5 allowed). Consider refactoring.
      Open

      def eighth_signup_view(request, block_id=None):
          start_time = time.time()
      
          if block_id is None and "block" in request.GET:
              block_ids = request.GET.getlist("block")
      Severity: Minor
      Found in intranet/apps/eighth/views/signup.py - About 2 days 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 query has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring.
      Open

      def query(q, admin=False):
          # If only a digit, search for student ID and user ID
          results = []
          if is_entirely_digit(q):
              results = list(get_user_model().objects.exclude_from_search().filter(Q(student_id=q) | Q(id=q)))
      Severity: Minor
      Found in intranet/apps/search/views.py - About 2 days 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 files_type has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
      Open

      def files_type(request, fstype=None):
          """Do all processing (directory listing, file downloads) for a given filesystem."""
          try:
              host = Host.objects.get(code=fstype)
          except Host.DoesNotExist:
      Severity: Minor
      Found in intranet/apps/files/views.py - About 1 day 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 edit_activity_view has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
      Open

      def edit_activity_view(request, activity_id):
          try:
              activity = EighthActivity.objects.get(id=activity_id)  # include deleted
          except EighthActivity.DoesNotExist as e:
              raise http.Http404 from e
      Severity: Minor
      Found in intranet/apps/eighth/views/admin/activities.py - About 1 day 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 eighth_multi_signup_view has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
      Open

      def eighth_multi_signup_view(request):
          if request.method == "POST":
              if "unsignup" in request.POST and "aid" not in request.POST:
                  uid = request.POST.get("uid")
                  bids_comma = request.POST.get("bid")
      Severity: Minor
      Found in intranet/apps/eighth/views/signup.py - About 1 day 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 take_attendance_view has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
      Open

      def take_attendance_view(request, scheduled_activity_id):
          try:
              scheduled_activity = EighthScheduledActivity.objects.select_related("activity", "block").get(
                  activity__deleted=False, id=scheduled_activity_id
              )
      Severity: Minor
      Found in intranet/apps/eighth/views/attendance.py - About 1 day 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 room_utilization_action has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
      Open

      def room_utilization_action(request, start_id, end_id):
          try:
              start_block = EighthBlock.objects.get(id=start_id)
              end_block = EighthBlock.objects.get(id=end_id)
      
      
      Severity: Minor
      Found in intranet/apps/eighth/views/admin/rooms.py - About 1 day 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

      File groups.py has 653 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import csv
      import logging
      import re
      from typing import List, Optional
      
      
      Severity: Major
      Found in intranet/apps/eighth/views/admin/groups.py - About 1 day to fix

        Function add_block_view has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
        Open

        def add_block_view(request):
            if request.method == "POST" and "custom_block" in request.POST:
                form = QuickBlockForm(request.POST)
                if form.is_valid():
                    form.save()
        Severity: Minor
        Found in intranet/apps/eighth/views/admin/blocks.py - About 1 day 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

        File __init__.py has 638 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import datetime
        import logging
        import os
        import re
        import sys
        Severity: Major
        Found in intranet/settings/__init__.py - About 1 day to fix

          File bus-afternoon.js has 636 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { getSocket } from "./bus-shared.js";
          
          /* globals Messenger */
          var bus = {};
          
          
          Severity: Major
          Found in intranet/static/js/bus-afternoon.js - About 1 day to fix

            File views.py has 610 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import csv
            import json
            import logging
            from collections import OrderedDict
            
            
            Severity: Major
            Found in intranet/apps/polls/views.py - About 1 day to fix

              User has 69 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class User(AbstractBaseUser, PermissionsMixin):
                  """Django User model subclass"""
              
                  TITLES = (("Mr.", "Mr."), ("Ms.", "Ms."), ("Mrs.", "Mrs."), ("Dr.", "Dr."), ("Mx.", "Mx."))
              
              
              Severity: Major
              Found in intranet/apps/users/models.py - About 1 day to fix

                Function perform_hybrid_block_signup has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
                Open

                def perform_hybrid_block_signup(fmtdate, celery_logger):
                    blocks = EighthBlock.objects.filter(date=fmtdate)
                    block_names = {b.block_letter[4:] for b in blocks if "P1" in b.block_letter or "P2" in b.block_letter or "Virt" in b.block_letter}
                    sticky_act = EighthActivity.objects.get_or_create(name="z - Hybrid Sticky", sticky=True, administrative=True)[0]
                    failed_users = set()
                Severity: Minor
                Found in intranet/apps/eighth/views/admin/blocks.py - About 1 day 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

                File attendance.py has 585 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import csv
                import io
                import logging
                from html import escape
                
                
                Severity: Major
                Found in intranet/apps/eighth/views/attendance.py - About 1 day to fix
                  Severity
                  Category
                  Status
                  Source
                  Language