XoopsModules25x/about

View on GitHub

Showing 45 of 434 total issues

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

    public static function recurseCopy($src, $dst)
    {
        $dir = \opendir($src);
        //        @mkdir($dst);
        if (!@\mkdir($dst) && !\is_dir($dst)) {
Severity: Minor
Found in class/Common/FilesManagement.php - 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 rmove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function rmove($src, $dest)
    {
        // Only continue if user is a 'global' Admin
        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
            return false;
Severity: Minor
Found in class/Common/FilesManagement.php - 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 rcopy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function rcopy($src, $dest)
    {
        // Only continue if user is a 'global' Admin
        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
            return false;
Severity: Minor
Found in class/Common/FilesManagement.php - 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

Method makeSelBox has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

            $name,
            $fieldName,
            $prefix = '-',
            $selected = '',
            $addEmptyOption = false,
Severity: Major
Found in class/Tree.php - About 50 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if ($pageObj->getVar('page_image')) {
                            @unlink($upload_path . '/' . $pageObj->getVar('page_image'));
                        }
    Severity: Major
    Found in admin/admin.page.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if (is_file($templateFolder . $v)) {
                                      unlink($templateFolder . $v);
                                  }
      Severity: Major
      Found in include/onupdate.php - About 45 mins to fix

        Function render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function render()
            {
                $ret    = '<div>';
                $hidden = '';
                foreach ($this->getElements() as $ele) {
        Severity: Minor
        Found in class/BlockForm.php - About 45 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 menuTree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function menuTree(array $pages = [], $key = 0, $level = 1)
            {
                $ret = false;
                if (!\is_array($pages) || 0 === \count($pages)) {
                    return $ret;
        Severity: Minor
        Found in class/PageHandler.php - About 45 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

        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

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

                  public function makeTreeItems($key, &$ret, $prefix_orig, $prefix_curr = '', $tags = null)
          Severity: Minor
          Found in class/Tree.php - About 35 mins to fix

            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

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

            function xoops_module_install_about(\XoopsModule $module)
            {
                require_once dirname(__DIR__, 3) . '/mainfile.php';
            
                $moduleDirName = basename(dirname(__DIR__));
            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 xoops_module_uninstall_about has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function xoops_module_uninstall_about(\XoopsModule $module)
            {
                $moduleDirName = $module->dirname();
                $helper  = Helper::getInstance();
                $utility = new Utility();
            Severity: Minor
            Found in include/action.module.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 xoops_module_uninstall_about has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function xoops_module_uninstall_about(\XoopsModule $module)
            {
                //    return true;
            
                require_once dirname(__DIR__) . '/preloads/autoloader.php';
            Severity: Minor
            Found in include/onuninstall.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

            The function xoops_module_update_about() has an NPath complexity of 865. The configured NPath complexity threshold is 200.
            Open

            function xoops_module_update_about(\XoopsModule $module, $previousVersion = null)
            {
                $moduleDirName      = basename(dirname(__DIR__));
                $moduleDirNameUpper = mb_strtoupper($moduleDirName);
            
            
            Severity: Minor
            Found in include/onupdate.php by phpmd

            NPathComplexity

            Since: 0.1

            The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

            Example

            class Foo {
                function bar() {
                    // lots of complicated code
                }
            }

            Source https://phpmd.org/rules/codesize.html#npathcomplexity

            The method truncateHtml() has an NPath complexity of 1116. The configured NPath complexity threshold is 200.
            Open

                public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
                {
                    if ($considerHtml) {
                        // if the plain text is shorter than the maximum length, return the whole text
                        if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
            Severity: Minor
            Found in class/Common/SysUtility.php by phpmd

            NPathComplexity

            Since: 0.1

            The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

            Example

            class Foo {
                function bar() {
                    // lots of complicated code
                }
            }

            Source https://phpmd.org/rules/codesize.html#npathcomplexity

            The method rmove() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
            Open

                public static function rmove($src, $dest)
                {
                    // Only continue if user is a 'global' Admin
                    if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
                        return false;
            Severity: Minor
            Found in class/Common/FilesManagement.php by phpmd

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

            The function xoops_module_update_about() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
            Open

            function xoops_module_update_about(\XoopsModule $module, $prev_version = null)
            {
                $success = true;
                // Delete files from previous version (if they exist)
                $oldFiles = [
            Severity: Minor
            Found in include/action.module.php by phpmd

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

            The method truncateHtml() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10.
            Open

                public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
                {
                    if ($considerHtml) {
                        // if the plain text is shorter than the maximum length, return the whole text
                        if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
            Severity: Minor
            Found in class/Common/SysUtility.php by phpmd

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

            The method checkVerModule() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
            Open

                public static function checkVerModule($helper, $source = 'github', $default = 'master')
                {
                    $moduleDirName      = \basename(dirname(__DIR__, 2));
                    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
                    $update             = '';
            Severity: Minor
            Found in class/Common/VersionChecks.php by phpmd

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

            Severity
            Category
            Status
            Source
            Language