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) {
        $sfiles   = new Files();
        $filesarr = [];
        $filesarr = $sfiles->getAllbyStory($storyid);
        if (count($filesarr) > 0) {
Severity: Major
Found in include/storyform.original.php and 1 other location - About 6 hrs to fix
include/storyform.inc.php on lines 131..148

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

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

NewsStory has 46 functions (exceeds 20 allowed). Consider refactoring.
Open

class NewsStory extends XoopsStory
{
    public $newstopic; // XoopsTopic object
    public $rating; // News rating
    public $votes; // Number of votes
Severity: Minor
Found in class/NewsStory.php - About 6 hrs to fix

    XoopsStory has 46 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class XoopsStory
    {
        public $table;
        public $storyid;
        public $topicid;
    Severity: Minor
    Found in class/XoopsStory.php - About 6 hrs to fix

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

      if ($approveprivilege) {
          $editor2 = News\Utility::getWysiwygForm(_AM_EXTEXT, 'bodytext', $bodytext, 15, 60, 'bodytext_hidden');
          $sform->addElement($editor2, false);
      
          if (News\Utility::getModuleOption('tags') && \class_exists(\XoopsModules\Tag\FormTag::class) && xoops_isActiveModule('tag')) {
      Severity: Major
      Found in include/storyform.inc.php and 1 other location - About 6 hrs to fix
      include/storyform.original.php on lines 102..115

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

      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 ($approveprivilege) {
          $editor2 = News\Utility::getWysiwygForm(_AM_EXTEXT, 'bodytext', $bodytext, 15, 60, 'bodytext_hidden');
          $sform->addElement($editor2, false);
      
          if (News\Utility::getModuleOption('tags') && \class_exists(\XoopsModules\Tag\FormTag::class) && xoops_isActiveModule('tag')) {
      Severity: Major
      Found in include/storyform.original.php and 1 other location - About 6 hrs to fix
      include/storyform.inc.php on lines 98..114

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

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

      function PrintPage(): void
      {
          global $xoopsConfig, $xoopsModule, $story, $xoops_meta_keywords, $xoops_meta_description;
          $myts     = \MyTextSanitizer::getInstance();
          $datetime = formatTimestamp($story->published(), News\Utility::getModuleOption('dateformat')); ?>
      Severity: Major
      Found in print.php - About 6 hrs to fix

        Function news_search has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

        function news_search($queryarray, $andor, $limit, $offset, $userid)
        {
            global $xoopsDB, $xoopsUser;
            $restricted = News\Utility::getModuleOption('restrictindex');
            $highlight  = false;
        Severity: Minor
        Found in include/search.inc.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

        Method privBuildMimeArray has 154 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function privBuildMimeArray()
            {
                return [
                    'ez'      => 'application/andrew-inset',
                    'hqx'     => 'application/mac-binhex40',
        Severity: Major
        Found in class/Mimetype.php - About 6 hrs to fix

          Function xoops_module_update_news has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
          Open

          function xoops_module_update_news()
          {
              global $xoopsDB;
              $errors = 0;
          
          
          Severity: Minor
          Found in include/update_function.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

          Method xoops_module_update_news has 149 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function xoops_module_update_news()
          {
              global $xoopsDB;
              $errors = 0;
          
          
          Severity: Major
          Found in include/update_function.php - About 5 hrs to fix

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

                foreach ($lessreadednews as $storyid => $data) {
                    $url1  = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/index.php?storytopic=' . $data['topicid'];
                    $url2  = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/article.php?storyid=' . $storyid;
                    $url3  = XOOPS_URL . '/userinfo.php?uid=' . $data['uid'];
                    $class = ('even' === $class) ? 'odd' : 'even';
            Severity: Major
            Found in admin/index.php and 1 other location - About 5 hrs to fix
            admin/index.php on lines 1564..1579

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

            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

                foreach ($mostreadednews as $storyid => $data) {
                    $url1  = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/index.php?storytopic=' . $data['topicid'];
                    $url2  = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/article.php?storyid=' . $storyid;
                    $url3  = XOOPS_URL . '/userinfo.php?uid=' . $data['uid'];
                    $class = ('even' === $class) ? 'odd' : 'even';
            Severity: Major
            Found in admin/index.php and 1 other location - About 5 hrs to fix
            admin/index.php on lines 1586..1601

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

            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 XoopsStory.php has 412 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php declare(strict_types=1);
            
            namespace XoopsModules\News;
            
            use MyTextSanitizer;
            Severity: Minor
            Found in class/XoopsStory.php - About 5 hrs to fix

              Method listBlocks has 144 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function listBlocks(): void
                  {
                      global $xoopsModule, $pathIcon16;
                      require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
                      //        xoops_loadLanguage('admin', 'system');
              Severity: Major
              Found in class/Common/Blocksadmin.php - About 5 hrs to fix

                Method getStats has 144 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function getStats(): void
                {
                    global $xoopsModule, $xoopsConfig;
                    xoops_cp_header();
                    $myts   = \MyTextSanitizer::getInstance();
                Severity: Major
                Found in admin/index.php - About 5 hrs to fix

                  Function topicsmanager has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function topicsmanager(): void
                  {
                      global $xoopsDB, $xoopsConfig, $xoopsModule, $myts;
                      require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
                      xoops_cp_header();
                  Severity: Minor
                  Found in admin/index.php - About 5 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

                      public function topic_imgurl($format = 'S')
                      {
                          if ('' === \trim($this->topic_imgurl)) {
                              $this->topic_imgurl = 'blank.png';
                          }
                  Severity: Major
                  Found in class/NewsStory.php and 1 other location - About 5 hrs to fix
                  class/NewsTopic.php on lines 563..585

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

                  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 bodytext($format = 'Show')
                      {
                          $myts   = MyTextSanitizer::getInstance();
                          $html   = 1;
                          $smiley = 1;
                  Severity: Major
                  Found in class/XoopsStory.php and 1 other location - About 5 hrs to fix
                  class/XoopsStory.php on lines 455..483

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

                  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 hometext($format = 'Show')
                      {
                          $myts   = MyTextSanitizer::getInstance();
                          $html   = 1;
                          $smiley = 1;
                  Severity: Major
                  Found in class/XoopsStory.php and 1 other location - About 5 hrs to fix
                  class/XoopsStory.php on lines 490..518

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

                  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 function topic_imgurl($format = 'S')
                      {
                          if ('' === \trim($this->topic_imgurl)) {
                              $this->topic_imgurl = 'blank.png';
                          }
                  Severity: Major
                  Found in class/NewsTopic.php and 1 other location - About 5 hrs to fix
                  class/NewsStory.php on lines 725..747

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

                  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