XoopsModules25x/xoopspoll

View on GitHub

Showing 2,846 of 2,846 total issues

The class Post has an overall complexity of 120 which is very high. The configured complexity threshold is 50.
Open

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

The class PostHandler has an overall complexity of 101 which is very high. The configured complexity threshold is 50.
Open

class PostHandler extends \XoopsPersistableObjectHandler
{
    /**
     * @param null|\XoopsDatabase $db
     */

The class Post has an overall complexity of 103 which is very high. The configured complexity threshold is 50.
Open

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

The class SysUtility has 11 public methods. Consider refactoring SysUtility to keep number of public methods under 10.
Open

class SysUtility
{
    use VersionChecks;    //checkVerXoops, checkVerPhp Traits
    use ServerStats;    // getServerStats Trait
    use FilesManagement;    // Files Management Trait
Severity: Minor
Found in class/Common/SysUtility.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

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

The class SysUtility has an overall complexity of 50 which is very high. The configured complexity threshold is 50.
Open

class SysUtility
{
    use VersionChecks;    //checkVerXoops, checkVerPhp Traits
    use ServerStats;    // getServerStats Trait
    use FilesManagement;    // Files Management Trait
Severity: Minor
Found in class/Common/SysUtility.php by phpmd

The class PostHandler has an overall complexity of 85 which is very high. The configured complexity threshold is 50.
Open

class PostHandler extends \XoopsPersistableObjectHandler
{
    /**
     * @param null|\XoopsDatabase $db
     */

The class Poll has an overall complexity of 61 which is very high. The configured complexity threshold is 50.
Open

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

File polls.php has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);
/*
 * Newbb module
 *
 * You may not change or alter any portion of this comment or credits
Severity: Minor
Found in extras/newbb_5x/trunk_5_00/polls.php - About 3 hrs to fix

    Method _delete has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function _delete($post, $force = false)
        {
            global $xoopsModule;
    
            if (!is_object($post) || 0 == $post->getVar('post_id')) {
    Severity: Major
    Found in extras/newbb_5x/trunk_5_00/class/Post.php - About 3 hrs to fix

      Function setVoteCookie has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function setVoteCookie($index, string $value, int $expires = 0, string $cookieBaseName = 'voted_polls'): bool
          {
              $pollDir = \basename(\dirname(__DIR__));
              $success = false;
              // do a little sanity check on $index and $cookieBaseName
      Severity: Minor
      Found in class/Utility.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

      Function setVoteCookie has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function setVoteCookie($index, string $value, int $expires = 0, string $cookieBaseName = 'voted_polls'): bool
          {
              $pollDir = \basename(\dirname(__DIR__));
              $success = false;
              // do a little sanity check on $index and $cookieBaseName
      Severity: Minor
      Found in class/PollUtility.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 renderForm has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function renderForm(string $rtnPage, string $rtnMethod = 'post', array $addHidden = [])
          {
              \xoops_load('xoopsformloader');
              $myts = \MyTextSanitizer::getInstance();
      
      
      Severity: Major
      Found in class/Poll.php - About 3 hrs to fix

        Function Timepicker has 80 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var Timepicker = function () {
                this.regional = []; // Available regional settings, indexed by language code
                this.regional[''] = { // Default regional settings
                    currentText: 'Now',
                    closeText: 'Done',
        Severity: Major
        Found in assets/js/jquery-ui-timepicker-addon.js - About 3 hrs to fix

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

          function xoopspoll_search($queryArray, mixed $andor, mixed $limit, mixed $offset, $uid): array
          {
              $ret = [];
              if (0 === (int)$uid) {
                  $pollHandler = Helper::getInstance()->getHandler('Poll');
          Severity: Minor
          Found in include/search.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

          Function updateBlock has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups)
              {
                  $myblock = new \XoopsBlock($bid);
                  $myblock->setVar('title', $btitle);
                  $myblock->setVar('weight', $bweight);
          Severity: Minor
          Found in class/Common/Blocksadmin.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

          Function orderBlock has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              public function orderBlock(
                  array $bid,
                  array $oldtitle,
                  array $oldside,
                  array $oldweight,
          Severity: Minor
          Found in class/Common/Blocksadmin.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

          Function checkVerModule has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
              {
                  $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

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

                  $cache_select->addOptionArray([
                                                    0       => \_NOCACHE,
                                                    30      => \sprintf(\_SECONDS, 30),
                                                    60      => \_MINUTE,
                                                    300     => \sprintf(\_MINUTES, 5),
          Severity: Major
          Found in class/Common/Blocksadmin.php and 1 other location - About 2 hrs to fix
          class/Common/Blocksadmin.php on lines 114..126

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

          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

                  $cachetimes = [
                      0       => \_NOCACHE,
                      30      => \sprintf(\_SECONDS, 30),
                      60      => \_MINUTE,
                      300     => \sprintf(\_MINUTES, 5),
          Severity: Major
          Found in class/Common/Blocksadmin.php and 1 other location - About 2 hrs to fix
          class/Common/Blocksadmin.php on lines 722..734

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

          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 get($id = null, $fields = null)
              {
                  $id    = (int)$id;
                  $post  = null;
                  $sql   = 'SELECT p.*, t.* FROM ' . $this->db->prefix('bb_posts') . ' p LEFT JOIN ' . $this->db->prefix('bb_posts_text') . ' t ON p.post_id=t.post_id WHERE p.post_id=' . $id;
          Severity: Major
          Found in extras/newbb_5x/trunk_5_00/class/Post.php and 1 other location - About 2 hrs to fix
          extras/newbb_5x/irmtfan/class/PostHandler.php on lines 46..58

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

          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

          Severity
          Category
          Status
          Source
          Language