nus-mtp/cs-modify

View on GitHub

Showing 75 of 2,705 total issues

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

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

    function convertToDataPrerequisite() {
        var prerequisites = [];
        // For iterating through units comprising of
        // [[Module-columns],[AND-column]]
        var rows = document.getElementsByTagName("tbody")[0].children;
    Severity: Minor
    Found in static/javascripts/csmodify.js - 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 validate_input has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def validate_input(input_data, input_types, is_future=False,
    Severity: Minor
    Found in components/model.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not outcome:
                              is_successful = False
                              error_code_and_msg = [module, ERROR_MSG_MODULE_DOESNT_EXIST]
                              error_list.append(error_code_and_msg)
                          else:
      Severity: Major
      Found in components/database.py - About 45 mins to fix

        Function validate_input has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def validate_input(input_data, input_types, is_future=False,
        Severity: Minor
        Found in components/helper.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if outcome == "has_mounting":
                                      outcome_message += "Module " + module_code + " has " +\
                                                         "mountings that refer to it. " +\
                                                         "Please remove all mountings before deleting " +\
                                                         "the module."
          Severity: Major
          Found in components/handlers/outcome.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if sem1_quota == '?' or sem1_quota == '-':
                                        oversub_amount = sem1_num_students
                                    else:
                                        oversub_amount = sem1_num_students - sem1_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

              Avoid deeply nested control flow statements.
              Open

                                      if sem1_quota == '?' or sem1_quota == '-':
                                          oversub_amount = sem1_num_students
                                      else:
                                          oversub_amount = sem1_num_students - sem1_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

                Consider simplifying this complex logical expression.
                Open

                                    if ((sem2_quota != '?' and sem2_quota != '-') \
                                        and sem2_num_students > sem2_quota) \
                                        or ((sem2_quota == '?' or sem2_quota == '-') and sem2_num_students > 0):
                                        if sem2_quota == '?' or sem2_quota == '-':
                                            oversub_amount = sem2_num_students
                Severity: Major
                Found in components/handlers/oversub_mod.py - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                                      if ((sem1_quota != '?' and sem1_quota != '-') \
                                          and sem1_num_students > sem1_quota) \
                                          or ((sem1_quota == '?' or sem1_quota == '-') and sem1_num_students > 0):
                                          if sem1_quota == '?' or sem1_quota == '-':
                                              oversub_amount = sem1_num_students
                  Severity: Major
                  Found in components/handlers/oversub_mod.py - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                                        if ((sem1_quota != '?' and sem1_quota != '-') \
                                            and sem1_num_students > sem1_quota) \
                                            or ((sem1_quota == '?' or sem1_quota == '-') and sem1_num_students > 0):
                                            if sem1_quota == '?' or sem1_quota == '-':
                                                oversub_amount = sem1_num_students
                    Severity: Major
                    Found in components/handlers/oversub_mod.py - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                          if ((sem2_quota != '?' and sem2_quota != '-') \
                                              and sem2_num_students > sem2_quota) \
                                              or ((sem2_quota == '?' or sem2_quota == '-') and sem2_num_students > 0):
                                              if sem2_quota == '?' or sem2_quota == '-':
                                                  oversub_amount = sem2_num_students
                      Severity: Major
                      Found in components/handlers/oversub_mod.py - About 40 mins to fix

                        Function checkMountingChange has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function checkMountingChange(element, oldMounting, oldQuota, mountingID, quotaID) {
                        Severity: Minor
                        Found in static/javascripts/editAll.js - About 35 mins to fix

                          Function add_module has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def add_module(code, name, description, module_credits, status):
                          Severity: Minor
                          Found in components/model.py - About 35 mins to fix

                            Function add_module has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def add_module(code, name, description, module_credits, status):
                            Severity: Minor
                            Found in components/database.py - About 35 mins to fix

                              Function get_all_mods_taken_together has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def get_all_mods_taken_together(aysem=None):
                                  '''
                                      Retrieves the list of all modules taken together in the same semester.
                              
                                      Returns a table of lists. Each list contains
                              Severity: Minor
                              Found in components/database.py - About 35 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_mods_no_one_take has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def get_mods_no_one_take(aysem):
                                  '''
                                      Retrieves the list of all modules which no student take together
                                      in the specified semester.
                              
                              
                              Severity: Minor
                              Found in components/database.py - About 35 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def GET(self):
                                      '''
                                          This function is called when /starModule is accessed.
                                      '''
                                      web.header('X-Frame-Options', 'SAMEORIGIN')
                              Severity: Minor
                              Found in components/handlers/star_modules.py - About 35 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_mod_specified_class_size has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def get_mod_specified_class_size(given_aysem, quota_lower, quota_higher):
                                  '''
                                      Retrieves the list of modules with quota/class size in the
                                      specified AY-Semester if the quota falls within the given range
                                      of quota_lower <= retrieved module quota <= quota_higher
                              Severity: Minor
                              Found in components/database.py - About 35 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 False
                              Severity: Major
                              Found in components/handlers/edit_all_mountings_and_quotas.py - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language