autolab/Autolab

View on GitHub
app/assets/javascripts/watchlist.js

Summary

Maintainability
F
5 days
Test Coverage

File watchlist.js has 622 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Loads all Semantic javascripts
//= require semantic-ui

const escapeHtml = (unsafe) => {
  return unsafe.replaceAll('&', '&')
Severity: Major
Found in app/assets/javascripts/watchlist.js - About 1 day to fix

    Function get_watchlist_function has 192 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function get_watchlist_function(){
    
      var pending_instances = {}
      var contacted_instances = {}
      var resolved_instances = {}
    Severity: Major
    Found in app/assets/javascripts/watchlist.js - About 7 hrs to fix

      Function get_condition_html has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function get_condition_html(condition_types) {
        var conditions_html = "";
        $.each(condition_types, function( condition, violations ) {
          var condition_string = "";
          var violation_string = "";
      Severity: Major
      Found in app/assets/javascripts/watchlist.js - About 2 hrs to fix

        Function set_tab_html has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function set_tab_html(is_search, instances, tab_name, archived_instances, empty_message, selected_user_ids) {
          is_empty = Object.keys(instances).length === 0;
          if (is_empty && !is_search){
            $(`#${tab_name}_header`).hide();
            html_empty_message = get_html_empty_message(empty_message);
        Severity: Major
        Found in app/assets/javascripts/watchlist.js - About 2 hrs to fix

          Function get_buttons_html has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function get_buttons_html(user_id, tab, archived_instances) {
            var archived_icon = (user_id in archived_instances) ? 
                `<div class="left ui icon" data-content="Student also appears in archived">
                  <i class="exclamation circle icon"></i>
                </div>` : "";
          Severity: Minor
          Found in app/assets/javascripts/watchlist.js - About 1 hr to fix

            Function search_enter_action has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function search_enter_action(query, tab_name, instances, archived_instances, empty_message, selected_user_ids) {
              var search_input = query.toLowerCase().trim();
              if (search_input === "") {
                set_tab_html(
                  true,
            Severity: Minor
            Found in app/assets/javascripts/watchlist.js - About 1 hr to fix

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

              function set_search_action(instances, tab_name, archived_instances, empty_message, search_content, selected_user_ids) {
              Severity: Minor
              Found in app/assets/javascripts/watchlist.js - About 45 mins to fix

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

                function search_enter_action(query, tab_name, instances, archived_instances, empty_message, selected_user_ids) {
                Severity: Minor
                Found in app/assets/javascripts/watchlist.js - About 45 mins to fix

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

                  function set_tab_html(is_search, instances, tab_name, archived_instances, empty_message, selected_user_ids) {
                  Severity: Minor
                  Found in app/assets/javascripts/watchlist.js - About 45 mins to fix

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

                    function showTopButtons(selectAllCheckbox, resolveButton, contactButton, deleteButton, exportButton) {
                    Severity: Minor
                    Found in app/assets/javascripts/watchlist.js - About 35 mins to fix

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

                      function set_tab_html(is_search, instances, tab_name, archived_instances, empty_message, selected_user_ids) {
                        is_empty = Object.keys(instances).length === 0;
                        if (is_empty && !is_search){
                          $(`#${tab_name}_header`).hide();
                          html_empty_message = get_html_empty_message(empty_message);
                      Severity: Minor
                      Found in app/assets/javascripts/watchlist.js - 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 updateButtonVisibility has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function updateButtonVisibility(item){
                        // Deleting instances only avilable in archive tab
                        showTopButtons(true, true, true, false, true);
                        switch ($(item).attr("data-tab")) {
                          case "pending_tab":
                      Severity: Minor
                      Found in app/assets/javascripts/watchlist.js - About 25 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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                        $('#resolve_button').click(function(){
                          method = "resolve";
                          var instances = get_active_instances(pending_instances, contacted_instances, archived_instances);
                      
                          var instance_ids = [];
                      Severity: Major
                      Found in app/assets/javascripts/watchlist.js and 1 other location - About 3 hrs to fix
                      app/assets/javascripts/watchlist.js on lines 543..555

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 110.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                        $('#delete_button').click(function(){
                          method = "delete";
                          var instances = get_active_instances(pending_instances, contacted_instances, archived_instances);
                      
                          var instance_ids = [];
                      Severity: Major
                      Found in app/assets/javascripts/watchlist.js and 1 other location - About 3 hrs to fix
                      app/assets/javascripts/watchlist.js on lines 527..539

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 110.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                            case "extension_requests":
                              var extension_count = 0;
                              var violation_list = [];
                              $.each(violations, function( lab, val ) {
                                violation_list.push(`${lab}: ${val}`);
                      Severity: Major
                      Found in app/assets/javascripts/watchlist.js and 1 other location - About 3 hrs to fix
                      app/assets/javascripts/watchlist.js on lines 90..99

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 101.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                            case "grace_day_usage":
                              var num_grace_days_used = 0;
                              var violation_list = [];
                              $.each(violations, function( lab, val ) {
                                violation_list.push(`${lab}: ${val}`);
                      Severity: Major
                      Found in app/assets/javascripts/watchlist.js and 1 other location - About 3 hrs to fix
                      app/assets/javascripts/watchlist.js on lines 100..109

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 101.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                        {
                          search_content, 
                          instances_dict, 
                          id, 
                          user_id, 
                      Severity: Minor
                      Found in app/assets/javascripts/watchlist.js and 1 other location - About 50 mins to fix
                      app/assets/javascripts/watchlist.js on lines 413..424

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 51.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                                var instance_info = {
                                  search_content,
                                  instances_dict,
                                  id, 
                                  user_id, 
                      Severity: Minor
                      Found in app/assets/javascripts/watchlist.js and 1 other location - About 50 mins to fix
                      app/assets/javascripts/watchlist.js on lines 272..283

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 51.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      There are no issues that match your filters.

                      Category
                      Status