mambax7/mymenus

View on GitHub

Showing 115 of 115 total issues

Consider simplifying this complex logical expression.
Open

            if ($oldtitle[$i] !== $title[$i]
                || $oldweight[$i] !== $weight[$i]
                || $oldvisible[$i] !== $visible[$i]
                || $oldside[$i] !== $side[$i]
                || $oldbcachetime[$i] !== $bcachetime[$i]
Severity: Major
Found in class/Common/Blocksadmin.php - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

                if (parentItem != null && nextItem === null &&
                    (o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) ||
                    !o.rtl && (this.positionAbs.left < parentItem.offset().left))) {
                    parentItem.after(this.placeholder[0]);
                    this._clearEmpty(parentItem[0]);
    Severity: Major
    Found in assets/js/nestedSortable.js - About 40 mins to fix

      Method truncateHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
      Severity: Minor
      Found in class/Common/SysUtility.php - About 35 mins to fix

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

        ddtreemenu.flatten = function (treeid, action) { //expand or contract all UL elements
            var ultags = document.getElementById(treeid).getElementsByTagName("ul");
            for (var i = 0; i < ultags.length; i++) {
                ultags[i].style.display = (action == "expand") ? "block" : "none";
                var relvalue = (action == "expand") ? "open" : "closed";
        Severity: Minor
        Found in skins/treemenu/simpletreemenu.js - 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 _renderOptionTree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = []): void
            {
                $tree .= $prefix . '<input type="checkbox" name="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" onclick="';
                // If there are parent elements, add javascript that will
                // make them selecteded when this element is checked to make
        Severity: Minor
        Found in class/GroupFormCheckBox.php - 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 addLink has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function addLink($mid): void
            {
                $helper = Helper::getInstance();
        
                if (!$GLOBALS['xoopsSecurity']->check()) {
        Severity: Minor
        Found in class/LinksUtility.php - 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 getEditor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function getEditor($helper = null, $options = null)
            {
                /** @var Helper $helper */
                if (null === $options) {
                    $options           = [];
        Severity: Minor
        Found in class/Common/SysUtility.php - 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

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

                if (status == "error") {
                    var msg = "Sorry but there was an error: ";
                    $("#error").html(msg + xhr.status + " " + xhr.statusText);
                } else {
                    $("#hidden-result_" + id).hide();
        Severity: Minor
        Found in assets/js/links.js and 1 other location - About 35 mins to fix
        assets/js/links.js on lines 80..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 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

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

                if (status == "error") {
                    var msg = "Sorry but there was an error: ";
                    $("#error").html(msg + xhr.status + " " + xhr.statusText);
                } else {
                    $("#hidden-result_" + id).hide();
        Severity: Minor
        Found in assets/js/links.js and 1 other location - About 35 mins to fix
        assets/js/links.js 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 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

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

        function xoops_module_install_mymenus(\XoopsModule $module)
        {
            require \dirname(__DIR__, 3) . '/mainfile.php';
            require \dirname(__DIR__) . '/config/config.php';
        
        
        Severity: Minor
        Found in include/oninstall.php - 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 setPlugins has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function setPlugins(): void
            {
                if (\is_dir($dir = $GLOBALS['xoops']->path("modules/{$this->helper->getDirname()}/class/Plugins/"))) {
                    $pluginsList = \XoopsLists::getDirListAsArray($dir);
                    foreach ($pluginsList as $plugin) {
        Severity: Minor
        Found in class/Plugin.php - 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 loadSampleData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function loadSampleData(): void
        {
            global $xoopsConfig;
            $moduleDirName      = \basename(\dirname(__DIR__));
            $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
        Severity: Minor
        Found in testdata/index.php - 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 eventEnd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function eventEnd(): void
            {
                $newmenus = [];
                $registry = Mymenus\Registry::getInstance();
                $menus    = $registry->getEntry('menus');
        Severity: Minor
        Found in class/Plugins/Dynamic/PluginItem.php - 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 convertIPAddresses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function convertIPAddresses($tableName, $columnName): void
            {
                if ($this->tableHandler->useTable($tableName)) {
                    $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName);
                    if (false !== mb_strpos($attributes, ' int(')) {
        Severity: Minor
        Found in class/Common/Migrate.php - 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 checkInfoTable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function checkInfoTable(\XoopsObject $module)
            {
                //    global $xoopsDB;
                $err = true;
        
        
        Severity: Minor
        Found in class/Updater.php - 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

        Severity
        Category
        Status
        Source
        Language