XoopsModules25x/xoopspoll

View on GitHub

Showing 300 of 2,846 total issues

The class Post has 23 fields. Consider redesigning Post to keep the number of fields under 15.
Open

class Post extends \XoopsObject
{
    private $post_id;
    private $topic_id;
    private $forum_id;

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

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

The class Poll has 16 fields. Consider redesigning Poll to keep the number of fields under 15.
Open

class Poll extends \XoopsObject
{
    private int    $poll_id;
    private string $question;
    private string $description;
Severity: Minor
Found in class/Poll.php by phpmd

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

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

Method editBlock has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function editBlock(int $bid): void
    {
        //        require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
        //        \xoops_cp_header();
        \xoops_loadLanguage('admin', 'system');
Severity: Minor
Found in class/Common/Blocksadmin.php - About 1 hr to fix

    Method assignForm has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function assignForm(\XoopsTpl $tpl): void
        {
            $myts       = \MyTextSanitizer::getInstance();
            $optionObjs = $this->optionHandler->getAllByPollId($this->pollObj->getVar('poll_id'));
    
    
    Severity: Minor
    Found in class/Renderer.php - About 1 hr to fix

      Method getPostBody has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function &getPostBody()
          {
              global $xoopsConfig, $xoopsUser, $myts;
              /** @var Xoopspoll\Helper $helper */
              $helper = Xoopspoll\Helper::getInstance();
      Severity: Minor
      Found in extras/newbb_5x/trunk_5_00/class/Post.php - About 1 hr to fix

        Method vote has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function vote(int $optionId, string $ip, int $time): bool
            {
                if (!empty($optionId) && $this->isAllowedToVote()) {
                    $voteTime      = empty($time) ? \time() : (int)$time;
                    $uid           = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->uid() : 0;
        Severity: Minor
        Found in class/Poll.php - About 1 hr to fix

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

              public function render(?array $block = null): void
              {
                  \xoops_load('XoopsFormLoader');
                  \xoops_loadLanguage('common', $this->moduleDirNameUpper);
          
          
          Severity: Minor
          Found in class/Common/Blocksadmin.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 displayAttachment has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function displayAttachment($asSource = false)
              {
                  global $xoopsModule;
                  /** @var Xoopspoll\Helper $helper */
                  $helper = Xoopspoll\Helper::getInstance();
          Severity: Minor
          Found in extras/newbb_5x/trunk_5_00/class/Post.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 getPostBody has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function &getPostBody()
              {
                  global $myts;
                  $GLOBALS['xoopsModuleConfig'] = newbb_load_config(); // irmtfan  load all newbb configs - newbb config in blocks activated in some modules like profile
                  //        mod_loadFunctions('user', 'newbb');
          Severity: Minor
          Found in extras/newbb_5x/irmtfan/class/Post.php - About 1 hr to fix

            Method orderBlock has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function orderBlock(
                    array $bid,
                    array $oldtitle,
                    array $oldside,
                    array $oldweight,
            Severity: Minor
            Found in class/Common/Blocksadmin.php - About 1 hr to fix

              Method __construct has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function __construct($id = null)
                  {
                      parent::__construct();
                      //        $timestamp = xoops_getUserTimestamp(time());
                      $currentTimestamp = \time();
              Severity: Minor
              Found in class/Poll.php - About 1 hr to fix

                Method hasVoted has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function hasVoted(?int $pid, string $ip, int $uid = 0): bool
                    {
                        $uid        = (int)$uid;
                        $pid        = (int)$pid;
                        $voted      = true;
                Severity: Minor
                Found in class/LogHandler.php - About 1 hr to fix

                  Function _getDateDatepicker has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      $.datepicker._getDateDatepicker = function (target, noDefault) {
                          var inst = this._getInst(target);
                          if (!inst) {
                              return;
                          }
                  Severity: Minor
                  Found in assets/js/jquery-ui-timepicker-addon.js - About 1 hr to fix

                    Method isResultVisible has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function isResultVisible()
                        {
                            $visibleMsg = '';
                            \xoops_loadLanguage('main', 'xoopspoll');
                            switch ($this->getVar('visibility')) {
                    Severity: Minor
                    Found in class/Poll.php - About 1 hr to fix

                      Method delete has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function delete($post, $isDeleteOne = true, $force = false)
                          {
                              $retVal = false;
                              if (($post instanceof Post) && ($post->getVar('post_id') > 0)) {
                                  if ($isDeleteOne) {
                      Severity: Minor
                      Found in extras/newbb_5x/irmtfan/class/PostHandler.php - About 1 hr to fix

                        Method processOrderBlockAction has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function processOrderBlockAction(BlockData $blockData)
                            {
                                $blockData->bid           = Request::getArray('bid', []);
                                $blockData->oldtitle      = Request::getArray('oldtitle', [], 'POST');
                                $blockData->oldside       = Request::getArray('oldside', [], 'POST');
                        Severity: Minor
                        Found in class/Common/BlockActionsHandler.php - About 1 hr to fix

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

                              public function mailResults(mixed $pollObj = null): array
                              {
                                  $criteria = new \CriteriaCompo();
                                  $criteria->add(new \Criteria('end_time', \time(), '<'));  // expired polls
                                  $criteria->add(new \Criteria('mail_status', Constants::POLL_NOT_MAILED, '=')); // email not previously sent
                          Severity: Minor
                          Found in class/PollHandler.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(string $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

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

                              public function hasVoted(?int $pid, string $ip, int $uid = 0): bool
                              {
                                  $uid        = (int)$uid;
                                  $pid        = (int)$pid;
                                  $voted      = true;
                          Severity: Minor
                          Found in class/LogHandler.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 assignResults has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function assignResults(\XoopsTpl $tpl): void
                              {
                                  $myts             = \MyTextSanitizer::getInstance();
                                  $xuEndTimestamp   = \xoops_getUserTimestamp($this->pollObj->getVar('end_time'));
                                  $xuEndFormatted   = \ucfirst(\date(_MEDIUMDATESTRING, (int)$xuEndTimestamp));
                          Severity: Minor
                          Found in class/Renderer.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

                          Severity
                          Category
                          Status
                          Source
                          Language