XoopsModules25x/news

View on GitHub
class/NewsStory.php

Summary

Maintainability
F
2 wks
Test Coverage

File NewsStory.php has 1244 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace XoopsModules\News;

/*
Severity: Major
Found in class/NewsStory.php - About 3 days to fix

    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

      Function getAllPublished has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getAllPublished(
              $limit = 0,
              $start = 0,
              $checkRight = false,
              $topic = 0,
      Severity: Minor
      Found in class/NewsStory.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

      Function getRandomNews has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getRandomNews(
              $limit = 0,
              $start = 0,
              $checkRight = false,
              $topic = 0,
      Severity: Minor
      Found in class/NewsStory.php - About 4 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 prepare2show has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function prepare2show($filescount)
          {
              global $xoopsUser, $xoopsConfig, $xoopsModule;
              /** @var News\Helper $helper */
              $helper = Helper::getInstance();
      Severity: Minor
      Found in class/NewsStory.php - About 4 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 prepare2show has 110 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function prepare2show($filescount)
          {
              global $xoopsUser, $xoopsConfig, $xoopsModule;
              /** @var News\Helper $helper */
              $helper = Helper::getInstance();
      Severity: Major
      Found in class/NewsStory.php - About 4 hrs to fix

        Method store has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function store($approved = false)
            {
                $myts        = \MyTextSanitizer::getInstance();
                $counter     = $this->counter ?? 0;
                $title       = $GLOBALS['xoopsDB']->escape($myts->censorString($this->title));
        Severity: Major
        Found in class/NewsStory.php - About 3 hrs to fix

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

              public function getStats($limit)
              {
                  $ret = [];
                  /** @var \XoopsMySQLDatabase $db */
                  $db   = \XoopsDatabaseFactory::getDatabaseConnection();
          Severity: Major
          Found in class/NewsStory.php - About 3 hrs to fix

            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

              Function getBigStory has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getBigStory(
                      $limit = 0,
                      $start = 0,
                      $checkRight = false,
                      $topic = 0,
              Severity: Minor
              Found in class/NewsStory.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 getRandomNews has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getRandomNews(
                      $limit = 0,
                      $start = 0,
                      $checkRight = false,
                      $topic = 0,
              Severity: Major
              Found in class/NewsStory.php - About 2 hrs to fix

                Method getAllPublished has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function getAllPublished(
                        $limit = 0,
                        $start = 0,
                        $checkRight = false,
                        $topic = 0,
                Severity: Major
                Found in class/NewsStory.php - About 2 hrs to fix

                  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

                  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

                  Method getBigStory has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getBigStory(
                          $limit = 0,
                          $start = 0,
                          $checkRight = false,
                          $topic = 0,
                  Severity: Minor
                  Found in class/NewsStory.php - About 1 hr to fix

                    Method uname has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function uname($uid = 0)
                        {
                            global $xoopsConfig;
                            static $tblusers = [];
                            $option = -1;
                    Severity: Minor
                    Found in class/NewsStory.php - About 1 hr to fix

                      Method getStoriesByIds has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getStoriesByIds(
                              $ids,
                              $checkRight = true,
                              $asobject = true,
                              $order = 'published',
                      Severity: Minor
                      Found in class/NewsStory.php - About 1 hr to fix

                        Function getStats has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getStats($limit)
                            {
                                $ret = [];
                                /** @var \XoopsMySQLDatabase $db */
                                $db   = \XoopsDatabaseFactory::getDatabaseConnection();
                        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

                        Function getStoriesByIds has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getStoriesByIds(
                                $ids,
                                $checkRight = true,
                                $asobject = true,
                                $order = 'published',
                        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 deleteBeforeDate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function deleteBeforeDate($timestamp, $expired, $topicslist = '')
                            {
                                global $xoopsModule;
                                /** @var \XoopsMySQLDatabase $db */
                                $db           = \XoopsDatabaseFactory::getDatabaseConnection();
                        Severity: Minor
                        Found in class/NewsStory.php - About 1 hr to fix

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

                              public static function getAllStoriesCount($storytype = 1, $checkRight = false)
                              {
                                  /** @var \XoopsMySQLDatabase $db */
                                  $db  = \XoopsDatabaseFactory::getDatabaseConnection();
                                  $sql = 'SELECT count(*) AS cpt FROM ' . $db->prefix('news_stories') . ' WHERE ';
                          Severity: Minor
                          Found in class/NewsStory.php - About 1 hr to fix

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

                                public function bodytext($format = 'Show')
                                {
                                    $myts   = \MyTextSanitizer::getInstance();
                                    $html   = 1;
                                    $smiley = 1;
                            Severity: Minor
                            Found in class/NewsStory.php - About 1 hr to fix

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

                                  public function adminlink()
                                  {
                                      global $xoopsModule;
                                      $dirname = \basename(\dirname(__DIR__));
                                      /** @var \XoopsModuleHandler $moduleHandler */
                              Severity: Minor
                              Found in class/NewsStory.php - About 1 hr to fix

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

                                    public function exportNews(
                                        $fromdate,
                                        $todate,
                                        $topicslist,
                                        $usetopicsdef,
                                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 auto_summary has 27 lines of code (exceeds 25 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

                                  Method getAllSubmitted has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public static function getAllSubmitted($limit = 0, $asobject = true, $checkRight = false, $start = 0)
                                      {
                                          /** @var \XoopsMySQLDatabase $db */
                                          $db       = \XoopsDatabaseFactory::getDatabaseConnection();
                                          $myts     = \MyTextSanitizer::getInstance();
                                  Severity: Minor
                                  Found in class/NewsStory.php - About 1 hr to fix

                                    Method exportNews has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function exportNews(
                                            $fromdate,
                                            $todate,
                                            $topicslist,
                                            $usetopicsdef,
                                    Severity: Minor
                                    Found in class/NewsStory.php - About 1 hr to fix

                                      Method hometext has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public function hometext($format = 'Show')
                                          {
                                              $hometext = '';
                                              $myts     = \MyTextSanitizer::getInstance();
                                              $html     = $smiley = $xcodes = 1;
                                      Severity: Minor
                                      Found in class/NewsStory.php - About 1 hr to fix

                                        Method _searchPreviousOrNextArticle has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            public function _searchPreviousOrNextArticle($storyid, $next = true, $checkRight = false)
                                            {
                                                /** @var \XoopsMySQLDatabase $db */
                                                $db      = \XoopsDatabaseFactory::getDatabaseConnection();
                                                $ret     = [];
                                        Severity: Minor
                                        Found in class/NewsStory.php - About 1 hr to fix

                                          Method getAllPublished has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                                  $limit = 0,
                                                  $start = 0,
                                                  $checkRight = false,
                                                  $topic = 0,
                                                  $ihome = 0,
                                          Severity: Major
                                          Found in class/NewsStory.php - About 1 hr to fix

                                            Function store has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public function store($approved = false)
                                                {
                                                    $myts        = \MyTextSanitizer::getInstance();
                                                    $counter     = $this->counter ?? 0;
                                                    $title       = $GLOBALS['xoopsDB']->escape($myts->censorString($this->title));
                                            Severity: Minor
                                            Found in class/NewsStory.php - About 55 mins 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 uname has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public function uname($uid = 0)
                                                {
                                                    global $xoopsConfig;
                                                    static $tblusers = [];
                                                    $option = -1;
                                            Severity: Minor
                                            Found in class/NewsStory.php - About 55 mins 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 _searchPreviousOrNextArticle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public function _searchPreviousOrNextArticle($storyid, $next = true, $checkRight = false)
                                                {
                                                    /** @var \XoopsMySQLDatabase $db */
                                                    $db      = \XoopsDatabaseFactory::getDatabaseConnection();
                                                    $ret     = [];
                                            Severity: Minor
                                            Found in class/NewsStory.php - About 55 mins 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 getAllStoriesCount has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public static function getAllStoriesCount($storytype = 1, $checkRight = false)
                                                {
                                                    /** @var \XoopsMySQLDatabase $db */
                                                    $db  = \XoopsDatabaseFactory::getDatabaseConnection();
                                                    $sql = 'SELECT count(*) AS cpt FROM ' . $db->prefix('news_stories') . ' WHERE ';
                                            Severity: Minor
                                            Found in class/NewsStory.php - About 55 mins 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 getAllSubmitted has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public static function getAllSubmitted($limit = 0, $asobject = true, $checkRight = false, $start = 0)
                                                {
                                                    /** @var \XoopsMySQLDatabase $db */
                                                    $db       = \XoopsDatabaseFactory::getDatabaseConnection();
                                                    $myts     = \MyTextSanitizer::getInstance();
                                            Severity: Minor
                                            Found in class/NewsStory.php - About 55 mins 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 getRandomNews has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                    $limit = 0,
                                                    $start = 0,
                                                    $checkRight = false,
                                                    $topic = 0,
                                                    $ihome = 0,
                                            Severity: Major
                                            Found in class/NewsStory.php - About 50 mins to fix

                                              Method exportNews has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                      $fromdate,
                                                      $todate,
                                                      $topicslist,
                                                      $usetopicsdef,
                                                      &$tbltopics,
                                              Severity: Major
                                              Found in class/NewsStory.php - About 50 mins to fix

                                                Method getBigStory has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                        $limit = 0,
                                                        $start = 0,
                                                        $checkRight = false,
                                                        $topic = 0,
                                                        $ihome = 0,
                                                Severity: Major
                                                Found in class/NewsStory.php - About 50 mins to fix

                                                  Function deleteBeforeDate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      public function deleteBeforeDate($timestamp, $expired, $topicslist = '')
                                                      {
                                                          global $xoopsModule;
                                                          /** @var \XoopsMySQLDatabase $db */
                                                          $db           = \XoopsDatabaseFactory::getDatabaseConnection();
                                                  Severity: Minor
                                                  Found in class/NewsStory.php - About 45 mins 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 getArchive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      public function getArchive(
                                                          $publish_start,
                                                          $publish_end,
                                                          $checkRight = false,
                                                          $asobject = true,
                                                  Severity: Minor
                                                  Found in class/NewsStory.php - About 45 mins 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 countPublishedByTopic has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      public static function countPublishedByTopic($topicid = 0, $checkRight = false)
                                                      {
                                                          /** @var \XoopsMySQLDatabase $db */
                                                          $db  = \XoopsDatabaseFactory::getDatabaseConnection();
                                                          $sql = 'SELECT COUNT(*) FROM ' . $db->prefix('news_stories') . ' WHERE published > 0 AND published <= ' . \time() . ' AND (expired = 0 OR expired > ' . \time() . ')';
                                                  Severity: Minor
                                                  Found in class/NewsStory.php - About 45 mins 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 getStoriesByIds has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                  Open

                                                          $ids,
                                                          $checkRight = true,
                                                          $asobject = true,
                                                          $order = 'published',
                                                          $onlyOnline = true
                                                  Severity: Minor
                                                  Found in class/NewsStory.php - About 35 mins to fix

                                                    Method getArchive has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                            $publish_start,
                                                            $publish_end,
                                                            $checkRight = false,
                                                            $asobject = true,
                                                            $order = 'published'
                                                    Severity: Minor
                                                    Found in class/NewsStory.php - About 35 mins to fix

                                                      Method getAllExpired has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                          public static function getAllExpired($limit = 0, $start = 0, $topic = 0, $ihome = 0, $asobject = true)
                                                      Severity: Minor
                                                      Found in class/NewsStory.php - About 35 mins to fix

                                                        Function hometext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            public function hometext($format = 'Show')
                                                            {
                                                                $hometext = '';
                                                                $myts     = \MyTextSanitizer::getInstance();
                                                                $html     = $smiley = $xcodes = 1;
                                                        Severity: Minor
                                                        Found in class/NewsStory.php - About 35 mins 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 bodytext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            public function bodytext($format = 'Show')
                                                            {
                                                                $myts   = \MyTextSanitizer::getInstance();
                                                                $html   = 1;
                                                                $smiley = 1;
                                                        Severity: Minor
                                                        Found in class/NewsStory.php - About 35 mins 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

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                return null;
                                                        Severity: Major
                                                        Found in class/NewsStory.php - About 30 mins to fix

                                                          Function topic_imgurl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function topic_imgurl($format = 'S')
                                                              {
                                                                  if ('' === \trim($this->topic_imgurl)) {
                                                                      $this->topic_imgurl = 'blank.png';
                                                                  }
                                                          Severity: Minor
                                                          Found in class/NewsStory.php - About 25 mins 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 getAllExpired has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public static function getAllExpired($limit = 0, $start = 0, $topic = 0, $ihome = 0, $asobject = true)
                                                              {
                                                                  /** @var \XoopsMySQLDatabase $db */
                                                                  $db   = \XoopsDatabaseFactory::getDatabaseConnection();
                                                                  $myts = \MyTextSanitizer::getInstance();
                                                          Severity: Minor
                                                          Found in class/NewsStory.php - About 25 mins 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 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

                                                          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 3 locations. Consider refactoring.
                                                          Open

                                                                  if (0 != (int)$topic) {
                                                                      if (!\is_array($topic)) {
                                                                          $sql .= ' AND topicid=' . (int)$topic . ' AND (ihome=1 OR ihome=0)';
                                                                      } elseif (\count($topic) > 0) {
                                                                          $sql .= ' AND topicid IN (' . \implode(',', $topic) . ')';
                                                          Severity: Major
                                                          Found in class/NewsStory.php and 2 other locations - About 50 mins to fix
                                                          class/NewsStory.php on lines 236..271
                                                          class/NewsStory.php on lines 1306..1335

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

                                                          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 (0 != $topic) {
                                                                      if (!\is_array($topic)) {
                                                                          if ($checkRight) {
                                                                              $topics = Utility::getMyItemIds('news_view');
                                                                              if (!\in_array($topic, $topics, true)) {
                                                          Severity: Major
                                                          Found in class/NewsStory.php and 2 other locations - About 50 mins to fix
                                                          class/NewsStory.php on lines 368..389
                                                          class/NewsStory.php on lines 1306..1335

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

                                                          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 (0 != $topic) {
                                                                      if (!\is_array($topic)) {
                                                                          if ($checkRight) {
                                                                              $topics = Utility::getMyItemIds('news_view');
                                                                              if (!\in_array($topic, $topics, true)) {
                                                          Severity: Major
                                                          Found in class/NewsStory.php and 2 other locations - About 50 mins to fix
                                                          class/NewsStory.php on lines 236..271
                                                          class/NewsStory.php on lines 368..389

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

                                                          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

                                                          There are no issues that match your filters.

                                                          Category
                                                          Status