XoopsModules25x/xoopspoll

View on GitHub

Showing 2,846 of 2,846 total issues

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

function loadTableFromArrayWithReplace(string $table, array $data, string $search, $replace): int
{
    /** @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

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

        echo $action[$mode]['msg']
             . "<p><a href='"
             . XOOPS_URL
             . '/modules/'
             . $xoopsModule->getVar('dirname')
Severity: Major
Found in extras/newbb_5x/irmtfan/topicmanager.php and 1 other location - About 1 hr to fix
extras/newbb_5x/irmtfan/topicmanager.php on lines 236..253

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

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

        echo $action[$mode]['msg']
             . "<p><a href='"
             . XOOPS_URL
             . '/modules/'
             . $xoopsModule->getVar('dirname')
Severity: Major
Found in extras/newbb_5x/irmtfan/topicmanager.php and 1 other location - About 1 hr to fix
extras/newbb_5x/irmtfan/topicmanager.php on lines 141..158

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

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

Method handleActions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handleActions(BlockData $blockData)
    {
        $moduleDirNameUpper = \mb_strtoupper(Helper::getInstance()->getDirname());
        $bid = Request::getInt('bid', 0);

Severity: Minor
Found in class/Common/BlockActionsHandler.php - About 1 hr to fix

    Method cloneBlock has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function cloneBlock(int $bid)
        {
            //require __DIR__ . '/admin_header.php';
            //        \xoops_cp_header();
    
    
    Severity: Minor
    Found in class/Common/Blocksadmin.php - About 1 hr to fix

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

          public function getAllByPollId(int $pid): mixed
          {
              $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1);
              $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::getAll instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}");
              $criteria = new Criteria('poll_id', (int)$pid, '=');
      Severity: Major
      Found in class/Option.php and 1 other location - About 1 hr to fix
      class/Option.php on lines 125..132

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

      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 deleteByPollId(int $pid): mixed
          {
              $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1);
              $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::deleteAll instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}");
              $criteria = new Criteria('poll_id', (int)$pid, '=');
      Severity: Major
      Found in class/Option.php and 1 other location - About 1 hr to fix
      class/Option.php on lines 140..147

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

      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

      The class BlockData has 27 fields. Consider redesigning BlockData to keep the number of fields under 15.
      Open

      class BlockData
      {
          public $bid;
          public $op;
          public $ok;
      Severity: Minor
      Found in class/Common/BlockData.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

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

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

                      if ($topicHandler->getPermission($forum_id, $topic_status, 'delete')) {
                          $delete_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit')));
          
                          if ($delete_ok) {
                              $thread_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE);
          Severity: Major
          Found in extras/newbb_5x/trunk_5_00/class/Post.php and 1 other location - About 1 hr to fix
          extras/newbb_5x/trunk_5_00/class/Post.php on lines 527..535

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

          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

                      if ($topicHandler->getPermission($forum_id, $topic_status, 'edit')) {
                          $edit_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit')));
          
                          if ($edit_ok) {
                              $thread_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT);
          Severity: Major
          Found in extras/newbb_5x/trunk_5_00/class/Post.php and 1 other location - About 1 hr to fix
          extras/newbb_5x/trunk_5_00/class/Post.php on lines 537..545

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

          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

          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

            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

              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
                Severity
                Category
                Status
                Source
                Language