XoopsModules25x/news

View on GitHub

Showing 310 of 310 total issues

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

    if ('edit' === $op) {
        if (isset($picture) && '' !== xoops_trim($picture)) {
            $pictureTray = new \XoopsFormElementTray(_NW_CURENT_PICTURE, '<br>');
            $pictureTray->addElement(new \XoopsFormLabel('', "<img src='" . XOOPS_URL . '/uploads/news/image/' . $picture . "'>"));
            $deletePicureCheckbox = new \XoopsFormCheckBox('', 'deleteimage', 0);
Severity: Major
Found in include/storyform.inc.php and 1 other location - About 3 hrs to fix
include/storyform.original.php on lines 151..160

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

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 ('edit' === $op) {
        if (isset($picture) && '' !== xoops_trim($picture)) {
            $pictureTray = new \XoopsFormElementTray(_NW_CURENT_PICTURE, '<br>');
            $pictureTray->addElement(new \XoopsFormLabel('', "<img src='" . XOOPS_URL . '/uploads/news/image/' . $picture . "'>"));
            $deletePicureCheckbox = new \XoopsFormCheckBox('', 'deleteimage', 0);
Severity: Major
Found in include/storyform.original.php and 1 other location - About 3 hrs to fix
include/storyform.inc.php on lines 150..159

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

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

    public function keywords($format = 'S')
    {
        $myts = \MyTextSanitizer::getInstance();
        switch (mb_strtoupper($format)) {
            case 'S':
Severity: Major
Found in class/NewsStory.php and 1 other location - About 2 hrs to fix
class/NewsStory.php on lines 1239..1256

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

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

    public function description($format = 'S')
    {
        $myts = \MyTextSanitizer::getInstance();
        switch (mb_strtoupper($format)) {
            case 'S':
Severity: Major
Found in class/NewsStory.php and 1 other location - About 2 hrs to fix
class/NewsStory.php on lines 1263..1280

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

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 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): void
    {
        $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, array $oldvisible, array $oldgroups, array $oldbcachetime, array $oldbmodule, array $title, array $weight, array $visible, array $side, array $bcachetime, array $groups, array $bmodule
    ): void {
        if (!$GLOBALS['xoopsSecurity']->check()) {
            \redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
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 b_news_top_edit has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

function b_news_top_edit($options)
{
    global $xoopsDB;
    $tmpstory = new NewsStory();
    $form     = _MB_NEWS_ORDER . "&nbsp;<select name='options[]'>";
Severity: Minor
Found in blocks/news_top.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

        $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 653..665

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

        $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 110..122

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

File XoopsTopic.php has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace XoopsModules\News;

/**
Severity: Minor
Found in class/XoopsTopic.php - About 2 hrs to fix

    Method addTopic has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function addTopic(): void
    {
        global $xoopsDB, $xoopsModule;
        $helper = Helper::getInstance();
    
    
    Severity: Major
    Found in admin/index.php - About 2 hrs to fix

      NewsTopic has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class NewsTopic extends XoopsTopic
      {
          public $menu;
          public $topic_description;
          public $topic_frontpage;
      Severity: Minor
      Found in class/NewsTopic.php - About 2 hrs to fix

        Function news_CreateMetaDatas has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        function news_CreateMetaDatas($story = null): void
        {
            global $xoopsConfig, $xoTheme, $xoopsTpl;
            $content = '';
            $myts    = \MyTextSanitizer::getInstance();
        Severity: Minor
        Found in include/functions.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 createMetaDatas has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function createMetaDatas($story = null): void
            {
                global $xoopsConfig, $xoTheme, $xoopsTpl;
                $content = '';
                $myts    = MyTextSanitizer::getInstance();
        Severity: Minor
        Found in class/Utility.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

        Method getAllPublishedByAuthor has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getAllPublishedByAuthor($uid, $checkRight = false, $asobject = true)
            {
                /** @var \XoopsMySQLDatabase $db */
                $db        = \XoopsDatabaseFactory::getDatabaseConnection();
                $myts      = \MyTextSanitizer::getInstance();
        Severity: Major
        Found in class/NewsStory.php - About 2 hrs to fix

          Method newSubmissions has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function newSubmissions(): void
          {
              global $dateformat, $pathIcon16;
              $start       = Request::getInt('startnew', 0, 'GET');
              $newsubcount = NewsStory::getAllStoriesCount(3, false);
          Severity: Major
          Found in admin/index.php - About 2 hrs to fix

            Method news_CreateMetaDatas has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function news_CreateMetaDatas($story = null): void
            {
                global $xoopsConfig, $xoTheme, $xoopsTpl;
                $content = '';
                $myts    = \MyTextSanitizer::getInstance();
            Severity: Major
            Found in include/functions.php - About 2 hrs to fix

              Method b_news_archives_edit has 63 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function b_news_archives_edit($options)
              {
                  global $xoopsDB;
                  $syear    = $smonth = $eyear = $emonth = $older = $recent = 0;
                  $selsyear = $selsmonth = $seleyear = $selemonth = 0;
              Severity: Major
              Found in blocks/news_archives.php - About 2 hrs to fix

                Method truncateHtml has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
                    {
                        if ($considerHtml) {
                            // if the plain text is shorter than the maximum length, return the whole text
                            if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
                Severity: Major
                Found in class/Common/SysUtility.php - About 2 hrs to fix

                  Method createMetaDatas has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function createMetaDatas($story = null): void
                      {
                          global $xoopsConfig, $xoTheme, $xoopsTpl;
                          $content = '';
                          $myts    = MyTextSanitizer::getInstance();
                  Severity: Major
                  Found in class/Utility.php - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language