XoopsModules25x/xoopspoll

View on GitHub

Showing 2,846 of 2,846 total issues

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

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

                        $reg_values = "closeText: '"
                                      . \_AM_XOOPSPOLL_DTP_CLOSETEXT
                                      . "',"
                                      . "prevText: '"
                                      . \_AM_XOOPSPOLL_DTP_PREVTEXT
        Severity: Major
        Found in class/FormDateTimePicker.php and 1 other location - About 1 hr to fix
        class/FormDateTimePicker.php on lines 133..155

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

        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

                        $reg_values .= "timeOnlyTitle: '"
                                       . \_AM_XOOPSPOLL_DTP_TIMEONLYTITLE
                                       . "',"
                                       . "timeText: '"
                                       . \_AM_XOOPSPOLL_DTP_TIMETEXT
        Severity: Major
        Found in class/FormDateTimePicker.php and 1 other location - About 1 hr to fix
        class/FormDateTimePicker.php on lines 87..109

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

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

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

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

                Method getServerStats has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function getServerStats(): string
                    {
                        //mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
                        $moduleDirName      = \basename(\dirname(__DIR__, 2));
                        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
                Severity: Minor
                Found in class/Common/ServerStats.php - About 1 hr to fix

                  Function _setDateDatepicker has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Method loadTableFromArrayWithReplace has 30 lines of code (exceeds 25 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

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

                                  if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
                                      tp_inst.timezone = tp_date.getTimezoneOffset() * -1;
                                  }
                      Severity: Major
                      Found in assets/js/jquery-ui-timepicker-addon.js and 1 other location - About 1 hr to fix
                      assets/js/jquery-ui-timepicker-addon.js on lines 1767..1769

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

                      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 (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
                                              tp_inst.timezone = date.getTimezoneOffset() * -1;
                                          }
                      Severity: Major
                      Found in assets/js/jquery-ui-timepicker-addon.js and 1 other location - About 1 hr to fix
                      assets/js/jquery-ui-timepicker-addon.js on lines 1707..1709

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

                      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

                      Avoid using undefined variables such as '$timeArray' which will lead to PHP notices.
                      Open

                                  unset($optionsObjArray, $pollOptionsArray, $pollObj, $pollVars, $timeArray);
                      Severity: Minor
                      Found in blocks/singlepoll.php by phpmd

                      UndefinedVariable

                      Since: 2.8.0

                      Detects when a variable is used that has not been defined before.

                      Example

                      class Foo
                      {
                          private function bar()
                          {
                              // $message is undefined
                              echo $message;
                          }
                      }

                      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                      Avoid using undefined variables such as '$viewtopic_users' which will lead to PHP notices.
                      Open

                                        && (!$uid || !isset($viewtopic_users[$uid]))) {

                      UndefinedVariable

                      Since: 2.8.0

                      Detects when a variable is used that has not been defined before.

                      Example

                      class Foo
                      {
                          private function bar()
                          {
                              // $message is undefined
                              echo $message;
                          }
                      }

                      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                      Severity
                      Category
                      Status
                      Source
                      Language