nus-mtp/cs-modify

View on GitHub

Showing 75 of 2,705 total issues

Function onload has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

window.onload = function () {
    var chart = new CanvasJS.Chart("quota-demand-chart",
    {
      animationEnabled: true,

Severity: Minor
Found in static/javascripts/viewModule.js - 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 replace_empty_quota_with_symbols has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def replace_empty_quota_with_symbols(mounting_plan):
    '''
        Replace all quota values with '-' (if not mounted)
        or '?' (if mounted)
    '''
Severity: Minor
Found in components/helper.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_oversub_mod has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def get_oversub_mod():
    '''
        Retrieves a list of modules which are oversubscribed.
        Returns module code, module name, AY/Sem, quota, number students interested
        i.e. has more students interested than the quota
Severity: Minor
Found in components/database.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 highlightErrorFieldsPrerequisite has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function highlightErrorFieldsPrerequisite(data) {
    var modulesWithErrors = data;

    var rows = document.getElementsByTagName("tbody")[0].children;
    var message_start = "<p><b>";
Severity: Minor
Found in static/javascripts/csmodify.js - 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_modules_with_modified_mounting has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def get_modules_with_modified_mounting(self):
        '''
            Get all modules whose mounting has been modified in a future AY.
            Return the module code, current AY-Sem, target AY-Sem, and mounting change
        '''
Severity: Minor
Found in components/handlers/modified_modules.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 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def GET(self, *test_data):
        '''
            Retrieve and display the pairs of modules that have
            at least 1 student who has taken module A
            prior to taking module B
Severity: Minor
Found in components/handlers/module_taken_prior_to_others.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 populate_module_ay_sem_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def populate_module_ay_sem_data(self):
        '''
            Populate each subplan with sem 1 and sem 2 mounting values, quotas,
            and numbers of students taking
        '''
Severity: Minor
Found in components/handlers/fixed_module_mountings.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 replaceNilQuotasWithNumbers has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function replaceNilQuotasWithNumbers(elementID){
    var table = $(elementID).DataTable();
    var data = table
        .rows()
        .data();
Severity: Minor
Found in static/javascripts/fixedAndTentaMounting.js - About 1 hr to fix

    Function saveChangesPrerequisite has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function saveChangesPrerequisite() {
        attachListenersToInputs(2);
    
        // Submit data to backend for updating the prerequisites for module.
        var modulePrerequisites = convertToDataPrerequisite();
    Severity: Minor
    Found in static/javascripts/csmodify.js - About 1 hr to fix

      Function saveChangesPreclusion has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function saveChangesPreclusion() {
          attachListenersToInputs(1);
      
          // Submit data to backend for updating the preclusions for module.
          var modulePreclusions = convertToDataPreclusion();
      Severity: Minor
      Found in static/javascripts/csmodify.js - About 1 hr to fix

        Function load_student_enrollments has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def load_student_enrollments(self, module_code, ay_sem):
                '''
                    Retrieve the number of students in each year of study,
                    and the number of students in each focus area,
                    that are taking this module
        Severity: Minor
        Found in components/handlers/module_view_in_ay_sem.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 convert_list_of_prereqs_to_string has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def convert_list_of_prereqs_to_string(prereq_list):
            '''
                Converts given list of lists (prereq_list) into string form of prereqs.
                Pre-condition: Given list must have the rows' first index sorted.
                Example: [['0', 'CS1010'], ['0', 'CS1231'], ['1', 'CS2105']] will yield
        Severity: Minor
        Found in components/helper.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 POST has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def POST(self):
                '''
                    Handles the deletion of a module
                '''
                # Verify that module exists
        Severity: Minor
        Found in components/handlers/delete_module.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 resetMountingAndQuota has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function resetMountingAndQuota(sem1Mounting, sem2Mounting, sem1Quota, sem2Quota,
                                       sem1MountingOption, sem2MountingOption,
                                       sem1QuotaInput, sem2QuotaInput) {
        Severity: Major
        Found in static/javascripts/editAll.js - About 1 hr to fix

          Function POST has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def POST(self, *test_data):
                  '''
                      Handles the submission of the 'Edit General Module Info' page
                  '''
                  if test_data:   # for testing purposes
          Severity: Minor
          Found in components/handlers/module_edit.py - About 55 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 deeply nested control flow statements.
          Open

                                      if test_data:
                                          return False
                                      else:
                                          return Outcome().POST("edit_all_mountings_and_quotas", False, None)
                              except ValueError:  # quota is not an integer
          Severity: Major
          Found in components/handlers/edit_all_mountings_and_quotas.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if test_data:
                                            return False
                                        else:
                                            return Outcome().POST("edit_all_mountings_and_quotas", False, None)
                                except ValueError:  # quota is not an integer
            Severity: Major
            Found in components/handlers/edit_all_mountings_and_quotas.py - About 45 mins to fix

              Function append_missing_year_of_study has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def append_missing_year_of_study(initial_table):
                  '''
                      Helper function to append missing years of study to the
                      given initial table.
                      initial_table given in lists of (year, number of students)
              Severity: Minor
              Found in components/helper.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 get_prerequisite_units has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_prerequisite_units(module_code):
                  '''
                      Retrieves all the prerequisite of given module_code as a list
                      of lists. The list will be a list of units having the "and" relationship.
                      Each unit is a list of modules having the "or" relationship.
              Severity: Minor
              Found in components/helper.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 deeply nested control flow statements.
              Open

                                      if sem2_quota == '?' or sem2_quota == '-':
                                          oversub_amount = sem2_num_students
                                      else:
                                          oversub_amount = sem2_num_students - sem2_quota
                                      list_of_oversub_mod.append((module_code, module_name, target_ay_sem,
              Severity: Major
              Found in components/handlers/oversub_mod.py - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language