XoopsModules25x/tag

View on GitHub

Showing 1,477 of 1,477 total issues

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

<?php declare(strict_types=1);
/*
 You may not change or alter any portion of this comment or credits
 of supporting developers from this source code or any supporting source code
 which is considered copyrighted (c) material of the original comment or credit authors.
Severity: Major
Found in plugin/myalbum2.php and 1 other location - About 2 days to fix
plugin/myalbum1.php on lines 1..120

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

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

<?php declare(strict_types=1);
/*
 You may not change or alter any portion of this comment or credits
 of supporting developers from this source code or any supporting source code
 which is considered copyrighted (c) material of the original comment or credit authors.
Severity: Major
Found in plugin/myalbum1.php and 1 other location - About 2 days to fix
plugin/myalbum2.php on lines 1..119

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

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

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

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

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

Refactorings

Further Reading

File Blocksadmin.php has 593 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace XoopsModules\Tag\Common;

/**
Severity: Major
Found in class/Common/Blocksadmin.php - About 1 day to fix

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

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

      Function xoops_module_update_tag has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
      Open

      function xoops_module_update_tag(\XoopsModule $module, $previousVersion = null): bool
      {
          global $xoopsDB;
          $moduleDirName = \basename(\dirname(__DIR__));
      
      
      Severity: Minor
      Found in include/onupdate.php - About 1 day 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 truncateHtml has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function truncateHtml(
              string $text,
              ?int $length = 100,
              string $ending = '...',
              bool $exact = false,
      Severity: Minor
      Found in class/Common/SysUtility.php - About 1 day 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

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

      function tdmdownloads_tag_synchronization(int $mid): void
      {
          //    $itemHandler = $helper->getHandler('Downloads', 'tdmdownloads');
      
          /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $itemHandler */
      Severity: Major
      Found in plugin/tdmdownloads.php and 1 other location - About 7 hrs to fix
      plugin/smartsection.php on lines 85..118

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

      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

      function article_tag_synchronization(int $mid): void
      {
          /** @var \XoopsModules\Smartsection\ItemHandler $itemHandler */
          $itemHandler = \XoopsModules\Smartsection\Helper::getInstance()->getHandler('Item');
      
      
      Severity: Major
      Found in plugin/smartsection.php and 1 other location - About 7 hrs to fix
      plugin/tdmdownloads.php on lines 66..101

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

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

          public function updateByItem($tags, int $itemid, $modid = '', int $catid = 0): bool
          {
              if (!empty($modid) && !\is_numeric($modid)) {
                  if (($GLOBALS['xoopsModule'] instanceof \XoopsModule)
                      && ($modid == $GLOBALS['xoopsModule']->getVar('dirname'))) {
      Severity: Minor
      Found in class/TagHandler.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

      File TagHandler.php has 374 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php declare(strict_types=1);
      
      namespace XoopsModules\Tag;
      
      /*
      Severity: Minor
      Found in class/TagHandler.php - About 5 hrs to fix

        Function listBlocks has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            public function listBlocks(): void
            {
                global $xoopsModule, $pathIcon16;
                require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
                //        xoops_loadLanguage('admin', 'system');
        Severity: Minor
        Found in class/Common/Blocksadmin.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 update_stats has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            public function update_stats(int $tag_id, int $modid = 0, int $catid = 0): bool
            {
                if (0 === $tag_id) {
                    return true;
                }
        Severity: Minor
        Found in class/TagHandler.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 render has 95 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function render(?array $block = null)
            {
                \xoops_load('XoopsFormLoader');
                \xoops_loadLanguage('common', $this->moduleDirNameUpper);
        
        
        Severity: Major
        Found in class/Common/Blocksadmin.php - About 3 hrs to fix

          The class SysUtility has 11 public methods. Consider refactoring SysUtility to keep number of public methods under 10.
          Open

          class SysUtility
          {
              use VersionChecks;
          
              //checkVerXoops, checkVerPhp Traits
          Severity: Minor
          Found in class/Common/SysUtility.php by phpmd

          TooManyPublicMethods

          Since: 0.1

          A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

          By default it ignores methods starting with 'get' or 'set'.

          Example

          Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

          The class TagHandler has an overall complexity of 97 which is very high. The configured complexity threshold is 50.
          Open

          class TagHandler extends \XoopsPersistableObjectHandler
          {
              public $table_link;
              public $table_stats;
          
          
          Severity: Minor
          Found in class/TagHandler.php by phpmd

          The class Blocksadmin has an overall complexity of 80 which is very high. The configured complexity threshold is 50.
          Open

          class Blocksadmin
          {
              /**
               * @var \XoopsMySQLDatabase|null
               */
          Severity: Minor
          Found in class/Common/Blocksadmin.php by phpmd

          Function tag_block_top_show has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          function tag_block_top_show(array $options, string $dirname = '', int $catid = 0)
          {
              if (!xoops_isActiveModule('tag')) {
                  return false;
              }
          Severity: Minor
          Found in blocks/block.php - About 3 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 updateByItem has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function updateByItem($tags, int $itemid, $modid = '', int $catid = 0): bool
              {
                  if (!empty($modid) && !\is_numeric($modid)) {
                      if (($GLOBALS['xoopsModule'] instanceof \XoopsModule)
                          && ($modid == $GLOBALS['xoopsModule']->getVar('dirname'))) {
          Severity: Major
          Found in class/TagHandler.php - About 3 hrs to fix

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

                    $cache_select->addOptionArray([
                                                      0       => _NOCACHE,
                                                      30      => \sprintf(_SECONDS, 30),
                                                      60      => _MINUTE,
                                                      300     => \sprintf(_MINUTES, 5),
            Severity: Major
            Found in class/Common/Blocksadmin.php and 1 other location - About 2 hrs to fix
            class/Common/Blocksadmin.php on lines 123..135

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

            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 updateBlock has a Cognitive Complexity of 21 (exceeds 5 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 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

            Severity
            Category
            Status
            Source
            Language