phpmyadmin/phpmyadmin

View on GitHub
resources/js/src/server/privileges.ts

Summary

Maintainability
D
2 days
Test Coverage

File privileges.ts has 371 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 { CommonParams } from '../modules/common.ts';
import { Navigation } from '../modules/navigation.ts';
Severity: Minor
Found in resources/js/src/server/privileges.ts - About 4 hrs to fix

    Function handleEvent has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        handleEvent: function (event) {
            event.preventDefault();
    
            var $thisButton = $(this);
            var $form = $('#usersForm');
    Severity: Minor
    Found in resources/js/src/server/privileges.ts - About 1 hr to fix

      Function handleEvent has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          handleEvent: function (event) {
              const editUserGroupModal = document.getElementById('editUserGroupModal');
              const button = event.relatedTarget;
              const username = button.getAttribute('data-username');
      
      
      Severity: Minor
      Found in resources/js/src/server/privileges.ts - About 1 hr to fix

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

        function addOrUpdateSubmenu () {
            var $editUserDialog = $('#edit_user_dialog');
            if ($editUserDialog.length === 0) {
                return;
            }
        Severity: Minor
        Found in resources/js/src/server/privileges.ts - About 1 hr to fix

          Function handleEvent has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              handleEvent: function () {
                  const button = this;
                  const isLocked = button.dataset.isLocked === 'true';
                  const url = isLocked
                      ? 'index.php?route=/server/privileges/account-unlock'
          Severity: Minor
          Found in resources/js/src/server/privileges.ts - About 1 hr to fix

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

                                    $form
                                        .find('tbody').find('tr').each(function (index) {
                                            if (index >= 0 && index % 2 === 0) {
                                                $(this).removeClass('odd').addClass('even');
                                            } else if (index >= 0 && index % 2 !== 0) {
            Severity: Major
            Found in resources/js/src/server/privileges.ts and 1 other location - About 3 hrs to fix
            resources/js/src/server/status/processes.ts on lines 66..72

            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 {
                            const unlockIcon = getImageTag('s_unlock', window.Messages.strUnlock, {}).toString();
                            button.innerHTML = '<span class="text-nowrap">' + unlockIcon + ' ' + window.Messages.strUnlock + '</span>';
                            button.title = window.Messages.strUnlockAccount;
                            button.dataset.isLocked = 'true';
            Severity: Major
            Found in resources/js/src/server/privileges.ts and 1 other location - About 3 hrs to fix
            resources/js/src/server/privileges.ts on lines 121..126

            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

                        if (isLocked) {
                            const lockIcon = getImageTag('s_lock', window.Messages.strLock, {}).toString();
                            button.innerHTML = '<span class="text-nowrap">' + lockIcon + ' ' + window.Messages.strLock + '</span>';
                            button.title = window.Messages.strLockAccount;
                            button.dataset.isLocked = 'false';
            Severity: Major
            Found in resources/js/src/server/privileges.ts and 1 other location - About 3 hrs to fix
            resources/js/src/server/privileges.ts on lines 126..131

            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

            There are no issues that match your filters.

            Category
            Status