XoopsModules25x/news

View on GitHub

Showing 310 of 310 total issues

Avoid deeply nested control flow statements.
Open

                            if (is_file($templateFolder . $v)) {
                                unlink($templateFolder . $v);
                            }
Severity: Major
Found in include/onupdate.php - About 45 mins to fix

    Method resizePicture has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            $src_path,
            $dst_path,
            $param_width,
            $param_height,
            $keep_original = false,
    Severity: Minor
    Found in class/Utility.php - About 45 mins to fix

      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

      Avoid deeply nested control flow statements.
      Open

                                  if (file_exists($newName)) {
                                      @unlink($fullPictureName);
                                      rename($newName, $fullPictureName);
                                  }
      Severity: Major
      Found in submit.php - About 45 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

        Avoid deeply nested control flow statements.
        Open

                                        if (!$sfiles->store()) {
                                            echo _AM_UPLOAD_DBERROR_SAVE;
                                        }
        Severity: Major
        Found in submit.php - About 45 mins to fix

          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

          Avoid deeply nested control flow statements.
          Open

                              if (!unlink($currentPicture)) {
                                  trigger_error('Error, impossible to delete the picture attached to this article');
                              }
          Severity: Major
          Found in submit.php - About 45 mins to fix

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

                if (News\Utility::existTable($xoopsDB->prefix('topics'))) {
                    $sql    = 'ALTER TABLE ' . $xoopsDB->prefix('topics') . ' RENAME ' . $xoopsDB->prefix('news_topics');
                    $result = $xoopsDB->queryF($sql);
                    if (!$result) {
                        echo '<br>' . _AM_NEWS_UPGRADEFAILED . ' ' . _AM_NEWS_UPGRADEFAILED2;
            Severity: Major
            Found in include/update_function.php and 2 other locations - About 45 mins to fix
            include/update_function.php on lines 56..63
            include/update_function.php on lines 74..81

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

            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 (News\Utility::existTable($xoopsDB->prefix('stories'))) {
                    $sql    = 'ALTER TABLE ' . $xoopsDB->prefix('stories') . ' RENAME ' . $xoopsDB->prefix('news_stories');
                    $result = $xoopsDB->queryF($sql);
                    if (!$result) {
                        echo '<br>' . _AM_NEWS_UPGRADEFAILED . ' ' . _AM_NEWS_UPGRADEFAILED2;
            Severity: Major
            Found in include/update_function.php and 2 other locations - About 45 mins to fix
            include/update_function.php on lines 65..72
            include/update_function.php on lines 74..81

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

            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 (News\Utility::existTable($xoopsDB->prefix('stories_files'))) {
                    $sql    = 'ALTER TABLE ' . $xoopsDB->prefix('stories_files') . ' RENAME ' . $xoopsDB->prefix('news_stories_files');
                    $result = $xoopsDB->queryF($sql);
                    if (!$result) {
                        echo '<br>' . _AM_NEWS_UPGRADEFAILED . ' ' . _AM_NEWS_UPGRADEFAILED2;
            Severity: Major
            Found in include/update_function.php and 2 other locations - About 45 mins to fix
            include/update_function.php on lines 56..63
            include/update_function.php on lines 65..72

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

            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

            Consider simplifying this complex logical expression.
            Open

                        if ($oldtitle[$i] !== $title[$i]
                            || $oldweight[$i] !== $weight[$i]
                            || $oldvisible[$i] !== $visible[$i]
                            || $oldside[$i] !== $side[$i]
                            || $oldbcachetime[$i] !== $bcachetime[$i]
            Severity: Major
            Found in class/Common/Blocksadmin.php - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                          if ((0 == $options[5]) && (1 == $options[4])
                              && (($options[6] > 0 && $options[6] == $story->storyid())
                                  || (0 == $options[6] && 0 == $key))) {
                              $spotlight = [];
                              $visible   = true;
              Severity: Major
              Found in blocks/news_top.php - About 40 mins to fix

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

                    protected function addSelectOptions($element, $fieldName, $key, $prefix_orig, $prefix_curr = ''): void
                Severity: Minor
                Found in class/ObjectTree.php - About 35 mins to fix

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

                  function news_search($queryarray, $andor, $limit, $offset, $userid)
                  Severity: Minor
                  Found in include/search.inc.php - About 35 mins to fix

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

                        public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
                    Severity: Minor
                    Found in class/Common/SysUtility.php - About 35 mins to fix

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

                          public function getChildTreeArray($sel_id = 0, $order = '', $perms = '', $parray = [], $r_prefix = '')
                      Severity: Minor
                      Found in class/NewsTopic.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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              public function __construct($total_items, $items_perpage, $current_start, $start_name = 'start', $extra_arg = '')
                          Severity: Minor
                          Found in class/PageNav.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
                              Severity
                              Category
                              Status
                              Source
                              Language