mambax7/publisher

View on GitHub

Showing 3,032 of 3,032 total issues

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

function publisher_category_items_sel_show($options)
{
    $helper = Helper::getInstance();

    $block = $item = [];
Severity: Minor
Found in blocks/category_items_sel.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 resizeAndCrop has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function resizeAndCrop()
    {
        // check file extension
        switch ($this->imageMimetype) {
            case 'image/png':
Severity: Minor
Found in class/Resizer.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 getAdminLinks has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAdminLinks($icons)
    {
        $adminLinks = '';
        if (\is_object($GLOBALS['xoopsUser'])
            && (Utility::userIsAdmin() || Utility::userIsAuthor($this)
Severity: Minor
Found in class/Item.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

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

        if (static::getPathStatus('images/category', true) < 0) {
            $thePath = static::getImageDir('category');
            $res     = static::mkdir($thePath);

            if ($res) {
Severity: Major
Found in class/Utility.php and 1 other location - About 1 hr to fix
class/Utility.php on lines 128..138

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

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 (static::getPathStatus('images/item', true) < 0) {
            $thePath = static::getImageDir('item');
            $res     = static::mkdir($thePath);

            if ($res) {
Severity: Major
Found in class/Utility.php and 1 other location - About 1 hr to fix
class/Utility.php on lines 116..126

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

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

            function showImage(i) {

                // optional parameter i
                i = i || cur;

Severity: Minor
Found in assets/js/jquery.popeye-2.1.js - About 1 hr to fix

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

        public function __construct($id = null)
        {
            //        $this->helper = Helper::getInstance();
            $this->db = \XoopsDatabaseFactory::getDatabaseConnection();
            $this->initVar('itemid', \XOBJ_DTYPE_INT, 0);
    Severity: Minor
    Found in class/Item.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 getArticle has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getArticle(Item $itemObj, Category $categoryObj, \XoopsUser $xoopsUser, Helper $helper)
            {
                $itemImage = $itemObj->getVar('image');
                if (isset($itemImage)) {
                    $imageHandler = xoops_getHandler('image');
        Severity: Minor
        Found in class/Jsonld.php - About 1 hr to fix

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

              foreach ($newCatArray as $oldid => $newCat) {
                  $criteria = new \CriteriaCompo();
                  $criteria->add(new \Criteria('categoryid', $newCat['newid']));
                  $oldpid = $newCat['oldpid'];
                  if (0 == $oldpid) {
          Severity: Major
          Found in admin/import/news.php and 5 other locations - About 1 hr to fix
          admin/import/ams.php on lines 415..427
          admin/import/smartsection.php on lines 231..243
          admin/import/wfsection.php on lines 246..258
          admin/import/xfsection.php on lines 244..256
          admin/import/xnews.php on lines 414..426

          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

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

              foreach ($newCatArray as $oldid => $newCat) {
                  $criteria = new \CriteriaCompo();
                  $criteria->add(new \Criteria('categoryid', $newCat['newid']));
                  $oldpid = $newCat['oldpid'];
                  if (0 == $oldpid) {
          Severity: Major
          Found in admin/import/wfsection.php and 5 other locations - About 1 hr to fix
          admin/import/ams.php on lines 415..427
          admin/import/news.php on lines 252..264
          admin/import/smartsection.php on lines 231..243
          admin/import/xfsection.php on lines 244..256
          admin/import/xnews.php on lines 414..426

          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

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

              foreach ($newCatArray as $oldid => $newCat) {
                  $criteria = new \CriteriaCompo();
                  $criteria->add(new \Criteria('categoryid', $newCat['newid']));
                  $oldpid = $newCat['oldpid'];
                  if (0 == $oldpid) {
          Severity: Major
          Found in admin/import/ams.php and 5 other locations - About 1 hr to fix
          admin/import/news.php on lines 252..264
          admin/import/smartsection.php on lines 231..243
          admin/import/wfsection.php on lines 246..258
          admin/import/xfsection.php on lines 244..256
          admin/import/xnews.php on lines 414..426

          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

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

              foreach ($newCatArray as $oldid => $newCat) {
                  $criteria = new \CriteriaCompo();
                  $criteria->add(new \Criteria('categoryid', $newCat['newid']));
                  $oldpid = $newCat['oldpid'];
                  if (0 == $oldpid) {
          Severity: Major
          Found in admin/import/xnews.php and 5 other locations - About 1 hr to fix
          admin/import/ams.php on lines 415..427
          admin/import/news.php on lines 252..264
          admin/import/smartsection.php on lines 231..243
          admin/import/wfsection.php on lines 246..258
          admin/import/xfsection.php on lines 244..256

          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

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

              foreach ($newCatArray as $oldid => $newCat) {
                  $criteria = new \CriteriaCompo();
                  $criteria->add(new \Criteria('categoryid', $newCat['newid']));
                  $oldpid = $newCat['oldpid'];
                  if (0 == $oldpid) {
          Severity: Major
          Found in admin/import/smartsection.php and 5 other locations - About 1 hr to fix
          admin/import/ams.php on lines 415..427
          admin/import/news.php on lines 252..264
          admin/import/wfsection.php on lines 246..258
          admin/import/xfsection.php on lines 244..256
          admin/import/xnews.php on lines 414..426

          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

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

              foreach ($newCatArray as $oldid => $newCat) {
                  $criteria = new \CriteriaCompo();
                  $criteria->add(new \Criteria('categoryid', $newCat['newid']));
                  $oldpid = $newCat['oldpid'];
                  if (0 == $oldpid) {
          Severity: Major
          Found in admin/import/xfsection.php and 5 other locations - About 1 hr to fix
          admin/import/ams.php on lines 415..427
          admin/import/news.php on lines 252..264
          admin/import/smartsection.php on lines 231..243
          admin/import/wfsection.php on lines 246..258
          admin/import/xnews.php on lines 414..426

          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

          The class Timthumb has 21 fields. Consider redesigning Timthumb to keep the number of fields under 15.
          Open

          class Timthumb
          {
              protected        $src                      = '';
              protected        $is404                    = false;
              protected        $docRoot                  = '';
          Severity: Minor
          Found in thumb.php by phpmd

          TooManyFields

          Since: 0.1

          Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

          Example

          class Person {
             protected $one;
             private $two;
             private $three;
             [... many more fields ...]
          }

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

          The class Category has 17 fields. Consider redesigning Category to keep the number of fields under 15.
          Open

          class Category extends \XoopsObject
          {
              /**
               * @var Helper
               */
          Severity: Minor
          Found in class/Category.php by phpmd

          TooManyFields

          Since: 0.1

          Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

          Example

          class Person {
             protected $one;
             private $two;
             private $three;
             [... many more fields ...]
          }

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

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

          function saveSampleData(): void
          {
              global $xoopsConfig;
              $moduleDirName      = \basename(\dirname(__DIR__));
              $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
          Severity: Minor
          Found in testdata/index.php - About 1 hr to fix

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

                public function sendNotifications($notifications = []): void
                {
                    /** @var \XoopsNotificationHandler $notificationHandler */
                    $notificationHandler = \xoops_getHandler('notification');
                    $tags                = [];
            Severity: Minor
            Found in class/Item.php - About 1 hr to fix

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

              function publisher_tag_iteminfo(&$items)
              {
                  if (empty($items) || !is_array($items)) {
                      return false;
                  }
              Severity: Minor
              Found in include/plugin.tag.php - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language