mambax7/publisher

View on GitHub

Showing 3,032 of 3,032 total issues

File MimetypesUtility.php has 642 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace XoopsModules\Publisher;

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

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

            if ($totalitems > 0) {
                for ($i = 0; $i < $totalItemsOnPage; ++$i) {
                    $categoryObj = $itemsObj[$i]->getCategory();
    
                    $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['edit'] . '</a>';
    Severity: Major
    Found in admin/item.php and 1 other location - About 1 day to fix
    admin/item.php on lines 309..333

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

    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 ($totalitems > 0) {
                for ($i = 0; $i < $totalItemsOnPage; ++$i) {
                    $categoryObj = $itemsObj[$i]->getCategory();
    
                    $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['edit'] . '</a>';
    Severity: Major
    Found in admin/item.php and 1 other location - About 1 day to fix
    admin/item.php on lines 253..277

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

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

    function publisher_latest_news_show($options)
    {
        $block = [];
    
        $configurator = new Configurator();
    Severity: Minor
    Found in blocks/latest_news.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 getElementsBySelector has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
    Open

    document.getElementsBySelector = function (selector) {
        // Attempt to fail gracefully in lesser browsers
        if (!document.getElementsByTagName) {
            return new Array();
        }
    Severity: Minor
    Found in assets/js/behavior.js - 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

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

    <?php declare(strict_types=1);
    
    namespace XoopsModules\Publisher\Common;
    
    /**
    Severity: Major
    Found in class/Common/Blocksadmin.php - About 1 day to fix

      Method processImageAndWriteToCache has 248 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function processImageAndWriteToCache($localImage)
          {
              $sData    = getimagesize($localImage);
              $origType = $sData[2];
              $mimeType = $sData['mime'];
      Severity: Major
      Found in thumb.php - About 1 day to fix

        Function publisher_items_new_show has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
        Open

        function publisher_items_new_show($options)
        {
            $helper = Helper::getInstance();
            /** @var ItemHandler $itemHandler */
            $itemHandler = $helper->getHandler('Item');
        Severity: Minor
        Found in blocks/items_new.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 publisher_items_spot_show has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
        Open

        function publisher_items_spot_show($options)
        {
            //    global $xoTheme;
            $helper = Helper::getInstance();
            /** @var CategoryHandler $categoryHandler */
        Severity: Minor
        Found in blocks/items_spot.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

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

          function xoops_module_update_publisher(\XoopsModule $module, ?string $previousVersion = null)
          {
              //    global $GLOBALS['xoopsDB'];
              $moduleDirName = \basename(\dirname(__DIR__));
              //    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
          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 createSchemaFromSqlfile has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
          Open

              public function createSchemaFromSqlfile(): bool
              {
                  if (!\is_file($this->fileSql)) {
                      \xoops_error('Error: Sql file not found!');
                      return false;
          Severity: Minor
          Found in class/Common/MigrateHelper.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

          File ItemForm.php has 498 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php declare(strict_types=1);
          
          namespace XoopsModules\Publisher\Form;
          
          /*
          Severity: Minor
          Found in class/Form/ItemForm.php - About 7 hrs to fix

            Method publisher_latest_news_show has 195 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function publisher_latest_news_show($options)
            {
                $block = [];
            
                $configurator = new Configurator();
            Severity: Major
            Found in blocks/latest_news.php - About 7 hrs to fix

              Function getItemRating has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getItemRating($itemId = 0, $source = 0)
                  {
                      $helper = \XoopsModules\Publisher\Helper::getInstance();
              
                      $itemRating               = [];
              Severity: Minor
              Found in class/RatingsHandler.php - About 7 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 ItemHandler.php has 479 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

                File modinfo.php has 477 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php declare(strict_types=1);
                
                define('_MI_PUBLISHER_ADMENU1', 'Summary');
                define('_MI_PUBLISHER_ADMENU2', 'Categories');
                define('_MI_PUBLISHER_ADMENU3', 'Articles');
                Severity: Minor
                Found in language/english/modinfo.php - About 7 hrs to fix

                  Function getItemRating has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getItemRating($itemId = null, $source = null): array
                      {
                          $itemId    = $itemId ?? 0;
                          $source    = $source ?? 0;
                          $xoopsUser = $GLOBALS['xoopsUser'];
                  Severity: Minor
                  Found in class/VoteHandler.php - About 7 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

                  Item has 49 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Item extends \XoopsObject
                  {
                      public const PAGEWRAP = '[pagewrap=';
                      public const BODYTAG  = '<body>';
                      /**
                  Severity: Minor
                  Found in class/Item.php - About 6 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language