Showing 515 of 5,889 total issues

File test_admin_groups.py has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import csv

from django.contrib.auth import get_user_model
from django.core.files.uploadedfile import SimpleUploadedFile
from django.urls import reverse
Severity: Minor
Found in intranet/apps/eighth/tests/admin/test_admin_groups.py - About 5 hrs to fix

    Function delinquent_students_view has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    def delinquent_students_view(request):
        lower_absence_limit = request.GET.get("lower", "")
        upper_absence_limit = request.GET.get("upper", "")
    
        include_freshmen = request.GET.get("freshmen", "off") == "on"
    Severity: Minor
    Found in intranet/apps/eighth/views/admin/attendance.py - About 5 hrs 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 signup.py has 381 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import datetime
    import logging
    import time
    
    from prometheus_client import Summary
    Severity: Minor
    Found in intranet/apps/eighth/views/signup.py - About 5 hrs to fix

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

          def post(self, request):
              """Validate and process the login POST request."""
      
              username = request.POST.get("username", "")
      
      
      Severity: Minor
      Found in intranet/apps/auth/views.py - About 5 hrs 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 signUp has 127 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          eighth.signUp = function(uid, bid, aid, callback) {
              var queryParams = $("#signup-button").hasClass("force") ? "?force" : "";
              $.ajax({
                  url: $("#activity-detail").data("signup-endpoint") + queryParams,
                  type: "POST",
      Severity: Major
      Found in intranet/static/js/eighth/signup.js - About 5 hrs to fix

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

        import logging
        from datetime import datetime, timedelta
        
        from dateutil.relativedelta import relativedelta
        
        
        Severity: Minor
        Found in intranet/apps/events/views.py - About 5 hrs to fix

          File tests.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import datetime
          import json
          import urllib.parse
          
          from oauth2_provider.models import AccessToken, get_application_model
          Severity: Minor
          Found in intranet/apps/api/tests.py - About 5 hrs to fix

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

            import csv
            import logging
            from datetime import MAXYEAR, MINYEAR, date, datetime, timedelta
            
            from cacheops import invalidate_obj
            Severity: Minor
            Found in intranet/apps/eighth/views/admin/attendance.py - About 5 hrs to fix

              Function getSocket has 124 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function getSocket(base_url, location, document, window, time) {
                  const protocol = (location.protocol.indexOf('s') > -1) ? 'wss' : 'ws';
                  let socket;
                  if (base_url !== '') {
                      socket = new ReconnectingWebSocket(`${protocol}://${base_url}/bus/`);
              Severity: Major
              Found in intranet/static/js/bus-shared.js - About 4 hrs to fix

                Function request_announcement_view has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                Open

                def request_announcement_view(request):
                    """The request announcement page."""
                    if request.method == "POST":
                        form = AnnouncementRequestForm(request.POST)
                
                
                Severity: Minor
                Found in intranet/apps/announcements/views.py - About 4 hrs 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 generate_statistics_pdf has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                Open

                def generate_statistics_pdf(activities=None, start_date=None, all_years=False, year=None):
                    """Accepts EighthActivity objects and outputs a PDF file."""
                    if activities is None:
                        activities = EighthActivity.objects.all().order_by("name")
                    if year is None:
                Severity: Minor
                Found in intranet/apps/eighth/views/activities.py - About 4 hrs 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 schedule_context has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                Open

                def schedule_context(request=None, date=None, use_cache=True, show_tomorrow=True):
                    monday = 1
                    friday = 5
                    if request and "date" in request.GET:
                        date = decode_date(request.GET["date"])
                Severity: Minor
                Found in intranet/apps/schedule/views.py - About 4 hrs 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 test_attendance.py has 371 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import csv
                import tempfile
                
                from django.contrib.auth import get_user_model
                from django.urls import reverse
                Severity: Minor
                Found in intranet/apps/eighth/tests/test_attendance.py - About 4 hrs to fix

                  File scheduling.py has 369 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import logging
                  
                  from cacheops import invalidate_obj
                  from formtools.wizard.views import SessionWizardView
                  
                  
                  Severity: Minor
                  Found in intranet/apps/eighth/views/admin/scheduling.py - About 4 hrs to fix

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

                    import calendar
                    import logging
                    from datetime import datetime, timedelta
                    
                    from dateutil.relativedelta import relativedelta
                    Severity: Minor
                    Found in intranet/apps/schedule/views.py - About 4 hrs to fix

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

                      def get_printers() -> Dict[str, str]:
                          """Returns a dictionary mapping name:description for available printers.
                      
                          This requires that a CUPS client be configured on the server.
                          Otherwise, this returns an empty dictionary.
                      Severity: Minor
                      Found in intranet/apps/printing/views.py - About 4 hrs 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 transfer_students_action has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def transfer_students_action(request):
                          """Do the actual process of transferring students."""
                          if "source_act" in request.GET:
                              source_act = EighthScheduledActivity.objects.get(id=request.GET.get("source_act"))
                          elif "source_act" in request.POST:
                      Severity: Minor
                      Found in intranet/apps/eighth/views/admin/scheduling.py - About 4 hrs 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_user_info has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def get_user_info(key: str, val) -> Optional[List[User]]:
                          if key in ["username", "id"]:
                              try:
                                  u = get_user_model().objects.filter(**{key: val})
                              except ValueError:
                      Severity: Minor
                      Found in intranet/apps/eighth/views/admin/groups.py - About 4 hrs 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_preferred_pic has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def save_preferred_pic(request, user):
                          preferred_pic = get_preferred_pic(user)
                          preferred_pic_form = PreferredPictureForm(user, data=request.POST, initial=preferred_pic)
                          if preferred_pic_form.is_valid():
                              if preferred_pic_form.has_changed():
                      Severity: Minor
                      Found in intranet/apps/preferences/views.py - About 4 hrs 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 events_view has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def events_view(request):
                          """Events homepage.
                      
                          Shows a list of events occurring in the next week, month, and
                          future.
                      Severity: Minor
                      Found in intranet/apps/events/views.py - About 4 hrs 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

                      Severity
                      Category
                      Status
                      Source
                      Language