ncbo/bioportal_web_ui

View on GitHub
public/javascripts/widgets/quick_jump.js

Summary

Maintainability
F
1 wk
Test Coverage

Function jumpTo_formatItem has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function jumpTo_formatItem(row) {
    var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"), // .*+?|()[]{}\
        keywords = jQuery(jumpTo_searchBoxSelector).val().trim().replace(specials, "\\$&").split(' ').join('|'),
        regex = new RegExp('(' + keywords + ')', 'gi');
    var resultTypeSpan = jQuery("<span>");
Severity: Major
Found in public/javascripts/widgets/quick_jump.js - About 2 hrs to fix

    File quick_jump.js has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // jQuery check, if it's not present then include it
    // jQuery check, if it's not present then include it
    function bpMinVersion(min, actual) {
      function parseVersionString (str) {
        if (typeof(str) != 'string') { return false; }
    Severity: Minor
    Found in public/javascripts/widgets/quick_jump.js - About 2 hrs to fix

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

      function jumpTo_formatItem(row) {
          var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"), // .*+?|()[]{}\
              keywords = jQuery(jumpTo_searchBoxSelector).val().trim().replace(specials, "\\$&").split(' ').join('|'),
              regex = new RegExp('(' + keywords + ')', 'gi');
          var resultTypeSpan = jQuery("<span>");
      Severity: Minor
      Found in public/javascripts/widgets/quick_jump.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 jumpTo_setup_functions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function jumpTo_setup_functions() {
          var extra_params = {
              subtreerootconceptid: encodeURIComponent(BP_search_branch)
          };
          var result_width = 350;
      Severity: Minor
      Found in public/javascripts/widgets/quick_jump.js - About 1 hr to fix

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

        function bpMinVersion(min, actual) {
          function parseVersionString (str) {
            if (typeof(str) != 'string') { return false; }
            var x = str.split('.');
            var maj = parseInt(x[0]) || 0;
        Severity: Minor
        Found in public/javascripts/widgets/quick_jump.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

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

        if (typeof jQuery == 'undefined') {
          var jq, jqMigrate, scriptLoc = document.getElementsByTagName('script')[0].parentElement;
          jq = document.createElement('script');
          jqMigrate = document.createElement('script');
          jq.type = jqMigrate.type = "text/javascript";
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 1 other location - About 1 day to fix
        public/javascripts/widgets/form_complete.js on lines 31..51

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

        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

        function bpMinVersion(min, actual) {
          function parseVersionString (str) {
            if (typeof(str) != 'string') { return false; }
            var x = str.split('.');
            var maj = parseInt(x[0]) || 0;
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 1 other location - About 1 day to fix
        public/javascripts/widgets/form_complete.js on lines 2..29

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

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

        function truncateText(text, max_length) {
            if (typeof max_length === 'undefined' || max_length == "") {
                max_length = 70;
            }
            var more = '...';
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 2 other locations - About 1 day to fix
        app/assets/javascripts/bp_form_complete.js on lines 211..239
        public/javascripts/widgets/form_complete.js on lines 364..392

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

        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 (BP_ontology_id !== "") {
                if (BP_include_definitions) {
                    resultDiv.append(definitionDiv(result_ont_version, result_uri));
                }
                resultDiv.append(resultClassDiv);
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 1 other location - About 7 hrs to fix
        public/javascripts/widgets/form_complete.js on lines 201..219

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

        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

        function getWidgetAjaxContent() {
            // Look for anchors with a get_via_ajax class and replace the parent with the resulting ajax call
            $(".get_definition_via_ajax").each(function() {
                var def_link = $(this);
                if (typeof def_link.attr("getting_content") === 'undefined') {
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 1 other location - About 6 hrs to fix
        public/javascripts/widgets/form_complete.js on lines 349..362

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

        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

        function getScript(url){
            return new Promise((resolve, reject) => {
                const script = document.createElement('script')
                script.src = url
                script.async = true
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 1 other location - About 6 hrs to fix
        public/javascripts/widgets/form_complete.js on lines 106..126

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

        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

            if (row[0].match(regex) == null) {
                var contents = row[6].split("\t");
                var synonym = contents[0] || "";
                synonym = synonym.split(";");
                if (synonym !== "") {
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 1 other location - About 5 hrs to fix
        public/javascripts/widgets/form_complete.js on lines 162..172

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

        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

        function definitionDiv(ont, concept) {
            var definitionAjax = jQuery("<a>");
            definitionAjax.addClass("get_definition_via_ajax");
            definitionAjax.attr("href", BP_SEARCH_SERVER + "/ajax/json_class?callback=?&ontologyid=" + ont + "&conceptid=" + encodeURIComponent(concept));
            var definitionDiv = jQuery("<div>");
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 1 other location - About 3 hrs to fix
        public/javascripts/widgets/form_complete.js on lines 223..232

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

        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 (row[0].indexOf("[obsolete]") != -1) {
                row[0] = row[0].replace("[obsolete]", "");
                obsolete_prefix = "<span class='obsolete_class' title='obsolete class'>";
                obsolete_suffix = "</span>";
            } else {
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 1 other location - About 2 hrs to fix
        public/javascripts/widgets/form_complete.js on lines 174..181

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

        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

            var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"), // .*+?|()[]{}\
                keywords = jQuery(jumpTo_searchBoxSelector).val().trim().replace(specials, "\\$&").split(' ').join('|'),
                regex = new RegExp('(' + keywords + ')', 'gi');
        Severity: Major
        Found in public/javascripts/widgets/quick_jump.js and 1 other location - About 2 hrs to fix
        public/javascripts/widgets/form_complete.js on lines 158..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 79.

        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