XoopsModules25x/xoopspoll

View on GitHub

Showing 2,846 of 2,846 total issues

Identical blocks of code found in 2 locations. 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: Major
Found in class/Utility.php and 1 other location - About 1 day to fix
class/PollUtility.php on lines 140..172

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

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 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: Major
Found in class/PollUtility.php and 1 other location - About 1 day to fix
class/Utility.php on lines 114..146

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

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

File Blocksadmin.php has 554 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace XoopsModules\Xoopspoll\Common;

/**
Severity: Major
Found in class/Common/Blocksadmin.php - About 1 day to fix

    File Post.php has 528 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php declare(strict_types=1);
    
    namespace XoopsModules\Newbb;
    
    /*
    Severity: Major
    Found in extras/newbb_5x/irmtfan/class/Post.php - About 1 day to fix

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

              $pollVars = [
                  'user_id'     => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'),
                  'question'    => Request::getString('question', null, 'POST'),
                  'description' => Request::getText('description', null, 'POST'),
                  'mail_status' => (Constants::NOTIFICATION_ENABLED === $notify) ? Constants::POLL_NOT_MAILED : Constants::POLL_MAILED,
      Severity: Major
      Found in admin/main.php and 2 other locations - About 1 day to fix
      extras/newbb_5x/irmtfan/polls.php on lines 408..422
      extras/newbb_5x/trunk_5_00/polls.php on lines 149..163

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

      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 3 locations. Consider refactoring.
      Open

                  $poll_vars = [
                      'user_id'     => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'),
                      'question'    => Request::getString('question', null, 'POST'),
                      'description' => Request::getText('description', null, 'POST'),
                      'mail_status' => (Constants::NOTIFICATION_ENABLED === $notify) ? Constants::POLL_NOT_MAILED : Constants::POLL_MAILED,
      Severity: Major
      Found in extras/newbb_5x/irmtfan/polls.php and 2 other locations - About 1 day to fix
      admin/main.php on lines 251..265
      extras/newbb_5x/trunk_5_00/polls.php on lines 149..163

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

      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 3 locations. Consider refactoring.
      Open

              $poll_vars = [
                  'user_id'     => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'),
                  'question'    => Request::getString('question', null, 'POST'),
                  'description' => Request::getText('description', null, 'POST'),
                  'mail_status' => (Constants::NOTIFICATION_ENABLED === $notify) ? Constants::POLL_NOT_MAILED : Constants::POLL_MAILED,
      Severity: Major
      Found in extras/newbb_5x/trunk_5_00/polls.php and 2 other locations - About 1 day to fix
      admin/main.php on lines 251..265
      extras/newbb_5x/irmtfan/polls.php on lines 408..422

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

      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

      Function _delete has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _delete($post, $force = false)
          {
              global $xoopsModule;
      
              if (!is_object($post) || 0 == $post->getVar('post_id')) {
      Severity: Minor
      Found in extras/newbb_5x/trunk_5_00/class/Post.php - About 1 day 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 truncateHtml has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function truncateHtml(
              string $text,
              ?int $length = 100,
              ?string $ending = '...',
              ?bool $exact = false,
      Severity: Minor
      Found in class/Common/SysUtility.php - About 1 day 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 (!$topic_id = $post->getVar('topic_id')) {
                      $topic_obj->setVar('topic_title', $post->getVar('subject', 'n'));
                      $topic_obj->setVar('topic_poster', $post->getVar('uid'));
                      $topic_obj->setVar('forum_id', $post->getVar('forum_id'));
                      $topic_obj->setVar('topic_time', $post->getVar('post_time'));
      Severity: Major
      Found in extras/newbb_5x/irmtfan/class/PostHandler.php and 1 other location - About 1 day to fix
      extras/newbb_5x/trunk_5_00/class/Post.php on lines 790..810

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

      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

                  if (!$topic_id = $post->getVar('topic_id')) {
                      $topic_obj->setVar('topic_title', $post->getVar('subject', 'n'));
                      $topic_obj->setVar('topic_poster', $post->getVar('uid'));
                      $topic_obj->setVar('forum_id', $post->getVar('forum_id'));
                      $topic_obj->setVar('topic_time', $post->getVar('post_time'));
      Severity: Major
      Found in extras/newbb_5x/trunk_5_00/class/Post.php and 1 other location - About 1 day to fix
      extras/newbb_5x/irmtfan/class/PostHandler.php on lines 216..238

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

      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 showPost has 201 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function showPost($isadmin)
          {
              global $myts;
              global $forumUrl, $forumImage;
              global $viewtopic_users, $viewtopic_posters, $forum_obj, $topic_obj, $online, $user_karma, $viewmode, $order, $start, $total_posts, $topic_status;
      Severity: Major
      Found in extras/newbb_5x/irmtfan/class/Post.php - About 1 day to fix

        File polls.php has 495 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/irmtfan/polls.php - About 7 hrs to fix

          File main.php has 480 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php declare(strict_types=1);
          
          if (defined('MAIN_DEFINED')) {
              return;
          }
          Severity: Minor
          Found in extras/newbb_5x/irmtfan/language/english/main.php - About 7 hrs 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/irmtfan/class/Post.php and 1 other location - About 7 hrs to fix
            extras/newbb_5x/irmtfan/class/Post.php on lines 559..569

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

            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);
                                $thread_buttons['edit']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}");
            Severity: Major
            Found in extras/newbb_5x/irmtfan/class/Post.php and 1 other location - About 7 hrs to fix
            extras/newbb_5x/irmtfan/class/Post.php on lines 571..582

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

            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

            Function xoops_module_update_xoopspoll has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

            function xoops_module_update_xoopspoll(\XoopsModule $module, $prev_version): bool
            {
                // referer check
                $success = false;
                $ref     = xoops_getenv('HTTP_REFERER');
            Severity: Minor
            Found in include/onupdate.php - About 7 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 _limitMinMaxDateTime has 174 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    _limitMinMaxDateTime: function (dp_inst, adjustSliders) {
                        var o = this._defaults,
                            dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
            
                        if (!this._defaults.showTimepicker) {
            Severity: Major
            Found in assets/js/jquery-ui-timepicker-addon.js - About 6 hrs to fix

              Function xoopspollBlockSinglepollShow has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
              Open

              function xoopspollBlockSinglepollShow(mixed $options): array
              {
                  $block = [];
              
                  /** @var \XoopsConfigHandler $configHandler */
              Severity: Minor
              Found in blocks/singlepoll.php - About 6 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

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

              } elseif ('compact' === $viewmode) {
                  $viewmode_options[] = [
                      'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=thread&amp;topic_id=' . $topic_id,
                      'title' => _THREADED,
                  ];
              Severity: Major
              Found in extras/newbb_5x/trunk_5_00/viewtopic.php and 1 other location - About 6 hrs to fix
              extras/newbb_5x/trunk_5_00/viewtopic.php on lines 550..570

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

              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