XoopsModules25x/news

View on GitHub

Showing 310 of 310 total issues

File Files.php has 253 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace XoopsModules\News;

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

    Method lastStories has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function lastStories(): void
    {
        global $dateformat, $pathIcon16;
        news_collapsableBar('laststories', 'toplaststories');
        echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='toplaststories' name='toplaststories' src='" . $pathIcon16 . "/close12.gif' alt=''></a>&nbsp;" . sprintf(_AM_LAST10ARTS, Utility::getModuleOption('storycountadmin')) . '</h4>';
    Severity: Major
    Found in admin/index.php - About 2 hrs to fix

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

      if (News\Utility::checkVerXoops($GLOBALS['xoopsModule'], '2.5.9')) {
          //    $topic_select = $topic_tree->makeSelBox('topic_id', 'topic_title', '-- ', $topicid, false);
          $topic_select = $topic_tree->makeSelectElement('topic_id', 'topic_title', '--', $topicid, false, 0, '', _NW_TOPIC);
          $sform->addElement($topic_select);
      } else {
      Severity: Major
      Found in include/storyform.original.php and 1 other location - About 2 hrs to fix
      include/storyform.inc.php on lines 52..58

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

      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 (News\Utility::checkVerXoops($GLOBALS['xoopsModule'], '2.5.9')) {
          $topic_select = $topic_tree->makeSelectElement('topic_id', 'topic_title', '--', $topicid, false, 0, '', _NW_TOPIC);
          $sform->addElement($topic_select);
      } else {
          $topic_select = $topic_tree->makeSelBox('topic_id', 'topic_title', '-- ', $topicid, false);
      Severity: Major
      Found in include/storyform.inc.php and 1 other location - About 2 hrs to fix
      include/storyform.original.php on lines 58..65

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

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

      function b_news_randomnews_show($options)
      {
          /** @var Helper $helper */
          if (!class_exists(Helper::class)) {
              return false;
      Severity: Minor
      Found in blocks/news_randomnews.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 getStats has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      function getStats(): void
      {
          global $xoopsModule, $xoopsConfig;
          xoops_cp_header();
          $myts   = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in admin/index.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 checkVerModule has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function checkVerModule(
              \Xmf\Module\Helper $helper,
              ?string            $source = null,
              ?string            $default = null
          ): ?array {
      Severity: Minor
      Found in class/Common/VersionChecks.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 getAllPublishedByAuthor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getAllPublishedByAuthor($uid, $checkRight = false, $asobject = true)
          {
              /** @var \XoopsMySQLDatabase $db */
              $db        = \XoopsDatabaseFactory::getDatabaseConnection();
              $myts      = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in class/NewsStory.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 b_news_topicsnav_show has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function b_news_topicsnav_show($options)
      {
          /** @var Helper $helper */
          if (!class_exists(Helper::class)) {
              return false;
      Severity: Minor
      Found in blocks/news_topicsnav.php - About 1 hr to fix

        Method orderBlock has 15 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                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
        Severity: Major
        Found in class/Common/Blocksadmin.php - About 1 hr to fix

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

                  if (\class_exists('XoopsFormEditor')) {
                      if ($isAdmin) {
                          $descEditor = new XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea');
                      } else {
                          $descEditor = new XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea');
          Severity: Major
          Found in class/Common/SysUtility.php and 1 other location - About 1 hr to fix
          class/Utility.php on lines 293..301

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

          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 (\class_exists('XoopsFormEditor')) {
                      if ($isAdmin) {
                          $descEditor = new XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea');
                      } else {
                          $descEditor = new XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea');
          Severity: Major
          Found in class/Utility.php and 1 other location - About 1 hr to fix
          class/Common/SysUtility.php on lines 173..181

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

          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 (is_object($xoopsUser)) {
              $notify_checkbox = new \XoopsFormCheckBox('', 'notifypub', $notifypub);
              $notify_checkbox->addOption(1, _NW_NOTIFYPUBLISH);
              $option_tray->addElement($notify_checkbox);
              if ($xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
          Severity: Major
          Found in include/storyform.inc.php and 1 other location - About 1 hr to fix
          include/storyform.original.php on lines 187..196

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

          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 (is_object($xoopsUser)) {
              $notify_checkbox = new \XoopsFormCheckBox('', 'notifypub', $notifypub);
              $notify_checkbox->addOption(1, _NW_NOTIFYPUBLISH);
              $option_tray->addElement($notify_checkbox);
              if ($xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
          Severity: Major
          Found in include/storyform.original.php and 1 other location - About 1 hr to fix
          include/storyform.inc.php on lines 189..198

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

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

              public static function checkVerModule(
                  \Xmf\Module\Helper $helper,
                  ?string            $source = null,
                  ?string            $default = null
              ): ?array {
          Severity: Minor
          Found in class/Common/VersionChecks.php - About 1 hr to fix

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

            function news_close_tags($string)
            {
                // match opened tags
                if (preg_match_all('/<([a-z\:\-]+)[^\/]>/', $string, $start_tags)) {
                    $start_tags = $start_tags[1];
            Severity: Minor
            Found in include/functions.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 closeTags has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function closeTags($string)
                {
                    // match opened tags
                    if (\preg_match_all('/<([a-z\:\-]+)[^\/]>/', $string, $start_tags)) {
                        $start_tags = $start_tags[1];
            Severity: Minor
            Found in class/Utility.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 auto_summary has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                public function auto_summary($text, &$titles)
                {
                    $auto_summary = '';
                    if (Utility::getModuleOption('enhanced_pagenav')) {
                        $expr_matches = [];
            Severity: Minor
            Found in class/NewsStory.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

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

                if ('category' === $category) {
                    $sql    = 'SELECT title FROM ' . $xoopsDB->prefix('news_topics') . ' WHERE topic_id = ' . (int)$item_id;
                    $result = $xoopsDB->query($sql);
                    if ($result) {
                        $result_array = $xoopsDB->fetchArray($result);
            Severity: Major
            Found in include/notification.inc.php and 1 other location - About 1 hr to fix
            include/notification.inc.php on lines 35..48

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

            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 ('story' === $category) {
                    // Assume we have a valid story id
                    $sql    = 'SELECT title FROM ' . $xoopsDB->prefix('news_stories') . ' WHERE storyid = ' . (int)$item_id;
                    $result = $xoopsDB->query($sql);
                    if ($result) {
            Severity: Major
            Found in include/notification.inc.php and 1 other location - About 1 hr to fix
            include/notification.inc.php on lines 51..63

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

            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