phpmyadmin/phpmyadmin

View on GitHub
resources/js/src/modules/navigation.ts

Summary

Maintainability
F
1 wk
Test Coverage

File navigation.ts has 998 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import $ from 'jquery';
import { CommonParams } from './common.ts';
import { Config } from './config.ts';
import { ajaxRemoveMessage, ajaxShowMessage } from './ajax-message.ts';
import updateNavigationWidthConfig from './navigation/updateNavigationWidthConfig.ts';
Severity: Major
Found in resources/js/src/modules/navigation.ts - About 2 days to fix

    Function showCurrent has 176 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function showCurrent (): void {
        var db = CommonParams.get('db');
        var table = CommonParams.get('table');
    
        var autoexpand = $('#pma_navigation_tree').hasClass('autoexpand');
    Severity: Major
    Found in resources/js/src/modules/navigation.ts - About 7 hrs to fix

      Function ResizeHandler has 149 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const ResizeHandler = function () {
          /**
           * @var {number} panelWidth Used by the collapser to know where to go
           *                      back to when uncollapsing the panel
           */
      Severity: Major
      Found in resources/js/src/modules/navigation.ts - About 5 hrs to fix

        Function showCurrent has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

        function showCurrent (): void {
            var db = CommonParams.get('db');
            var table = CommonParams.get('table');
        
            var autoexpand = $('#pma_navigation_tree').hasClass('autoexpand');
        Severity: Minor
        Found in resources/js/src/modules/navigation.ts - About 5 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 ResizeHandler has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        const ResizeHandler = function () {
            /**
             * @var {number} panelWidth Used by the collapser to know where to go
             *                      back to when uncollapsing the panel
             */
        Severity: Minor
        Found in resources/js/src/modules/navigation.ts - About 5 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 loadChildNodes has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function loadChildNodes (isNode, $expandElem, callback): void {
            var $destination = null;
            var params = null;
        
            if (isNode) {
        Severity: Major
        Found in resources/js/src/modules/navigation.ts - About 3 hrs to fix

          Function keyup has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

                  keyup: function (event) {
                      var $obj = $(this).closest('div.list_container');
                      var str = '';
                      if ($(this).val() !== this.defaultValue && $(this).val() !== '') {
                          $obj.find('div.pageselector').hide();
          Severity: Minor
          Found in resources/js/src/modules/navigation.ts - 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 keyup has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  keyup: function (event) {
                      var $obj = $(this).closest('div.list_container');
                      var str = '';
                      if ($(this).val() !== this.defaultValue && $(this).val() !== '') {
                          $obj.find('div.pageselector').hide();
          Severity: Major
          Found in resources/js/src/modules/navigation.ts - About 2 hrs to fix

            Function treePagination has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function treePagination ($this): void {
                var $msgbox = ajaxShowMessage();
                var isDbSelector = $this.closest('div.pageselector').is('.dbselector');
                var url = 'index.php?route=/navigation';
                var params = 'ajax_request=true';
            Severity: Major
            Found in resources/js/src/modules/navigation.ts - About 2 hrs to fix

              Function setWidth has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  this.setWidth = function (position): void {
                      var pos = position;
                      if (typeof pos !== 'number') {
                          pos = 240;
                      }
              Severity: Minor
              Found in resources/js/src/modules/navigation.ts - About 1 hr to fix

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

                function filterStateRestore (): void {
                    if (isStorageSupported('sessionStorage')
                        && typeof window.sessionStorage.navTreeSearchFilters !== 'undefined'
                    ) {
                        var searchClauses = JSON.parse(window.sessionStorage.navTreeSearchFilters);
                Severity: Minor
                Found in resources/js/src/modules/navigation.ts - About 1 hr to fix

                  Function expandTreeNode has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function expandTreeNode ($expandElem, callback = undefined): void {
                      var $children = $expandElem.closest('li').children('div.list_container');
                      var $icon = $expandElem.find('img');
                      if ($expandElem.hasClass('loaded')) {
                          if ($icon.is('.ic_b_plus')) {
                  Severity: Minor
                  Found in resources/js/src/modules/navigation.ts - About 1 hr to fix

                    Function request has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    FastFilter.Filter.prototype.request = function (): void {
                        var self = this;
                        if (self.$this.find('li.fast_filter').find('img.throbber').length === 0) {
                            self.$this.find('li.fast_filter').append(
                                $('<div class="throbber"></div>').append(
                    Severity: Minor
                    Found in resources/js/src/modules/navigation.ts - About 1 hr to fix

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

                          function loadAndHighlightTableOrView ($dbItem, itemName) {
                              var $container = $dbItem.children('div.list_container');
                              var $expander;
                              var $whichItem = isItemInContainer($container, itemName, 'li.nav_node_table, li.view');
                              // If item already there in some container
                      Severity: Minor
                      Found in resources/js/src/modules/navigation.ts - About 1 hr to fix

                        Function findLoadedItem has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            function findLoadedItem ($container, name, clazz, doSelect) {
                                var ret: any = false;
                                $container.children('ul').children('li').each(function () {
                                    var $li = $(this);
                                    // this is a navigation group, recurse
                        Severity: Minor
                        Found in resources/js/src/modules/navigation.ts - About 1 hr to fix

                          Function showFullName has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function showFullName ($containerELem): void {
                              $containerELem.find('.hover_show_full').on('mouseenter', function () {
                                  /** mouseenter */
                                  var $this = $(this);
                                  var thisOffset = $this.offset();
                          Severity: Minor
                          Found in resources/js/src/modules/navigation.ts - About 1 hr to fix

                            Function traverseForPaths has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function traverseForPaths () {
                                var params = {
                                    pos: $('#pma_navigation_tree').find('div.dbselector select').val()
                                };
                                if ($('#navi_db_select').length) {
                            Severity: Minor
                            Found in resources/js/src/modules/navigation.ts - About 1 hr to fix

                              Function reload has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function reload (callback = null, paths = null): void {
                                  var params: { server: any; reload: boolean; no_debug: boolean, db?: string } = {
                                      'reload': true,
                                      'no_debug': true,
                                      'server': CommonParams.get('server'),
                              Severity: Minor
                              Found in resources/js/src/modules/navigation.ts - About 1 hr to fix

                                Function filterStateRestore has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function filterStateRestore (): void {
                                    if (isStorageSupported('sessionStorage')
                                        && typeof window.sessionStorage.navTreeSearchFilters !== 'undefined'
                                    ) {
                                        var searchClauses = JSON.parse(window.sessionStorage.navTreeSearchFilters);
                                Severity: Minor
                                Found in resources/js/src/modules/navigation.ts - 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 request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                FastFilter.Filter.prototype.request = function (): void {
                                    var self = this;
                                    if (self.$this.find('li.fast_filter').find('img.throbber').length === 0) {
                                        self.$this.find('li.fast_filter').append(
                                            $('<div class="throbber"></div>').append(
                                Severity: Minor
                                Found in resources/js/src/modules/navigation.ts - 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 treePagination has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function treePagination ($this): void {
                                    var $msgbox = ajaxShowMessage();
                                    var isDbSelector = $this.closest('div.pageselector').is('.dbselector');
                                    var url = 'index.php?route=/navigation';
                                    var params = 'ajax_request=true';
                                Severity: Minor
                                Found in resources/js/src/modules/navigation.ts - 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 loadChildNodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function loadChildNodes (isNode, $expandElem, callback): void {
                                    var $destination = null;
                                    var params = null;
                                
                                    if (isNode) {
                                Severity: Minor
                                Found in resources/js/src/modules/navigation.ts - 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

                                Function expandTreeNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function expandTreeNode ($expandElem, callback = undefined): void {
                                    var $children = $expandElem.closest('li').children('div.list_container');
                                    var $icon = $expandElem.find('img');
                                    if ($expandElem.hasClass('loaded')) {
                                        if ($icon.is('.ic_b_plus')) {
                                Severity: Minor
                                Found in resources/js/src/modules/navigation.ts - 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

                                        var $throbber = $('#pma_navigation').find('.throbber')
                                            .first()
                                            .clone()
                                            .css({ visibility: 'visible', display: 'block' })
                                            .on('click', false);
                                Severity: Major
                                Found in resources/js/src/modules/navigation.ts and 1 other location - About 1 hr to fix
                                resources/js/src/database/structure.ts on lines 160..164

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

                                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

                                                $parent.find('span.pos3_value').first().text(
                                                    $parent.find('span.pos3_value').last().text()
                                                );
                                Severity: Minor
                                Found in resources/js/src/modules/navigation.ts and 1 other location - About 40 mins to fix
                                resources/js/src/modules/navigation.ts on lines 742..744

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

                                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

                                                $parent.find('span.pos2_value').first().text(
                                                    $parent.find('span.pos2_value').last().text()
                                                );
                                Severity: Minor
                                Found in resources/js/src/modules/navigation.ts and 1 other location - About 40 mins to fix
                                resources/js/src/modules/navigation.ts on lines 746..748

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

                                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 ($icon.is('.ic_b_minus')) {
                                            $icon.removeClass('ic_b_minus').addClass('ic_b_plus');
                                            $children.slideUp('fast');
                                        }
                                Severity: Minor
                                Found in resources/js/src/modules/navigation.ts and 1 other location - About 30 mins to fix
                                resources/js/src/modules/navigation.ts on lines 289..292

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

                                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 ($icon.is('.ic_b_plus')) {
                                            $icon.removeClass('ic_b_plus').addClass('ic_b_minus');
                                            $children.slideDown('fast');
                                        }
                                Severity: Minor
                                Found in resources/js/src/modules/navigation.ts and 1 other location - About 30 mins to fix
                                resources/js/src/modules/navigation.ts on lines 222..225

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

                                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