Admidio/admidio

View on GitHub
adm_program/system/js/common_functions.js

Summary

Maintainability
F
4 days
Test Coverage

Function formSubmit has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

function formSubmit(event) {
    var submitButtonID = $("#" + $(this).attr("id") + " button[type=submit]").attr("id");
    var submitButtonIcon = $("#" + submitButtonID + " i");
    var iconClass = submitButtonIcon.attr("class");
    var formAlert = $("#" + $(this).attr("id") + " .form-alert");
Severity: Minor
Found in adm_program/system/js/common_functions.js - 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 formSubmit has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function formSubmit(event) {
    var submitButtonID = $("#" + $(this).attr("id") + " button[type=submit]").attr("id");
    var submitButtonIcon = $("#" + submitButtonID + " i");
    var iconClass = submitButtonIcon.attr("class");
    var formAlert = $("#" + $(this).attr("id") + " .form-alert");
Severity: Major
Found in adm_program/system/js/common_functions.js - About 2 hrs to fix

    Function callUrlHideElement has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function callUrlHideElement(elementId, url, csrfToken, callback) {
        var entryDeleted = document.getElementById(elementId);
        if (!entryDeleted) {
            entryDeleted = document.getElementById("row_" + elementId);
        }
    Severity: Major
    Found in adm_program/system/js/common_functions.js - About 2 hrs to fix

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

      function formatPhpToLuxon(format) {
          const formatMap = {
              d: "dd",
              D: "ccc",
              j: "d",
      Severity: Major
      Found in adm_program/system/js/common_functions.js - About 2 hrs to fix

        File common_functions.js has 253 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         ***********************************************************************************************
         * Common JavaScript functions that are used in multiple Admidio scripts.
         *
         * @copyright The Admidio Team
        Severity: Minor
        Found in adm_program/system/js/common_functions.js - About 2 hrs to fix

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

                  success: function(data) {
                      try {
                          var returnData = JSON.parse(data);
                          var returnStatus = returnData.status;
                          var returnMessage = "";
          Severity: Minor
          Found in adm_program/system/js/common_functions.js - About 1 hr to fix

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

            function moveTableRow(direction, elementId, updateSequenceUrl, csrfToken) {
                $.post(updateSequenceUrl + "?mode=sequence&uuid=" + elementId + "&direction=" + direction, {
                        "admidio-csrf-token": csrfToken,
                        "direction": direction,
                        "uuid": elementId,
            Severity: Minor
            Found in adm_program/system/js/common_functions.js - About 1 hr to fix

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

                              setTimeout(function(){
                                      $("#admidio-modal").modal("hide");
                                      if (callback === "callbackRoles") {
                                          $(entryDeleted).fadeOut("slow", callbackRoles);
                                      } else if (callback === "callbackFormerRoles") {
              Severity: Major
              Found in adm_program/system/js/common_functions.js and 1 other location - About 5 hrs to fix
              adm_program/system/js/common_functions.js on lines 86..99

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

              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

                          } else {
                              $("#admidio-modal").modal("hide");
                              if (callback === 'callbackRoles') {
                                  $(entryDeleted).fadeOut("slow", callbackRoles);
                              } else if (callback === 'callbackFormerRoles') {
              Severity: Major
              Found in adm_program/system/js/common_functions.js and 1 other location - About 5 hrs to fix
              adm_program/system/js/common_functions.js on lines 72..85

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

              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

                      try {
                          const returnData = JSON.parse(data);
                          returnStatus = returnData.status;
                          if (typeof returnData.message !== 'undefined') {
                              returnMessage = returnData.message;
              Severity: Major
              Found in adm_program/system/js/common_functions.js and 1 other location - About 3 hrs to fix
              adm_program/system/js/common_functions.js on lines 216..229

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

              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

                          try {
                              const returnData = JSON.parse(data);
                              returnStatus = returnData.status;
                              if (typeof returnData.message !== 'undefined') {
                                  returnMessage = returnData.message;
              Severity: Major
              Found in adm_program/system/js/common_functions.js and 1 other location - About 3 hrs to fix
              adm_program/system/js/common_functions.js on lines 54..67

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

              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($("#"+showHideElementId).is(":hidden")) {
                      $("#"+showHideElementId).show("slow");
                      $('#'+elementId+" .bi").attr("class", "bi bi-caret-down-fill")
                  } else {
              Severity: Minor
              Found in adm_program/system/js/common_functions.js and 1 other location - About 35 mins to fix
              adm_program/system/js/common_functions.js on lines 23..26

              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

                  } else {
                      $("#"+showHideElementId).hide("slow");
                      $('#'+elementId+" .bi").attr("class", "bi bi-caret-right-fill")
                  }
              Severity: Minor
              Found in adm_program/system/js/common_functions.js and 1 other location - About 35 mins to fix
              adm_program/system/js/common_functions.js on lines 20..23

              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