mambax7/publisher

View on GitHub

Showing 3,029 of 3,029 total issues

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

        switch ((int)$helper->getConfig('ratingbars')) {
            case Constants::RATING_NONE:
            default:
                \redirect_header('index.php', 3, _MA_PUBLISHER_RATING_VOTE_BAD);
            case Constants::RATING_LIKES:
Severity: Major
Found in ratelike.php and 1 other location - About 6 hrs to fix
vote.php on lines 73..99

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

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

        switch ($votingType) {
            case Constants::RATING_NONE:
            default:
                \redirect_header('index.php', 3, _MA_PUBLISHER_RATING_VOTE_BAD);
            // no break
Severity: Major
Found in vote.php and 1 other location - About 6 hrs to fix
ratelike.php on lines 71..96

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

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

Method createElements has 162 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function createElements(): void
    {
        // require_once  \dirname(__DIR__, 2) . '/include/common.php';
        // Category
        $criteria = new \Criteria(null);
Severity: Major
Found in class/Form/CategoryForm.php - About 6 hrs to fix

    Method search has 162 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function search($icons): void
        {
            $helper = Helper::getInstance();
            /** @var MimetypeHandler $mimetypeHandler */
            $mimetypeHandler = $helper->getHandler('Mimetype');
    Severity: Major
    Found in class/MimetypesUtility.php - About 6 hrs to fix

      File item.php has 432 lines of code (exceeds 250 allowed). 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: Minor
      Found in admin/item.php - About 6 hrs to fix

        Utility has 46 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Utility extends Common\SysUtility
        {
            //--------------- Custom module methods -----------------------------
            /**
             * Function responsible for checking if a directory exists, we can also write in and create an index.html file
        Severity: Minor
        Found in class/Utility.php - About 6 hrs to fix

          Method getItemRating5 has 152 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getItemRating5($itemObj = null, $source = null): array
              {
                  $itemId    = $itemObj->itemid();
                  $source    = $source ?? 0;
                  $xoopsUser = $GLOBALS['xoopsUser'];
          Severity: Major
          Found in class/VoteHandler.php - About 6 hrs to fix

            File jquery.popeye-2.1.js has 409 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*
             * jQuery Popeye 2.1 - http://dev.herr-schuessler.de/jquery/popeye/
             *
             * converts a HTML image list in image gallery with inline enlargement
             *
            Severity: Minor
            Found in assets/js/jquery.popeye-2.1.js - About 5 hrs to fix

              Function __construct has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function __construct()
                  {
                      global $allowedSites;
                      $this->startTime = microtime(true);
                      date_default_timezone_set('UTC');
              Severity: Minor
              Found in thumb.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

              Method getItemRating has 138 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getItemRating($itemId = null, $source = null): array
                  {
                      $itemId    = $itemId ?? 0;
                      $source    = $source ?? 0;
                      $xoopsUser = $GLOBALS['xoopsUser'];
              Severity: Major
              Found in class/VoteHandler.php - About 5 hrs to fix

                Method publisher_items_spot_show has 137 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function publisher_items_spot_show($options)
                {
                    //    global $xoTheme;
                    $helper = Helper::getInstance();
                    /** @var CategoryHandler $categoryHandler */
                Severity: Major
                Found in blocks/items_spot.php - About 5 hrs to fix

                  Method publisher_latest_news_edit has 133 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function publisher_latest_news_edit($options)
                  {
                      $tabletag1 = '<tr><td style="padding:3px;" width="37%">';
                      $tabletag2 = '</td><td style="padding:3px;">';
                      $tabletag3 = '<tr><td style="padding-top:20px;border-bottom:1px solid #000;" colspan="2">';
                  Severity: Major
                  Found in blocks/latest_news.php - About 5 hrs to fix

                    Function getElementsBySelector has 131 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    document.getElementsBySelector = function (selector) {
                        // Attempt to fail gracefully in lesser browsers
                        if (!document.getElementsByTagName) {
                            return new Array();
                        }
                    Severity: Major
                    Found in assets/js/behavior.js - About 5 hrs to fix

                      Method getItemRating has 128 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getItemRating($itemId = 0, $source = 0)
                          {
                              $helper = \XoopsModules\Publisher\Helper::getInstance();
                      
                              $itemRating               = [];
                      Severity: Major
                      Found in class/RatingsHandler.php - About 5 hrs to fix

                        File latest_news.php has 375 lines of code (exceeds 250 allowed). 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: Minor
                        Found in blocks/latest_news.php - About 5 hrs to fix

                          Method manage has 124 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function manage($icons): void
                              {
                                  $helper  = Helper::getInstance();
                                  $utility = new Utility();
                                  /** @var MimetypeHandler $mimetypeHandler */
                          Severity: Major
                          Found in class/MimetypesUtility.php - About 4 hrs to fix

                            Function getItemRating5 has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function getItemRating5($itemObj = null, $source = null): array
                                {
                                    $itemId    = $itemObj->itemid();
                                    $source    = $source ?? 0;
                                    $xoopsUser = $GLOBALS['xoopsUser'];
                            Severity: Minor
                            Found in class/VoteHandler.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 publisher_editItem has 122 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function publisher_editItem($showmenu = false, $itemId = 0, $clone = false): void
                            {
                                $helper = Helper::getInstance();
                                global $publisherCurrentPage;
                            
                            
                            Severity: Major
                            Found in admin/item.php - About 4 hrs to fix

                              Method publisher_items_new_show has 122 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function publisher_items_new_show($options)
                              {
                                  $helper = Helper::getInstance();
                                  /** @var ItemHandler $itemHandler */
                                  $itemHandler = $helper->getHandler('Item');
                              Severity: Major
                              Found in blocks/items_new.php - About 4 hrs to fix

                                Method edit has 121 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public static function edit(): void
                                    {
                                        $helper = Helper::getInstance();
                                        /** @var MimetypeHandler $mimetypeHandler */
                                        $mimetypeHandler = $helper->getHandler('Mimetype');
                                Severity: Major
                                Found in class/MimetypesUtility.php - About 4 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language