XoopsModules25x/smallworld

View on GitHub
class/WallUpdates.php

Summary

Maintainability
D
2 days
Test Coverage

File WallUpdates.php has 348 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace XoopsModules\Smallworld;

/**
Severity: Minor
Found in class/WallUpdates.php - About 4 hrs to fix

    Method parsePubArray has 85 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/WallUpdates.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/WallUpdates.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 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function Updates($last, $uid, $followers)
          {
              $uid       = (int)$uid;
              $query     = '';
              $hm        = \XoopsModules\Smallworld\Helper::getInstance()->getConfig('msgtoshow');
      Severity: Minor
      Found in class/WallUpdates.php - About 1 hr to fix

        Function insertUpdate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function insertUpdate($uid, $update, $priv = 0)
            {
                $uid    = (int)$uid;
                $priv   = (int)$priv;
                $update = smallworld_sanitize(htmlentities($update, ENT_QUOTES, 'UTF-8'));
        Severity: Minor
        Found in class/WallUpdates.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 insertUpdate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function insertUpdate($uid, $update, $priv = 0)
            {
                $uid    = (int)$uid;
                $priv   = (int)$priv;
                $update = smallworld_sanitize(htmlentities($update, ENT_QUOTES, 'UTF-8'));
        Severity: Minor
        Found in class/WallUpdates.php - About 1 hr to fix

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

              public function Updates($last, $uid, $followers)
              {
                  $uid       = (int)$uid;
                  $query     = '';
                  $hm        = \XoopsModules\Smallworld\Helper::getInstance()->getConfig('msgtoshow');
          Severity: Minor
          Found in class/WallUpdates.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 Gravatar has 27 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/WallUpdates.php - About 1 hr to fix

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

                public function getSharingDiv($id, $priv, $permalink, $desc, $username)
            Severity: Minor
            Found in class/WallUpdates.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/WallUpdates.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

              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/WallUpdates.php and 1 other location - About 2 hrs to fix
              class/PublicWallUpdates.php on lines 454..458

              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/WallUpdates.php and 1 other location - About 1 hr to fix
              class/PublicWallUpdates.php on lines 287..294

              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