phpmyadmin/phpmyadmin

View on GitHub
resources/js/src/database/events.ts

Summary

Maintainability
F
2 wks
Test Coverage

Function editorDialog has 131 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    editorDialog: function (isNew, $this) {
        var that = this;
        /**
         * @var $edit_row jQuery object containing the reference to
         *                the row of the the item being edited
Severity: Major
Found in resources/js/src/database/events.ts - About 5 hrs to fix

    File events.ts has 372 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 { ajaxRemoveMessage, ajaxShowMessage } from '../modules/ajax-message.ts';
    Severity: Minor
    Found in resources/js/src/database/events.ts - About 4 hrs to fix

      Function click has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  buttonOptions[window.Messages.strGo].click = function () {
                      // Move the data from the codemirror editor back to the
                      // textarea, where it can be used in the form submission.
                      if (typeof window.CodeMirror !== 'undefined') {
                          that.syntaxHiglighter.save();
      Severity: Major
      Found in resources/js/src/database/events.ts - About 2 hrs to fix

        Function exportDialog has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            exportDialog: function ($this) {
                var $msg = ajaxShowMessage();
                if ($this.attr('id') === 'bulkActionExportButton') {
                    var combined = {
                        success: true,
        Severity: Major
        Found in resources/js/src/database/events.ts - About 2 hrs to fix

          Function dropMultipleDialog has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              dropMultipleDialog: function ($this) {
                  // We ask for confirmation here
                  $this.confirm(window.Messages.strDropRTEitems, '', function () {
                      /**
                       * @var msg jQuery object containing the reference to
          Severity: Minor
          Found in resources/js/src/database/events.ts - About 1 hr to fix

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

                dropDialog: function ($this) {
                    /**
                     * @var $curr_row Object containing reference to the current row
                     */
                    var $currRow = $this.parents('tr');
            Severity: Minor
            Found in resources/js/src/database/events.ts - About 1 hr to fix

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

                  validateCustom: function () {
                      /**
                       * @var elm a jQuery object containing the reference
                       *          to an element that is being validated
                       */
              Severity: Minor
              Found in resources/js/src/database/events.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

                                  $.post(url, data, function (data) {
                                      if (data.success !== true) {
                                          ajaxShowMessage(data.error, false);
              
                                          return;
              Severity: Major
              Found in resources/js/src/database/events.ts and 1 other location - About 3 days to fix
              resources/js/src/triggers.ts on lines 224..330

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

              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

                  dropMultipleDialog: function ($this) {
                      // We ask for confirmation here
                      $this.confirm(window.Messages.strDropRTEitems, '', function () {
                          /**
                           * @var msg jQuery object containing the reference to
              Severity: Major
              Found in resources/js/src/database/events.ts and 1 other location - About 3 days to fix
              resources/js/src/triggers.ts on lines 474..560

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

              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

                  dropDialog: function ($this) {
                      /**
                       * @var $curr_row Object containing reference to the current row
                       */
                      var $currRow = $this.parents('tr');
              Severity: Major
              Found in resources/js/src/database/events.ts and 1 other location - About 2 days to fix
              resources/js/src/triggers.ts on lines 399..472

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

              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

                          that.$ajaxDialog = $('<div id="rteDialog">' + data.message + '</div>').dialog({
                              classes: {
                                  'ui-dialog-titlebar-close': 'btn-close'
                              },
                              height: 500,
              Severity: Major
              Found in resources/js/src/database/events.ts and 1 other location - About 2 days to fix
              resources/js/src/database/routines.ts on lines 348..382

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

              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 ($this.attr('id') === 'bulkActionExportButton') {
                          var combined = {
                              success: true,
                              title: window.Messages.strExport,
                              message: '',
              Severity: Major
              Found in resources/js/src/database/events.ts and 1 other location - About 1 day to fix
              resources/js/src/triggers.ts on lines 77..112

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

              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

                      function showExport (data) {
                          if (data.success !== true) {
                              ajaxShowMessage(data.error, false);
              
                              return;
              Severity: Major
              Found in resources/js/src/database/events.ts and 1 other location - About 1 day to fix
              resources/js/src/database/routines.ts on lines 123..164

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

              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

                  validate: function () {
                      /**
                       * @var $elm a jQuery object containing the reference
                       *           to an element that is being validated
                       */
              Severity: Major
              Found in resources/js/src/database/events.ts and 2 other locations - About 1 day to fix
              resources/js/src/database/routines.ts on lines 42..74
              resources/js/src/triggers.ts on lines 31..63

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

              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

                  $(document).on('click', 'a.ajax.add_anchor, a.ajax.edit_anchor', function (event) {
                      event.preventDefault();
              
                      if ($(this).hasClass('add_anchor')) {
                          // @ts-ignore
              Severity: Major
              Found in resources/js/src/database/events.ts and 1 other location - About 3 hrs to fix
              resources/js/src/triggers.ts on lines 567..576

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

              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 {
                          // The execute_at field must not be empty for "once off" events
                          $elm = this.$ajaxDialog.find('input[name=item_execute_at]');
                          if ($elm.val() === '') {
                              $elm.trigger('focus');
              Severity: Major
              Found in resources/js/src/database/events.ts and 1 other location - About 1 hr to fix
              resources/js/src/database/events.ts on lines 564..573

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

              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 (this.$ajaxDialog.find('select[name=item_type]').find(':selected').val() === 'RECURRING') {
                          // The interval field must not be empty for recurring events
                          $elm = this.$ajaxDialog.find('input[name=item_interval_value]');
                          if ($elm.val() === '') {
                              $elm.trigger('focus');
              Severity: Major
              Found in resources/js/src/database/events.ts and 1 other location - About 1 hr to fix
              resources/js/src/database/events.ts on lines 573..582

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

              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

                  $(document).on('click', '#bulkActionExportButton', function (event) {
                      event.preventDefault();
                      DatabaseEvents.exportDialog($(this));
                  }); // end $(document).on()
              Severity: Minor
              Found in resources/js/src/database/events.ts and 1 other location - About 55 mins to fix
              resources/js/src/database/events.ts on lines 624..627

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

              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

                  $(document).on('click', '#bulkActionDropButton', function (event) {
                      event.preventDefault();
                      DatabaseEvents.dropMultipleDialog($(this));
                  }); // end $(document).on()
              Severity: Minor
              Found in resources/js/src/database/events.ts and 1 other location - About 55 mins to fix
              resources/js/src/database/events.ts on lines 611..614

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

              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 3 locations. Consider refactoring.
              Open

                  $(document).on('change', 'select[name=item_type]', function () {
                      $(this).closest('table').find('tr.recurring_event_row, tr.onetime_event_row').toggle();
                  });
              Severity: Major
              Found in resources/js/src/database/events.ts and 2 other locations - About 50 mins to fix
              resources/js/src/database/routines.ts on lines 992..994
              resources/js/src/drag_drop_import.ts on lines 388..390

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

              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

                          buttonOptions[window.Messages.strClose].click = function () {
                              $(this).dialog('close');
                          };
              Severity: Minor
              Found in resources/js/src/database/events.ts and 2 other locations - About 40 mins to fix
              resources/js/src/database/routines.ts on lines 341..343
              resources/js/src/triggers.ts on lines 334..336

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

              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