ncbo/bioportal_web_ui

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

Summary

Maintainability
F
1 wk
Test Coverage

File bp_admin.js has 867 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Created by mdorf on 3/27/15.
 * Updated by Syphax.Bouazzouni on 28/04/21 , users admin part
 */

Severity: Major
Found in app/assets/javascripts/bp_admin.js - About 2 days to fix

    Function displayOntologies has 121 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function displayOntologies(data, ontology) {
      var ontTable = null;
    
      if (jQuery.fn.dataTable.isDataTable('#adminOntologies')) {
        ontTable = jQuery('#adminOntologies').DataTable();
    Severity: Major
    Found in app/assets/javascripts/bp_admin.js - About 4 hrs to fix

      Function displayUsers has 91 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function displayUsers(data) {
          let ontTable = null;
          let allRows
          if (jQuery.fn.dataTable.isDataTable('#adminUsers')) {
              ontTable = jQuery('#adminUsers').DataTable();
      Severity: Major
      Found in app/assets/javascripts/bp_admin.js - About 3 hrs to fix

        Function onSuccessAction has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

        AjaxAction.prototype.onSuccessAction = function(data, ontology, deferredObj) {
          var self = this;
          if (!self.isLongOperation) {
            return;
          }
        Severity: Minor
        Found in app/assets/javascripts/bp_admin.js - About 3 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 _showStatusMessages has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

        function _showStatusMessages(success, errors, notices, isAppendMode) {
          if (success.length > 0) {
            if (isAppendMode) {
              var appendStr = (jQuery.trim(jQuery('#success_message').html()).length) ? ", " : "";
              jQuery("#success_message").append(appendStr + success.join(", ")).html();
        Severity: Minor
        Found in app/assets/javascripts/bp_admin.js - About 2 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 onSuccessAction has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

        UpdateCheck.prototype.onSuccessAction = function(data, ontology, deferredObj) {
          var self = this;
          delete data["success"];
          updateInfo = data["update_info"];
        
        
        Severity: Minor
        Found in app/assets/javascripts/bp_admin.js - About 2 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 _ajaxCall has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        AjaxAction.prototype._ajaxCall = function() {
          var self = this;
          var success = [];
          var errors = [];
          var notices = [];
        Severity: Major
        Found in app/assets/javascripts/bp_admin.js - About 2 hrs to fix

          Function onSuccessAction has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          AjaxAction.prototype.onSuccessAction = function(data, ontology, deferredObj) {
            var self = this;
            if (!self.isLongOperation) {
              return;
            }
          Severity: Major
          Found in app/assets/javascripts/bp_admin.js - About 2 hrs to fix

            Function timer has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              var timer = setInterval(function() {
                jQuery.ajax({
                  url: determineHTTPS(BP_CONFIG.rest_url) + "/admin/ontologies_report/" + processId,
                  data: {
                    apikey: BP_CONFIG.apikey,
            Severity: Minor
            Found in app/assets/javascripts/bp_admin.js - About 1 hr to fix

              Function populateOntologyRows has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              function populateOntologyRows(data) {
                var ontologies = data.ontologies;
                var allRows = [];
                var hideFields = ["format", "administeredBy", "date_created", "report_date_updated", "errErrorStatus", "errMissingStatus", "problem", "logFilePath"];
              
              
              Severity: Minor
              Found in app/assets/javascripts/bp_admin.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 displayOntologies has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              function displayOntologies(data, ontology) {
                var ontTable = null;
              
                if (jQuery.fn.dataTable.isDataTable('#adminOntologies')) {
                  ontTable = jQuery('#adminOntologies').DataTable();
              Severity: Minor
              Found in app/assets/javascripts/bp_admin.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 onSuccessAction has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              UpdateCheck.prototype.onSuccessAction = function(data, ontology, deferredObj) {
                var self = this;
                delete data["success"];
                updateInfo = data["update_info"];
              
              
              Severity: Minor
              Found in app/assets/javascripts/bp_admin.js - About 1 hr to fix

                Function populateOntologyRows has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function populateOntologyRows(data) {
                  var ontologies = data.ontologies;
                  var allRows = [];
                  var hideFields = ["format", "administeredBy", "date_created", "report_date_updated", "errErrorStatus", "errMissingStatus", "problem", "logFilePath"];
                
                
                Severity: Minor
                Found in app/assets/javascripts/bp_admin.js - About 1 hr to fix

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

                  function _showStatusMessages(success, errors, notices, isAppendMode) {
                    if (success.length > 0) {
                      if (isAppendMode) {
                        var appendStr = (jQuery.trim(jQuery('#success_message').html()).length) ? ", " : "";
                        jQuery("#success_message").append(appendStr + success.join(", ")).html();
                  Severity: Minor
                  Found in app/assets/javascripts/bp_admin.js - About 1 hr to fix

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

                    function displayUsers(data) {
                        let ontTable = null;
                        let allRows
                        if (jQuery.fn.dataTable.isDataTable('#adminUsers')) {
                            ontTable = jQuery('#adminUsers').DataTable();
                    Severity: Minor
                    Found in app/assets/javascripts/bp_admin.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 AjaxAction has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    var AjaxAction = function(httpMethod, operation, path, isLongOperation, params) {
                    Severity: Minor
                    Found in app/assets/javascripts/bp_admin.js - About 35 mins to fix

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

                        if (notices.length > 0) {
                          if (isAppendMode) {
                            var appendStr = (jQuery.trim(jQuery('#info_message').html()).length) ? ", " : "";
                            jQuery("#info_message").append(appendStr + notices.join(", ")).html();
                          } else {
                      Severity: Major
                      Found in app/assets/javascripts/bp_admin.js and 2 other locations - About 5 hrs to fix
                      app/assets/javascripts/bp_admin.js on lines 598..606
                      app/assets/javascripts/bp_admin.js on lines 608..616

                      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 140.

                      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 3 locations. Consider refactoring.
                      Open

                        if (errors.length > 0) {
                          if (isAppendMode) {
                            var appendStr = (jQuery.trim(jQuery('#error_message').html()).length) ? ", " : "";
                            jQuery("#error_message").append(appendStr + errors.join(", ")).html();
                          } else {
                      Severity: Major
                      Found in app/assets/javascripts/bp_admin.js and 2 other locations - About 5 hrs to fix
                      app/assets/javascripts/bp_admin.js on lines 598..606
                      app/assets/javascripts/bp_admin.js on lines 618..626

                      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 140.

                      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 3 locations. Consider refactoring.
                      Open

                        if (success.length > 0) {
                          if (isAppendMode) {
                            var appendStr = (jQuery.trim(jQuery('#success_message').html()).length) ? ", " : "";
                            jQuery("#success_message").append(appendStr + success.join(", ")).html();
                          } else {
                      Severity: Major
                      Found in app/assets/javascripts/bp_admin.js and 2 other locations - About 5 hrs to fix
                      app/assets/javascripts/bp_admin.js on lines 608..616
                      app/assets/javascripts/bp_admin.js on lines 618..626

                      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 140.

                      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

                            "rowCallback": function(row, data, index) {
                              var acronym = jQuery('td:first', row).text();
                              jQuery(row).attr("id", "tr_" + acronym);
                      
                              if (data[data.length - 1] === true) {
                      Severity: Major
                      Found in app/assets/javascripts/bp_admin.js and 1 other location - About 2 hrs to fix
                      app/assets/javascripts/bp_admin.js on lines 929..936

                      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 90.

                      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

                                  "rowCallback": function(row, data, index) {
                                      var acronym = jQuery('td:nth-child(3)', row).text();
                      
                                      jQuery(row).attr("id", "tr_" + acronym);
                                      if (data[data.length - 1] === true) {
                      Severity: Major
                      Found in app/assets/javascripts/bp_admin.js and 1 other location - About 2 hrs to fix
                      app/assets/javascripts/bp_admin.js on lines 662..669

                      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 90.

                      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

                                if (data.notices) {
                                  var notice = data.notices.replace(reg, ',');
                                  notices.push.apply(notices, notice.split(","));
                                }
                      Severity: Major
                      Found in app/assets/javascripts/bp_admin.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/bp_admin.js on lines 152..155

                      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 55.

                      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

                                if (data.success) {
                                  var suc = data.success.replace(reg, ',');
                                  success.push.apply(success, suc.split(","));
                                }
                      Severity: Major
                      Found in app/assets/javascripts/bp_admin.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/bp_admin.js on lines 157..160

                      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 55.

                      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