XoopsModules25x/smallworld

View on GitHub
class/PublicWallUpdates.php

Summary

Maintainability
F
3 days
Test Coverage

File PublicWallUpdates.php has 317 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace XoopsModules\Smallworld;

/*
Severity: Minor
Found in class/PublicWallUpdates.php - About 3 hrs to fix

    Method parsePubArray has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function parsePubArray($updatesarray, $id)
        {
            /**
             * @var \XoopsModules\Smallworld\Helper $helper
             * @var \XoopsModules\Smallworld\SwUserHandler $swUserHandler
    Severity: Major
    Found in class/PublicWallUpdates.php - About 3 hrs to fix

      Function parsePubArray has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parsePubArray($updatesarray, $id)
          {
              /**
               * @var \XoopsModules\Smallworld\Helper $helper
               * @var \XoopsModules\Smallworld\SwUserHandler $swUserHandler
      Severity: Minor
      Found in class/PublicWallUpdates.php - About 3 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 Updates has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function Updates($last, $moderators)
          {
              /** @var \XoopsModules\Smallworld\Helper $helper */
              $helper     = Helper::getInstance();
              $moderators = is_array($moderators) ? $moderators : [$moderators];
      Severity: Major
      Found in class/PublicWallUpdates.php - About 2 hrs to fix

        Method Gravatar has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function Gravatar($uid)
            {
                $depMsg = get_class() . __FUNCTION__ . " is deprecated use SwUserHandler::gravatar() instead.";
                if (isset($GLOBALS['xoopsLogger'])) {
                    $GLOBALS['xoopsLogger']->addDeprecated($depMsg);
        Severity: Minor
        Found in class/PublicWallUpdates.php - About 1 hr to fix

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

              public function Updates($last, $moderators)
              {
                  /** @var \XoopsModules\Smallworld\Helper $helper */
                  $helper     = Helper::getInstance();
                  $moderators = is_array($moderators) ? $moderators : [$moderators];
          Severity: Minor
          Found in class/PublicWallUpdates.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 getSharingDiv has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function getSharingDiv($id, $priv, $permalink, $desc, $username)
          Severity: Minor
          Found in class/PublicWallUpdates.php - About 35 mins to fix

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

                public function Gravatar($uid)
                {
                    $depMsg = get_class() . __FUNCTION__ . " is deprecated use SwUserHandler::gravatar() instead.";
                    if (isset($GLOBALS['xoopsLogger'])) {
                        $GLOBALS['xoopsLogger']->addDeprecated($depMsg);
            Severity: Minor
            Found in class/PublicWallUpdates.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

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

                public function updatesSharelink($updid, $ownerID)
                {
                    $query  = 'SELECT M.msg_id, M.uid_fk, M.message, M.created, M.priv, U.username FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_messages') . ' M, ' . $GLOBALS['xoopsDB']->prefix('smallworld_user') . " U WHERE M.uid_fk=U.userid AND M.uid_fk='" . $ownerID . "' AND M.priv = 0";
                    $query  .= " AND M.msg_id = '" . $updid . "'";
                    $query  .= ' order by created DESC LIMIT 1';
            Severity: Major
            Found in class/PublicWallUpdates.php and 1 other location - About 4 hrs to fix
            class/PublicWallUpdates.php on lines 305..321

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

            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

                public function updatesPermalink($updid, $uid, $ownerID)
                {
                    $query  = 'SELECT M.msg_id, M.uid_fk, M.message, M.created, M.priv, U.username FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_messages') . ' M, ' . $GLOBALS['xoopsDB']->prefix('smallworld_user') . " U  WHERE M.uid_fk=U.userid AND M.uid_fk='" . $ownerID . "'";
                    $query  .= " AND M.msg_id = '" . $updid . "'";
                    $query  .= ' order by M.created DESC LIMIT 1';
            Severity: Major
            Found in class/PublicWallUpdates.php and 1 other location - About 4 hrs to fix
            class/PublicWallUpdates.php on lines 331..347

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

            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 (1 == $USW['posts'] || $profile >= Constants::PROFILE_HAS_BOTH) {
                            $wm['sharediv'] = $this->getSharingDiv($wm['msg_id'], $wm['priv'], $wm['sharelinkurl'], $wm['orimessage'], $wm['usernameTitle']);
                        } else {
                            $wm['sharediv'] = $this->getSharingDiv($wm['msg_id'], 1, $wm['sharelinkurl'], $wm['orimessage'], $wm['usernameTitle']);
                        }
            Severity: Major
            Found in class/PublicWallUpdates.php and 1 other location - About 2 hrs to fix
            class/WallUpdates.php on lines 513..517

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

            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

                public function countMsges($userid)
                {
                    $sql    = 'SELECT (SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_comments') . " WHERE uid_fk = '" . $userid . "') + (SELECT COUNT(*) FROM " . $GLOBALS['xoopsDB']->prefix('smallworld_messages') . " WHERE uid_fk = '" . $userid . "')";
                    $result = $GLOBALS['xoopsDB']->queryF($sql);
                    $sum    = $GLOBALS['xoopsDB']->fetchRow($result);
            Severity: Major
            Found in class/PublicWallUpdates.php and 1 other location - About 1 hr to fix
            class/WallUpdates.php on lines 355..362

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

            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