XoopsModules25x/xoopspoll

View on GitHub

Showing 2,846 of 2,846 total issues

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

        if (!empty($end_time)) {
            $timezone = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
            //        $poll_obj->setVar("end_time", userTimeToServerTime(strtotime($end_time), $timezone));
            //Hack by irmtfan
            $poll_obj->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
Severity: Major
Found in extras/newbb_5x/irmtfan/polls.php and 1 other location - About 1 hr to fix
extras/newbb_5x/trunk_5_00/polls.php on lines 347..354

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

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 (!empty($end_time)) {
            $timezone = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
            //        $poll_obj->setVar("end_time", userTimeToServerTime(strtotime($end_time), $timezone));
            //Hack by irmtfan
            $poll_obj->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
Severity: Major
Found in extras/newbb_5x/trunk_5_00/polls.php and 1 other location - About 1 hr to fix
extras/newbb_5x/irmtfan/polls.php on lines 728..735

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

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

            } else if (max) { //if max was set
                if (max === 0) {
                    max = new Date();
                } else {
                    max = new Date(max);
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 1874..1892

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

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 (min) { //if min was set
                if (min === 0) {
                    min = new Date();
                } else {
                    min = new Date(min);
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 1882..1892

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

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 mailResults has 46 lines of code (exceeds 25 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

    Method getFormFeedback has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getFormFeedback($action = false): XoopsThemeForm
        {
            if (!$action) {
                $action = $_SERVER['REQUEST_URI'];
            }
    Severity: Minor
    Found in class/Common/ModuleFeedback.php - About 1 hr to fix

      Function approve has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function approve(&$post, $force = false)
          {
              if (empty($post)) {
                  return false;
              }
      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 orderBlock has 14 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              array $bid,
              array $oldtitle,
              array $oldside,
              array $oldweight,
              array $oldvisible,
      Severity: Major
      Found in class/Common/Blocksadmin.php - About 1 hr to fix

        Function displayPostEdit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function displayPostEdit()
            {
                global $myts;
        
                if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])) {
        Severity: Minor
        Found in extras/newbb_5x/irmtfan/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 updateBlock has 43 lines of code (exceeds 25 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 1 hr to fix

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

                      if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) {
                          tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
                      }
          Severity: Major
          Found in assets/js/jquery-ui-timepicker-addon.js and 2 other locations - About 1 hr to fix
          assets/js/jquery-ui-timepicker-addon.js on lines 301..303
          assets/js/jquery-ui-timepicker-addon.js on lines 304..306

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

          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

                      if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) {
                          tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
                      }
          Severity: Major
          Found in assets/js/jquery-ui-timepicker-addon.js and 2 other locations - About 1 hr to fix
          assets/js/jquery-ui-timepicker-addon.js on lines 298..300
          assets/js/jquery-ui-timepicker-addon.js on lines 304..306

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

          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

                      if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
                          tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
                      }
          Severity: Major
          Found in assets/js/jquery-ui-timepicker-addon.js and 2 other locations - About 1 hr to fix
          assets/js/jquery-ui-timepicker-addon.js on lines 298..300
          assets/js/jquery-ui-timepicker-addon.js on lines 301..303

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

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

              public function renderOptionFormTray(int $pid = 0): \XoopsFormElementTray
              {
                  \xoops_load('xoopsformloader');
                  $pid            = (int)$pid;
                  $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/xoopspoll/assets/images/colorbars/'));
          Severity: Minor
          Found in class/OptionHandler.php - About 1 hr to fix

            Method checkVerModule has 42 lines of code (exceeds 25 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 1 hr to fix

              Function getPostBody has a Cognitive Complexity of 13 (exceeds 5 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

              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 approve has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function approve(&$post, $force = false)
                  {
                      if (empty($post)) {
                          return false;
                      }
              Severity: Minor
              Found in extras/newbb_5x/irmtfan/class/PostHandler.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 handleActions has a Cognitive Complexity of 13 (exceeds 5 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

              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 getPostBody has a Cognitive Complexity of 13 (exceeds 5 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

              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 isBlockCloned has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups, bool $redirect = true)
                  {
                      \xoops_loadLanguage('admin', 'system');
                      \xoops_loadLanguage('admin/blocksadmin', 'system');
                      \xoops_loadLanguage('admin/groups', 'system');
              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

              Severity
              Category
              Status
              Source
              Language