XoopsModules25x/xoopspoll

View on GitHub

Showing 2,846 of 2,846 total issues

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

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

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

        unset($thread_buttons, $mod_buttons, $eachposter);

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 '$myObjtree' which will lead to PHP notices.
Open

                $arr       = $myObjtree->getAllChild(); // get all children of this object

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 '$eachposter' which will lead to PHP notices.
Open

        unset($thread_buttons, $eachposter);

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 '$skipColumns' which will lead to PHP notices.
Open

    TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns);
Severity: Minor
Found in testdata/index.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 '$skipColumns' which will lead to PHP notices.
Open

    $skipColumns[] = 'gperm_id';
Severity: Minor
Found in testdata/index.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 '$options' which will lead to PHP notices.
Open

            $options[] = [
Severity: Minor
Found in class/Renderer.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 '$options' which will lead to PHP notices.
Open

                             'options'     => $options ?? [],
Severity: Minor
Found in class/Renderer.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

Method setPostEdit has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setPostEdit($poster_name = '')
    {
        global $xoopsUser;
        /** @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 looseParse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            var looseParse = function (f, s, o) {
                try {
                    var d = new Date('2012-01-01 ' + s);
                    if (isNaN(d.getTime())) {
                        d = new Date('2012-01-01T' + s);
    Severity: Minor
    Found in assets/js/jquery-ui-timepicker-addon.js - About 1 hr to fix

      Method b_marquee_xoopspoll has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function b_marquee_xoopspoll($limit, $dateformat, $itemssize)
      {
          require_once $GLOBALS['xoops']->path('modules/marquee/include/functions.php');
          $block = [];
          $myts  = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in extras/marquee/plugins/xoopspoll.php - About 1 hr to fix

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

                $expire_text = new \XoopsFormText(_MD_POLL_EXPIRATION . '<br><small>' . _MD_POLL_FORMAT . '<br>' . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), _DATESTRING)) . '</small>', 'end_time', 20, 19, formatTimestamp(time() + $default_poll_duration, _DATESTRING));
        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 322..322

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

        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

                $expire_text           = new \XoopsFormText(_MD_POLL_EXPIRATION . '<br><small>' . _MD_POLL_FORMAT . '<br>' . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), _DATESTRING)) . '</small>', 'end_time', 20, 19, formatTimestamp(time() + $default_poll_duration, _DATESTRING));
        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 696..696

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

        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 updateBlock has 9 arguments (exceeds 4 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)
        Severity: Major
        Found in class/Common/Blocksadmin.php - About 1 hr to fix

          Method isBlockCloned has 9 arguments (exceeds 4 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)
          Severity: Major
          Found in class/Common/Blocksadmin.php - About 1 hr to fix

            Method setPostEdit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function setPostEdit($poster_name = '', $post_editmsg = '')
                {
                    if ($this->getVar('approved') < 1
                        || empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])
                        || (\time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60) {
            Severity: Minor
            Found in extras/newbb_5x/irmtfan/class/Post.php - About 1 hr to fix

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

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

                  Function deleteAttachment has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function deleteAttachment($attach_array = null)
                      {
                          /** @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 isResultVisible has a Cognitive Complexity of 10 (exceeds 5 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

                  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