phpmyadmin/phpmyadmin

View on GitHub
resources/js/src/table/change.ts

Summary

Maintainability
F
6 days
Test Coverage

File change.ts has 653 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import $ from 'jquery';
import { AJAX } from '../modules/ajax.ts';
import { Functions } from '../modules/functions.ts';

/**
Severity: Major
Found in resources/js/src/table/change.ts - About 1 day to fix

    Function addNewContinueInsertionFields has 159 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function addNewContinueInsertionFields (event) {
        event.preventDefault();
        /**
         * @var columnCount   Number of number of columns table has.
         */
    Severity: Major
    Found in resources/js/src/table/change.ts - About 6 hrs to fix

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

      function addNewContinueInsertionFields (event) {
          event.preventDefault();
          /**
           * @var columnCount   Number of number of columns table has.
           */
      Severity: Minor
      Found in resources/js/src/table/change.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 verificationsAfterFieldChange has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      function verificationsAfterFieldChange (urlField, multiEdit, theType) {
          var evt = window.event || arguments.callee.caller.arguments[0];
          var target = evt.target || evt.srcElement;
          var $thisInput = ($(':input[name^=\'fields[multi_edit][' + multiEdit + '][' +
              urlField + ']\']') as JQuery<HTMLInputElement>);
      Severity: Minor
      Found in resources/js/src/table/change.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 verificationsAfterFieldChange has 131 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function verificationsAfterFieldChange (urlField, multiEdit, theType) {
          var evt = window.event || arguments.callee.caller.arguments[0];
          var target = evt.target || evt.srcElement;
          var $thisInput = ($(':input[name^=\'fields[multi_edit][' + multiEdit + '][' +
              urlField + ']\']') as JQuery<HTMLInputElement>);
      Severity: Major
      Found in resources/js/src/table/change.ts - About 5 hrs to fix

        Function isDate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        function isDate (val, tmstmp = undefined) {
            var value = val.replace(/[.|*|^|+|//|@]/g, '-');
            var arrayVal = value.split('-');
            for (var a = 0; a < arrayVal.length; a++) {
                if (arrayVal[a].length === 1) {
        Severity: Minor
        Found in resources/js/src/table/change.ts - About 3 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

                var tempIncrementIndex = function () {
                    var $thisElement = $(this);
                    /**
                     * Extract the index from the name attribute for all input/select fields and increment it
                     * name is of format funcs[multi_edit][10][<long random string of alphanum chars>]
        Severity: Major
        Found in resources/js/src/table/change.ts - About 2 hrs to fix

          Function verifyAfterSearchFieldChange has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function verifyAfterSearchFieldChange (index, searchFormId) {
              var $thisInput = $('input[name=\'criteriaValues[' + index + ']\']');
              // Add  data-skip-validators attribute to skip validation in changeValueFieldType function
              if ($('#fieldID_' + index).data('data-skip-validators')) {
                  $(searchFormId).validate().destroy();
          Severity: Major
          Found in resources/js/src/table/change.ts - About 2 hrs to fix

            Function nullify has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            function nullify (theType, urlField, md5Field, multiEdit) {
                // @ts-ignore
                var rowForm = document.forms.insertForm;
            
                if (typeof (rowForm.elements['funcs' + multiEdit + '[' + md5Field + ']']) !== 'undefined') {
            Severity: Minor
            Found in resources/js/src/table/change.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 isDate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function isDate (val, tmstmp = undefined) {
                var value = val.replace(/[.|*|^|+|//|@]/g, '-');
                var arrayVal = value.split('-');
                for (var a = 0; a < arrayVal.length; a++) {
                    if (arrayVal[a].length === 1) {
            Severity: Minor
            Found in resources/js/src/table/change.ts - About 1 hr to fix

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

              function validateIntField (jqueryInput, returnValueIfIsNumber): void {
                  var mini = parseInt(jqueryInput.data('min'));
                  var maxi = parseInt(jqueryInput.data('max'));
                  // removing previous rules
                  jqueryInput.rules('remove');
              Severity: Minor
              Found in resources/js/src/table/change.ts - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                            if (year > 2038 || (year > 2037 && day > 19 && month >= 1) || (year > 2037 && month > 1)) {
                                return false;
                            }
                Severity: Major
                Found in resources/js/src/table/change.ts - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if (target.value === 'AES_ENCRYPT' ||
                          target.value === 'AES_DECRYPT' ||
                          target.value === 'DES_ENCRYPT' ||
                          target.value === 'DES_DECRYPT' ||
                          target.value === 'ENCRYPT' ||
                  Severity: Major
                  Found in resources/js/src/table/change.ts - About 40 mins to fix

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

                    function verifyAfterSearchFieldChange (index, searchFormId) {
                        var $thisInput = $('input[name=\'criteriaValues[' + index + ']\']');
                        // Add  data-skip-validators attribute to skip validation in changeValueFieldType function
                        if ($('#fieldID_' + index).data('data-skip-validators')) {
                            $(searchFormId).validate().destroy();
                    Severity: Minor
                    Found in resources/js/src/table/change.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

                    Avoid too many return statements within this function.
                    Open

                        return true;
                    Severity: Major
                    Found in resources/js/src/table/change.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return isDate(dtValue.substring(0, dv), tmstmp) &&
                                          isTime(dtValue.substring(dv + 1));
                      Severity: Major
                      Found in resources/js/src/table/change.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                            return isDate(dtValue, tmstmp);
                        Severity: Major
                        Found in resources/js/src/table/change.ts - About 30 mins to fix

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

                          function validateIntField (jqueryInput, returnValueIfIsNumber): void {
                              var mini = parseInt(jqueryInput.data('min'));
                              var maxi = parseInt(jqueryInput.data('max'));
                              // removing previous rules
                              jqueryInput.rules('remove');
                          Severity: Minor
                          Found in resources/js/src/table/change.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

                                  if (target.value === 'MD5') {
                                      $('#' + target.id).rules('add', {
                                          validationFunctionForMd5: {
                                              param: $thisInput,
                                              depends: function () {
                          Severity: Major
                          Found in resources/js/src/table/change.ts and 1 other location - About 1 hr to fix
                          resources/js/src/table/change.ts on lines 386..395

                          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

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

                                  if (target.value === 'DES_ENCRYPT' || target.value === 'AES_ENCRYPT') {
                                      $('#' + target.id).rules('add', {
                                          validationFunctionForAesDesEncrypt: {
                                              param: $thisInput,
                                              depends: function () {
                          Severity: Major
                          Found in resources/js/src/table/change.ts and 1 other location - About 1 hr to fix
                          resources/js/src/table/change.ts on lines 375..384

                          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

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

                                  max: {
                                      param: maxi,
                                      depends: function () {
                                          if (isNaN(jqueryInput.val())) {
                                              return false;
                          Severity: Minor
                          Found in resources/js/src/table/change.ts and 1 other location - About 40 mins to fix
                          resources/js/src/table/change.ts on lines 282..291

                          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

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

                                  min: {
                                      param: mini,
                                      depends: function () {
                                          if (isNaN(jqueryInput.val())) {
                                              return false;
                          Severity: Minor
                          Found in resources/js/src/table/change.ts and 1 other location - About 40 mins to fix
                          resources/js/src/table/change.ts on lines 292..301

                          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

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

                                  $.validator.addMethod('validationFunctionForMultipleInt', function (value) {
                                      return value.match(/^((([+-]|0x)?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?(,|$))+)$/i) !== null;
                                  }, window.Messages.strEnterValidNumber);
                          Severity: Minor
                          Found in resources/js/src/table/change.ts and 1 other location - About 30 mins to fix
                          resources/js/src/table/change.ts on lines 521..523

                          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

                                  $.validator.addMethod('validationFunctionForInt', function (value) {
                                      return value.match(/^([+-]|0x)?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$/i) !== null;
                                  }, window.Messages.strEnterValidNumber);
                          Severity: Minor
                          Found in resources/js/src/table/change.ts and 1 other location - About 30 mins to fix
                          resources/js/src/table/change.ts on lines 528..530

                          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