mambax7/gbook

View on GitHub

Showing 21 of 307 total issues

Function truncateHtml has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true): string
    {
        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 - About 1 day 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_update_gbook has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

function xoops_module_update_gbook(\XoopsModule $module, $previousVersion = null)
{
    global $xoopsDB;

    if ($previousVersion < 111) {
Severity: Minor
Found in include/onupdate.php - About 5 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 checkVerModule has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
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 - About 2 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

Method truncateHtml has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

    Function deleteDirectory has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function deleteDirectory($src): bool
        {
            // 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 2 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

    Method xoops_module_update_gbook has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function xoops_module_update_gbook(\XoopsModule $module, $previousVersion = null)
    {
        global $xoopsDB;
    
        if ($previousVersion < 111) {
    Severity: Minor
    Found in include/onupdate.php - About 1 hr to fix

      Method checkVerModule has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      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 - About 1 hr to fix

        Function loadTableFromArrayWithReplace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function loadTableFromArrayWithReplace($table, $data, $search, $replace)
        {
            /** @var \XoopsMySQLDatabase $db */
            $db = \XoopsDatabaseFactory::getDatabaseConnection();
        
        
        Severity: Minor
        Found in testdata/index.php - About 1 hr 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 rrmdir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function rrmdir($src): bool
            {
                // 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 1 hr 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 loadTableFromArrayWithReplace has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function loadTableFromArrayWithReplace($table, $data, $search, $replace)
        {
            /** @var \XoopsMySQLDatabase $db */
            $db = \XoopsDatabaseFactory::getDatabaseConnection();
        
        
        Severity: Minor
        Found in testdata/index.php - About 1 hr to fix

          Method getServerStats has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getServerStats(): string
              {
                  //mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
                  $moduleDirName      = \basename(\dirname(__DIR__, 2));
                  $moduleDirNameUpper = mb_strtoupper($moduleDirName);
          Severity: Minor
          Found in class/Common/ServerStats.php - About 1 hr to fix

            Method loadSampleData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function loadSampleData()
            {
                global $xoopsConfig;
                $moduleDirName      = \basename(\dirname(__DIR__));
                $moduleDirNameUpper = mb_strtoupper($moduleDirName);
            Severity: Minor
            Found in testdata/index.php - About 1 hr to fix

              Method getForm has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getForm($action = false): XoopsThemeForm
                  {
                      if (false === $action) {
                          $action = Request::getString('REQUEST_URI', '', 'SERVER');
                      }
              Severity: Minor
              Found in class/Entries.php - About 1 hr to fix

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

                    public static function recurseCopy($src, $dst): void
                    {
                        $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): bool
                    {
                        // 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): bool
                    {
                        // 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 truncateHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true): string
                Severity: Minor
                Found in class/Common/SysUtility.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 Gbook\Helper $helper */
                          if (null === $options) {
                              $options           = [];
                  Severity: Minor
                  Found in class/Utility.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

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

                  function loadSampleData()
                  {
                      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

                  Severity
                  Category
                  Status
                  Source
                  Language