phpmyadmin/phpmyadmin

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

Summary

Maintainability
F
6 days
Test Coverage

File indexes.ts has 581 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Function on has 182 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function on () {
        return function () {
            Indexes.resetColumnLists();
    
            // for table creation form
    Severity: Major
    Found in resources/js/src/modules/indexes.ts - About 7 hrs to fix

      Function showAddIndexDialog has 100 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function showAddIndexDialog (sourceArray, arrayIndex, targetColumns, colIndex, index, showDialog = undefined): void {
          var showDialogLocal = typeof showDialog !== 'undefined' ? showDialog : true;
          // Prepare post-data.
          var $table = $('input[name="table"]');
          var table = $table.length > 0 ? $table.val() : '';
      Severity: Major
      Found in resources/js/src/modules/indexes.ts - About 4 hrs to fix

        Function indexTypeSelectionDialog has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function indexTypeSelectionDialog (sourceArray, indexChoice, colIndex): void {
            var $singleColumnRadio = $('<div class="form-check">' +
                '<input class="form-check-input" type="radio" id="single_column" name="index_choice" checked="checked">' +
                '<label class="form-check-label" for="single_column">' +
                window.Messages.strCreateSingleColumnIndex + '</label></div>');
        Severity: Major
        Found in resources/js/src/modules/indexes.ts - About 2 hrs to fix

          Function removeColumnFromIndex has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          function removeColumnFromIndex (colIndex): void {
              // Get previous index details.
              var previousIndex = $('select[name="field_key[' + colIndex + ']"]')
                  .attr('data-index');
              if (previousIndex.length) {
          Severity: Minor
          Found in resources/js/src/modules/indexes.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 addColumnToIndex has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function addColumnToIndex (sourceArray, arrayIndex, indexChoice, colIndex): void {
              if (colIndex >= 0) {
                  // Remove column from other indexes (if any).
                  Indexes.removeColumnFromIndex(colIndex);
              }
          Severity: Minor
          Found in resources/js/src/modules/indexes.ts - About 1 hr to fix

            Function getCompositeIndexList has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getCompositeIndexList (sourceArray, colIndex) {
                // Remove any previous list.
                if ($('#composite_index_list').length) {
                    $('#composite_index_list').remove();
                }
            Severity: Minor
            Found in resources/js/src/modules/indexes.ts - About 1 hr to fix

              Function getCompositeIndexList has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function getCompositeIndexList (sourceArray, colIndex) {
                  // Remove any previous list.
                  if ($('#composite_index_list').length) {
                      $('#composite_index_list').remove();
                  }
              Severity: Minor
              Found in resources/js/src/modules/indexes.ts - About 55 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 showAddIndexDialog has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function showAddIndexDialog (sourceArray, arrayIndex, targetColumns, colIndex, index, showDialog = undefined): void {
              Severity: Minor
              Found in resources/js/src/modules/indexes.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if (sourceArray[previousIndexes[1]].columns[i].col_index === colIndex) {
                                        sourceArray[previousIndexes[1]].columns.splice(i, 1);
                                    }
                Severity: Major
                Found in resources/js/src/modules/indexes.ts - About 45 mins to fix

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

                          if (! $selectList.attr('data-index').length) {
                              $selectList.find('option[value*="none"]').attr('selected', 'selected');
                          } else {
                              var previousIndex = $selectList.attr('data-index').split(',');
                              $selectList.find('option[value*="' + previousIndex[0].toLowerCase() + '"]')
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 1 other location - About 3 hrs to fix
                  resources/js/src/modules/indexes.ts on lines 333..339

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

                  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 (! $selectList.attr('data-index').length) {
                                  $selectList.find('option[value*="none"]').attr('selected', 'selected');
                              } else {
                                  var previousIndex = $selectList.attr('data-index').split(',');
                                  $selectList.find('option[value*="' + previousIndex[0].toLowerCase() + '"]')
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 1 other location - About 3 hrs to fix
                  resources/js/src/modules/indexes.ts on lines 493..499

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

                  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

                              Functions.indexRenameDialog(url, title, function (data) {
                                  Navigation.update(CommonParams.set('db', data.params.db));
                                  Navigation.update(CommonParams.set('table', data.params.table));
                                  refreshMainContent('index.php?route=/table/structure');
                              });
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 1 other location - About 2 hrs to fix
                  resources/js/src/modules/indexes.ts on lines 677..681

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

                  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

                              Functions.indexEditorDialog(url, title, function (data) {
                                  Navigation.update(CommonParams.set('db', data.params.db));
                                  Navigation.update(CommonParams.set('table', data.params.table));
                                  refreshMainContent('index.php?route=/table/structure');
                              });
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 1 other location - About 2 hrs to fix
                  resources/js/src/modules/indexes.ts on lines 692..696

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

                  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 (! isMissingValue) {
                          Indexes.addColumnToIndex(
                              sourceArray,
                              arrayIndex,
                              index.Index_choice,
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 1 other location - About 1 hr to fix
                  resources/js/src/modules/indexes.ts on lines 400..415

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

                  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 (! isMissingValue) {
                                      Indexes.addColumnToIndex(
                                          sourceArray,
                                          arrayIndex,
                                          index.Index_choice,
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 1 other location - About 1 hr to fix
                  resources/js/src/modules/indexes.ts on lines 271..286

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

                  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

                  const Indexes = {
                      resetColumnLists: resetColumnLists,
                      getIndexArray: getIndexArray,
                      setIndexFormParameters: setIndexFormParameters,
                      removeColumnFromIndex: removeColumnFromIndex,
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 1 other location - About 1 hr to fix
                  resources/js/src/designer/database.ts on lines 233..244

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

                  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

                              for (var i = 0; i < sourceLength; i++) {
                                  targetColumns.push(sourceArray[arrayIndex].columns[i].col_index);
                              }
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 2 other locations - About 45 mins to fix
                  resources/js/src/modules/indexes.ts on lines 745..747
                  resources/js/src/modules/indexes.ts on lines 779..781

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

                  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

                                  for (var i = 0; i < sourceLength; i++) {
                                      targetColumns.push(sourceArray[arrayIndex].columns[i].col_index);
                                  }
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 2 other locations - About 45 mins to fix
                  resources/js/src/modules/indexes.ts on lines 477..479
                  resources/js/src/modules/indexes.ts on lines 745..747

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

                  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

                                      for (var i = 0; i < sourceLength; i++) {
                                          targetColumns.push(sourceArray[arrayIndex].columns[i].col_index);
                                      }
                  Severity: Major
                  Found in resources/js/src/modules/indexes.ts and 2 other locations - About 45 mins to fix
                  resources/js/src/modules/indexes.ts on lines 477..479
                  resources/js/src/modules/indexes.ts on lines 779..781

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

                  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

                      $('select[name="index[columns][names][]"]').each(function () {
                          if ($(this).val() === '') {
                              isMissingValue = true;
                          }
                      });
                  Severity: Minor
                  Found in resources/js/src/modules/indexes.ts and 1 other location - About 40 mins to fix
                  resources/js/src/modules/indexes.ts on lines 394..398

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

                  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

                                  $('select[name="index[columns][names][]"]').each(function () {
                                      if ($(this).val() === '') {
                                          isMissingValue = true;
                                      }
                                  });
                  Severity: Minor
                  Found in resources/js/src/modules/indexes.ts and 1 other location - About 40 mins to fix
                  resources/js/src/modules/indexes.ts on lines 265..269

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

                  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