phpmyadmin/phpmyadmin

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

Summary

Maintainability
F
3 days
Test Coverage

File config.ts has 544 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import $ from 'jquery';
import { CommonParams } from './common.ts';
import { ajaxShowMessage } from './ajax-message.ts';
import isStorageSupported from './functions/isStorageSupported.ts';
import formatDateTime from './functions/formatDateTime.ts';
Severity: Major
Found in resources/js/src/modules/config.ts - About 1 day to fix

    Function displayErrors has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    function displayErrors (errorList) {
        var tempIsEmpty = function (item) {
            return item !== '';
        };
    
    
    Severity: Minor
    Found in resources/js/src/modules/config.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 on has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function on () {
        return function () {
            var $topmenuUpt = $('#user_prefs_tabs');
            $topmenuUpt.find('a.active').attr('rel', 'samepage');
            $topmenuUpt.find('a:not(.active)').attr('rel', 'newpage');
    Severity: Major
    Found in resources/js/src/modules/config.ts - About 2 hrs to fix

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

      function checkFieldDefault (field, type) {
          var $field = $(field);
          var fieldId = $field.attr('id');
          if (typeof window.defaultValues[fieldId] === 'undefined') {
              return true;
      Severity: Minor
      Found in resources/js/src/modules/config.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 displayErrors has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function displayErrors (errorList) {
          var tempIsEmpty = function (item) {
              return item !== '';
          };
      
      
      Severity: Minor
      Found in resources/js/src/modules/config.ts - About 1 hr to fix

        Function setupValidation has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function setupValidation () {
            validate = {};
            window.configScriptLoaded = true;
            if (window.configScriptLoaded && typeof window.configInlineParams !== 'undefined') {
                Config.loadInlineConfig();
        Severity: Minor
        Found in resources/js/src/modules/config.ts - About 1 hr to fix

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

          function savePrefsToLocalStorage (form) {
              var $form = $(form);
              var submit = $form.find('input[type=submit]');
              submit.prop('disabled', true);
              $.ajax({
          Severity: Minor
          Found in resources/js/src/modules/config.ts - About 1 hr to fix

            Function offerPrefsAutoimport has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function offerPrefsAutoimport () {
                var hasConfig = (isStorageSupported('localStorage')) && (window.localStorage.config || false);
                var $cnt = $('#prefs_autoload');
                if (! $cnt.length || ! hasConfig) {
                    return;
            Severity: Minor
            Found in resources/js/src/modules/config.ts - About 1 hr to fix

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

              function validateField (field, isKeyUp, errors) {
                  var args;
                  var result;
                  var $field = $(field);
                  var fieldId = $field.attr('id');
              Severity: Minor
              Found in resources/js/src/modules/config.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 validateFieldset has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function validateFieldset (fieldset, isKeyUp, errors) {
                  var $fieldset = $(fieldset);
                  if ($fieldset.length && typeof window.validators.fieldset[$fieldset.attr('id')] !== 'undefined') {
                      var fieldsetErrors = window.validators.fieldset[$fieldset.attr('id')].apply($fieldset[0], [isKeyUp]);
                      for (var fieldId in fieldsetErrors) {
              Severity: Minor
              Found in resources/js/src/modules/config.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 getFieldValidators has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function getFieldValidators (fieldId, onKeyUpOnly) {
                  // look for field bound validator
                  var name = fieldId && fieldId.match(/[^-]+$/)[0];
                  if (typeof window.validators.field[name] !== 'undefined') {
                      return [[window.validators.field[name], null]];
              Severity: Minor
              Found in resources/js/src/modules/config.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 getFieldValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function getFieldValue (field, fieldType) {
                  var $field = $(field);
                  switch (fieldType) {
                  case 'text':
                  case 'number':
              Severity: Minor
              Found in resources/js/src/modules/config.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 getAllValues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function getAllValues () {
                  var $elements = $('fieldset input, fieldset select, fieldset textarea') as JQuery<HTMLInputElement>;
                  var values = {};
                  var type;
                  var value;
              Severity: Minor
              Found in resources/js/src/modules/config.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 setupValidation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function setupValidation () {
                  validate = {};
                  window.configScriptLoaded = true;
                  if (window.configScriptLoaded && typeof window.configInlineParams !== 'undefined') {
                      Config.loadInlineConfig();
              Severity: Minor
              Found in resources/js/src/modules/config.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

              There are no issues that match your filters.

              Category
              Status