phpmyadmin/phpmyadmin

View on GitHub
resources/js/src/sql.ts

Summary

Maintainability
F
5 days
Test Coverage

File sql.ts has 963 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import $ from 'jquery';
import { AJAX } from './modules/ajax.ts';
import { Functions } from './modules/functions.ts';
import { Navigation } from './modules/navigation.ts';
import { CommonParams } from './modules/common.ts';
Severity: Major
Found in resources/js/src/sql.ts - About 2 days to fix

    Function insertQuery has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    const insertQuery = function (queryType) {
        var table;
        if (queryType === 'clear') {
            setQuery('');
    
    
    Severity: Minor
    Found in resources/js/src/sql.ts - About 4 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 insertQuery has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const insertQuery = function (queryType) {
        var table;
        if (queryType === 'clear') {
            setQuery('');
    
    
    Severity: Major
    Found in resources/js/src/sql.ts - About 3 hrs to fix

      Function browseForeignDialog has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function browseForeignDialog ($thisA) {
          var formId = '#browse_foreign_form';
          var showAllId = '#foreign_showAll';
          var tableId = '#browse_foreign_table';
          var filterId = '#input_foreign_filter';
      Severity: Major
      Found in resources/js/src/sql.ts - About 2 hrs to fix

        Function setShowThisQuery has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        function setShowThisQuery () {
            var db = $('input[name="db"]').val();
            var table = $('input[name="table"]').val();
            if (isStorageSupported('localStorage')) {
                if (window.localStorage.showThisQueryObject !== undefined) {
        Severity: Minor
        Found in resources/js/src/sql.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 insertValueQuery has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        const insertValueQuery = function () {
            // @ts-ignore
            var myQuery = document.sqlform.sql_query;
            // @ts-ignore
            var myListBox = document.sqlform.dummy;
        Severity: Minor
        Found in resources/js/src/sql.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 buildProfilingChart has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function buildProfilingChart () {
            const profilingChartCanvas = document.getElementById('profilingChartCanvas') as HTMLCanvasElement;
            if (! profilingChartCanvas) {
                return;
            }
        Severity: Minor
        Found in resources/js/src/sql.ts - About 1 hr to fix

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

          const insertValueQuery = function () {
              // @ts-ignore
              var myQuery = document.sqlform.sql_query;
              // @ts-ignore
              var myListBox = document.sqlform.dummy;
          Severity: Minor
          Found in resources/js/src/sql.ts - About 1 hr to fix

            Function initProfilingTables has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function initProfilingTables () {
                if (! $.tablesorter) {
                    return;
                }
            
            
            Severity: Minor
            Found in resources/js/src/sql.ts - About 1 hr to fix

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

                          success: function (response) {
                              ajaxRemoveMessage($msgbox);
                              if (response.success) {
                                  var dialogContent = '<div class="preview_sql">';
                                  if (response.sql_data) {
              Severity: Minor
              Found in resources/js/src/sql.ts - About 1 hr to fix

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

                const handleSimulateQueryButton = function (): void {
                    const updateRegExp = /^\s*UPDATE\b\s*(((`([^`]|``)+`)|([a-z0-9_$]+))\s*\.\s*)?((`([^`]|``)+`)|([a-z0-9_$]+))\s*\bSET\b/i;
                    const deleteRegExp = /^\s*DELETE\b\s*((((`([^`]|``)+`)|([a-z0-9_$]+))\s*\.\s*)?((`([^`]|``)+`)|([a-z0-9_$]+))\s*)?\bFROM\b/i;
                
                    const query = window.codeMirrorEditor ? window.codeMirrorEditor.getValue() : ($('#sqlquery').val() as string);
                Severity: Minor
                Found in resources/js/src/sql.ts - 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

                Avoid deeply nested control flow statements.
                Open

                                        if (data.table) {
                                            url = 'index.php?route=/table/sql';
                                        } else {
                                            url = 'index.php?route=/database/sql';
                                        }
                Severity: Major
                Found in resources/js/src/sql.ts - About 45 mins to fix

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

                  function initProfilingTables () {
                      if (! $.tablesorter) {
                          return;
                      }
                  
                  
                  Severity: Minor
                  Found in resources/js/src/sql.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

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

                      $('#profiletable').tablesorter({
                          widgets: ['zebra'],
                          sortList: [[0, 0]],
                          textExtraction: function (node) {
                              if (node.children.length > 0) {
                  Severity: Major
                  Found in resources/js/src/sql.ts and 1 other location - About 2 hrs to fix
                  resources/js/src/sql.ts on lines 1391..1401

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

                  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

                      $('#profilesummarytable').tablesorter({
                          widgets: ['zebra'],
                          sortList: [[1, 1]],
                          textExtraction: function (node) {
                              if (node.children.length > 0) {
                  Severity: Major
                  Found in resources/js/src/sql.ts and 1 other location - About 2 hrs to fix
                  resources/js/src/sql.ts on lines 1374..1384

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

                  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

                      $('body').on('click', 'a.browse_foreign', function (e) {
                          e.preventDefault();
                          Sql.browseForeignDialog($(this));
                      });
                  Severity: Minor
                  Found in resources/js/src/sql.ts and 1 other location - About 35 mins to fix
                  resources/js/src/modules/navigation/event-loader.ts on lines 159..162

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

                  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

                          $('.alert-success').each(function () {
                              textArea.value += $(this).text() + '\n\n';
                          });
                  Severity: Minor
                  Found in resources/js/src/sql.ts and 1 other location - About 35 mins to fix
                  resources/js/src/sql.ts on lines 615..617

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

                  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

                          $('.sql pre').each(function () {
                              textArea.value += $(this).text() + '\n\n';
                          });
                  Severity: Minor
                  Found in resources/js/src/sql.ts and 1 other location - About 35 mins to fix
                  resources/js/src/sql.ts on lines 611..613

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

                  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