XoopsModules25x/news

View on GitHub

Showing 310 of 310 total issues

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

function b_news_topicsnav_show($options)
{
    /** @var Helper $helper */
    if (!class_exists(Helper::class)) {
        return false;
Severity: Minor
Found in blocks/news_topicsnav.php - About 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

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

    public static function deleteDirectory($src)
    {
        // Only continue if user is a 'global' Admin
        if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
            return false;
Severity: Minor
Found in class/Common/FilesManagement.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

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

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

if ($approveprivilege) {
    //Show topic image?
    $sform->addElement(new \XoopsFormRadioYN(_AM_TOPICDISPLAY, 'topicdisplay', $topicdisplay));
    //Select image position
    $posselect = new \XoopsFormSelect(_AM_TOPICALIGN, 'topicalign', $topicalign);
Severity: Major
Found in include/storyform.inc.php and 1 other location - About 2 hrs to fix
include/storyform.original.php on lines 69..80

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

if ($approveprivilege) {
    //Show topic image?
    $sform->addElement(new \XoopsFormRadioYN(_AM_TOPICDISPLAY, 'topicdisplay', $topicdisplay));
    //Select image position
    $posselect = new \XoopsFormSelect(_AM_TOPICALIGN, 'topicalign', $topicalign);
Severity: Major
Found in include/storyform.original.php and 1 other location - About 2 hrs to fix
include/storyform.inc.php on lines 63..74

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

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

XoopsTopic has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class XoopsTopic
{
    public $db;
    public $table;
    public $topic_id;
Severity: Minor
Found in class/XoopsTopic.php - About 2 hrs to fix

    Files has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Files
    {
        public $db;
        public $table;
        public $fileid;
    Severity: Minor
    Found in class/Files.php - About 2 hrs to fix

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

      function b_news_randomnews_show($options)
      {
          /** @var Helper $helper */
          if (!class_exists(Helper::class)) {
              return false;
      Severity: Major
      Found in blocks/news_randomnews.php - About 2 hrs to fix

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

        function getMetagen(): void
        {
            require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
            global $xoopsModule, $xoopsConfig, $cfg;
            $helper = Helper::getInstance();
        Severity: Major
        Found in admin/index.php - About 2 hrs to fix

          Method news_getWysiwygForm has 57 lines of code (exceeds 25 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: Major
          Found in include/functions.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

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

                    public static function getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental = '')
                    {
                        $editor_option            = \mb_strtolower(static::getModuleOption('form_options'));
                        $editor                   = false;
                        $editor_configs           = [];
                Severity: Major
                Found in class/Utility.php - About 2 hrs to fix

                  Function launchNewsletter has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function launchNewsletter(): void
                  {
                      global $xoopsConfig, $dateformat;
                      xoops_cp_header();
                      $adminObject = Admin::getInstance();
                  Severity: Minor
                  Found in admin/index.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

                  Function render has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function render(?array $block = null): void
                      {
                          \xoops_load('XoopsFormLoader');
                          \xoops_loadLanguage('common', $this->moduleDirNameUpper);
                  
                  
                  Severity: Minor
                  Found in class/Common/Blocksadmin.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 xoops_module_update_news has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function xoops_module_update_news(\XoopsModule $module, $previousVersion = null)
                  {
                      $moduleDirName      = \basename(\dirname(__DIR__));
                      $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
                  
                  
                  Severity: Major
                  Found in include/onupdate.php - About 2 hrs to fix

                    Method expStories has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function expStories(): void
                    {
                        global $dateformat, $pathIcon16;
                        $start        = Request::getInt('startexp', 0, 'GET');
                        $expiredcount = NewsStory::getAllStoriesCount(1, false);
                    Severity: Major
                    Found in admin/index.php - About 2 hrs to fix

                      Function news_createmeta_keywords has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function news_createmeta_keywords($content)
                      {
                          require_once XOOPS_ROOT_PATH . '/modules/news/config.php';
                          // require_once XOOPS_ROOT_PATH . '/modules/news/class/blacklist.php';
                          // require_once XOOPS_ROOT_PATH . '/modules/news/class/registryfile.php';
                      Severity: Minor
                      Found in include/functions.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

                      Function createMetaKeywords has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function createMetaKeywords($content)
                          {
                              global $cfg;
                              require_once XOOPS_ROOT_PATH . '/modules/news/config.php';
                              // require_once XOOPS_ROOT_PATH . '/modules/news/class/blacklist.php';
                      Severity: Minor
                      Found in class/Utility.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 isBlockCloned has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
                          {
                              \xoops_loadLanguage('admin', 'system');
                              \xoops_loadLanguage('admin/blocksadmin', 'system');
                              \xoops_loadLanguage('admin/groups', 'system');
                      Severity: Major
                      Found in class/Common/Blocksadmin.php - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language