XoopsModules25x/news

View on GitHub

Showing 310 of 310 total issues

Method b_news_archives_show has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function b_news_archives_show($options)
{
    global $xoopsDB, $xoopsConfig;
    // require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
    require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/calendar.php';
Severity: Minor
Found in blocks/news_archives.php - About 1 hr to fix

    Method b_news_topics_moderate has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function b_news_topics_moderate()
    {
        // require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
    
        /** @var Helper $helper */
    Severity: Minor
    Found in blocks/news_moderate.php - About 1 hr to fix

      Method updateBlock has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
          {
              $myblock = new \XoopsBlock($bid);
              $myblock->setVar('title', $btitle);
              $myblock->setVar('weight', $bweight);
      Severity: Minor
      Found in class/Common/Blocksadmin.php - About 1 hr to fix

        Function delTopic has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function delTopic(): void
        {
            global $xoopsDB, $xoopsModule;
            if (!isset($_POST['ok'])) {
                xoops_cp_header();
        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 loadTableFromArrayWithReplace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function loadTableFromArrayWithReplace($table, $data, $search, $replace)
        {
            /** @var \XoopsMySQLDatabase $db */
            $db = \XoopsDatabaseFactory::getDatabaseConnection();
        
        
        Severity: Minor
        Found in testdata/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 store has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function store($approved = false)
            {
                //$newpost = 0;
                $myts     = MyTextSanitizer::getInstance();
                $title    = $myts->censorString($this->title);
        Severity: Minor
        Found in class/XoopsStory.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_bigstory_show has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function b_news_bigstory_show()
        {
            // require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
        
            /** @var Helper $helper */
        Severity: Minor
        Found in blocks/news_bigstory.php - About 1 hr to fix

          Method news_html2text has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function news_html2text($document)
          {
              // PHP Manual:: function preg_replace
              // $document should contain an HTML document.
              // This will remove HTML tags, javascript sections
          Severity: Minor
          Found in include/functions.php - About 1 hr to fix

            Method html2text has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function html2text($document)
                {
                    // PHP Manual:: function preg_replace
                    // $document should contain an HTML document.
                    // This will remove HTML tags, javascript sections
            Severity: Minor
            Found in class/Utility.php - About 1 hr to fix

              Method b_news_randomnews_edit has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function b_news_randomnews_edit($options)
              {
                  global $xoopsDB;
                  $form = _MB_NEWS_ORDER . "&nbsp;<select name='options[]'>";
                  $form .= "<option value='published'";
              Severity: Minor
              Found in blocks/news_randomnews.php - About 1 hr to fix

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

                            if (0 == $options[5]) { // Use a specific news
                                if ($visible) {
                                    $spotlightArticle = new NewsStory($options[6]);
                                } else {
                                    $block['use_spotlight'] = false;
                Severity: Major
                Found in blocks/news_top.php and 1 other location - About 1 hr to fix
                blocks/news_top.php on lines 196..207

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

                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 (0 == $options[5]) { // Use a specific news
                                $tmpstory = $permstory ?? new NewsStory($options[6]);
                            } else { // Use the most recent news
                                $stories = [];
                                $stories = NewsStory::getAllPublished(1, 0, $restricted, 0, 1, true, $options[0]);
                Severity: Major
                Found in blocks/news_top.php and 1 other location - About 1 hr to fix
                blocks/news_top.php on lines 512..527

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

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

                      public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = ''): void
                      {
                          if ('' == $sel_name) {
                              $sel_name = $this->id;
                          }
                  Severity: Minor
                  Found in class/XoopsTree.php - About 1 hr to fix

                    Method makeMySelBox has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function makeMySelBox(
                            $title,
                            $order,
                            $preset_id,
                            $none,
                    Severity: Minor
                    Found in class/NewsTopic.php - About 1 hr to fix

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

                              if ($display) {
                                  $ret[$i]['image'] = 'assets/images/news.png';
                                  $ret[$i]['link']  = 'article.php?storyid=' . $myrow['storyid'] . $searchparam;
                                  $ret[$i]['title'] = $myrow['title'];
                                  $ret[$i]['time']  = $myrow['created'];
                      Severity: Major
                      Found in include/search.inc.php and 1 other location - About 1 hr to fix
                      include/search.inc.php on lines 125..132

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

                      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 ($display) {
                                      $ret[$i]['image'] = 'assets/images/news.png';
                                      $ret[$i]['link']  = 'article.php?storyid=' . $myrow['com_itemid'] . $searchparam;
                                      $ret[$i]['title'] = $myrow['com_title'];
                                      $ret[$i]['time']  = $myrow['com_created'];
                      Severity: Major
                      Found in include/search.inc.php and 1 other location - About 1 hr to fix
                      include/search.inc.php on lines 82..89

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

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

                          public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = ''): void
                          {
                              if ('' == $sel_name) {
                                  $sel_name = $this->id;
                              }
                      Severity: Minor
                      Found in class/XoopsTree.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 news_getWysiwygForm has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function news_getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental = '')
                      {
                          $editor_option            = \mb_strtolower(news_getmoduleoption('form_options'));
                          $editor                   = false;
                          $editor_configs           = [];
                      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 news_getmoduleoption has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function news_getmoduleoption($option, $repmodule = 'news')
                      {
                          global $xoopsModuleConfig, $xoopsModule;
                          static $tbloptions = [];
                          if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) {
                      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

                      Severity
                      Category
                      Status
                      Source
                      Language