mambax7/publisher

View on GitHub

Showing 3,032 of 3,032 total issues

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

            if (a < Math.abs(c)) {
                a = c;
                var s = p / 4;
            }
            else var s = p / (2 * Math.PI) * Math.asin(c / a);
Severity: Major
Found in assets/js/jquery.easing.js and 2 other locations - About 1 hr to fix
assets/js/jquery.easing.js on lines 126..130
assets/js/jquery.easing.js on lines 140..144

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

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 3 locations. Consider refactoring.
Open

            if (a < Math.abs(c)) {
                a = c;
                var s = p / 4;
            }
            else var s = p / (2 * Math.PI) * Math.asin(c / a);
Severity: Major
Found in assets/js/jquery.easing.js and 2 other locations - About 1 hr to fix
assets/js/jquery.easing.js on lines 126..130
assets/js/jquery.easing.js on lines 154..158

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

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

function publisher_items_new_edit($options)
{
    // require_once PUBLISHER_ROOT_PATH . '/class/blockform.php';
    xoops_load('XoopsFormLoader');

Severity: Minor
Found in blocks/items_new.php - About 1 hr to fix

    Method getTitle has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getTitle($title = '', $withExt = true)
        {
            /**
             * if XOOPS ML is present, let's sanitize the title with the current language
             */
    Severity: Minor
    Found in class/Seo.php - About 1 hr to fix

      Method orderBlock has 15 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              array $bid,
              array $oldtitle,
              array $oldside,
              array $oldweight,
              array $oldvisible,
      Severity: Major
      Found in class/Common/Blocksadmin.php - About 1 hr to fix

        Method loadSampleData has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Method serveWebshot has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function serveWebshot()
              {
                  $this->debug(3, 'Starting serveWebshot');
                  $instr = 'Please follow the instructions at https://code.google.com/p/timthumb/ to set your server up for taking website screenshots.';
                  if (!is_file(WEBSHOT_CUTYCAPT)) {
          Severity: Minor
          Found in thumb.php - About 1 hr to fix

            Method getFormFeedback has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getFormFeedback($action = false)
                {
                    if (!$action) {
                        $action = $_SERVER['REQUEST_URI'];
                    }
            Severity: Minor
            Found in class/Common/ModuleFeedback.php - About 1 hr to fix

              Method getAllFiles has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getAllFiles($itemId = 0, $status = -1, $limit = 0, $start = 0, $sort = 'datesub', $order = 'DESC', $category = [])
                  {
                      $files = [];
              
                      $this->table_link = $this->db->prefix($this->helper->getDirname() . '_items');
              Severity: Minor
              Found in class/FileHandler.php - About 1 hr to fix

                Function AjaxUpload has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    window.AjaxUpload = function (button, options) {
                        this._settings = {
                            // Location of the server-side upload script
                            action: 'upload.php',
                            // File upload name
                Severity: Minor
                Found in assets/js/ajaxupload.3.9.js - About 1 hr to fix

                  Method getObjects has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function &getObjects(\CriteriaElement $criteria = null, $idKey = 'none', $as_object = true, $notNullFields = null)
                      {
                          $limit         = $start = 0;
                          $ret           = [];
                          $notNullFields = (null !== $notNullFields) ?: '';
                  Severity: Minor
                  Found in class/ItemHandler.php - About 1 hr to fix

                    Function closeTags has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function closeTags($string)
                        {
                            // match opened tags
                            if (\preg_match_all('/<([a-z\:\-]+)[^\/]>/', $string, $startTags)) {
                                $startTags = $startTags[1];
                    Severity: Minor
                    Found in class/Utility.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 mergeImage has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function mergeImage(): void
                        {
                            $dest = \imagecreatefromjpeg($this->endFile);
                            $src  = \imagecreatefromjpeg($this->sourceFile);
                            if (4 == $this->mergeType) {
                    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 renderErrors has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function renderErrors($errArray, $reseturl = ''): void
                        {
                            if ($errArray && \is_array($errArray)) {
                                echo '<div id="readOnly" class="errorMsg" style="border:1px solid #D24D00; background:#FEFECC url(' . PUBLISHER_URL . '/assets/images/important-32.png) no-repeat 7px 50%;color:#333;padding-left:45px;">';
                    
                    
                    Severity: Minor
                    Found in class/Utility.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 getImages has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getImages()
                        {
                            static $ret;
                            $itemId = (int)$this->getVar('itemid');
                            if (!isset($ret[$itemId])) {
                    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

                    Method checkVerModule has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
                        {
                            /*
                                    // Generated by curl-to-PHP: https://incarnate.github.io/curl-to-php/
                                    $ch = curl_init();
                    Severity: Minor
                    Found in class/Common/VersionChecks.php - About 1 hr to fix

                      Method publisher_category_items_sel_show has 42 lines of code (exceeds 25 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

                        Method html2text has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function html2text($document)
                            {
                                if (empty($document)) {
                                    return '';
                                }
                        Severity: Minor
                        Found in class/Metagen.php - About 1 hr to fix

                          Avoid excessively long variable names like $filePrependSecurityBlock. Keep variable name length under 20.
                          Open

                              protected        $filePrependSecurityBlock = "<?php exit('Execution denied!'); //"; //Designed to have three letter mime type, space, question mark and greater than symbol appended. 6 bytes total.
                          Severity: Minor
                          Found in thumb.php by phpmd

                          LongVariable

                          Since: 0.2

                          Detects when a field, formal or local variable is declared with a long name.

                          Example

                          class Something {
                              protected $reallyLongIntName = -3; // VIOLATION - Field
                              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                  $otherReallyLongName = -5; // VIOLATION - Local
                                  for ($interestingIntIndex = 0; // VIOLATION - For
                                       $interestingIntIndex < 10;
                                       $interestingIntIndex++ ) {
                                  }
                              }
                          }

                          Source https://phpmd.org/rules/naming.html#longvariable

                          Avoid excessively long variable names like $optdisplaycategorylink. Keep variable name length under 20.
                          Open

                              $optdisplaycategorylink = $options[14] ?? '';
                          Severity: Minor
                          Found in blocks/items_spot.php by phpmd

                          LongVariable

                          Since: 0.2

                          Detects when a field, formal or local variable is declared with a long name.

                          Example

                          class Something {
                              protected $reallyLongIntName = -3; // VIOLATION - Field
                              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                  $otherReallyLongName = -5; // VIOLATION - Local
                                  for ($interestingIntIndex = 0; // VIOLATION - For
                                       $interestingIntIndex < 10;
                                       $interestingIntIndex++ ) {
                                  }
                              }
                          }

                          Source https://phpmd.org/rules/naming.html#longvariable

                          Severity
                          Category
                          Status
                          Source
                          Language