mambax7/publisher

View on GitHub

Showing 3,032 of 3,032 total issues

Method publisher_items_columns_edit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

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

    Method editBlock has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function editBlock(int $bid): void
        {
            //        require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
            //        \xoops_cp_header();
            \xoops_loadLanguage('admin', 'system');
    Severity: Minor
    Found in class/Common/Blocksadmin.php - About 1 hr to fix

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

        Function run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function run()
            {
                if ($this->isURL) {
                    if (!ALLOW_EXTERNAL) {
                        $this->debug(1, 'Got a request for an external image but ALLOW_EXTERNAL is disabled so returning error msg.');
        Severity: Minor
        Found in thumb.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 manage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function manage($icons): void
            {
                $helper  = Helper::getInstance();
                $utility = new Utility();
                /** @var MimetypeHandler $mimetypeHandler */
        Severity: Minor
        Found in class/MimetypesUtility.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 getItems has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function getItems($limit = 0, $start = 0, $status = '', $categoryid = -1, $sort = 'datesub', $order = 'DESC', $notNullFields = null, $asObject = true, $otherCriteria = null, $idKey = 'none')
        Severity: Major
        Found in class/ItemHandler.php - About 1 hr to fix

          Function insert has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function insert(\XoopsObject $item, $force = false)  //insert(&$item, $force = false)
              {
                  if (!$item->meta_keywords() || !$item->meta_description() || !$item->short_url()) {
                      $publisherMetagen = new Metagen($item->getTitle(), $item->getVar('meta_keywords'), $item->getVar('summary'));
                      // Auto create meta tags if empty
          Severity: Minor
          Found in class/ItemHandler.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 getCount has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getCount(\CriteriaElement $criteria = null, $notNullFields = null)
              {
                  //        $notNullFields = $notNullFields ?? null;
                  $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix($this->helper->getDirname() . '_items');
                  if (null !== $criteria && ($criteria instanceof \Criteria || $criteria instanceof \CriteriaCompo)) {
          Severity: Minor
          Found in class/ItemHandler.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 rrmdir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function rrmdir($src)
              {
                  // Only continue if user is a 'global' Admin
                  if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
                      return false;
          Severity: Minor
          Found in class/Common/FilesManagement.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 storeUpload has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function storeUpload($postField, $allowedMimetypes, &$errors)
              {
                  /** @var MimetypeHandler $mimetypeHandler */
                  $mimetypeHandler = $this->helper->getHandler('Mimetype');
                  $itemId          = $this->getVar('itemid');
          Severity: Minor
          Found in class/File.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 ratingBar has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function ratingBar($itemId)
              {
                  $helper          = Helper::getInstance();
                  $ratingUnitWidth = 30;
                  $units           = 5;
          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 createDir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function createDir(): void
              {
                  // auto crate folders
                  //        $thePath = static::getUploadDir();
          
          
          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

          Method cleanCache has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function cleanCache()
              {
                  if (FILE_CACHE_TIME_BETWEEN_CLEANS < 0) {
                      return null;
                  }
          Severity: Minor
          Found in thumb.php - About 1 hr to fix

            Method getKey has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getKey(string $line): array
                {
                    $key = [];
            
                    if (\strpos($line, 'RIMARY') > 0) {
            Severity: Minor
            Found in class/Common/MigrateHelper.php - About 1 hr to fix

              Method loadTableFromArrayWithReplace has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function loadTableFromArrayWithReplace($table, $data, $search, $replace)
              {
                  /** @var \XoopsMySQLDatabase $db */
                  $db = \XoopsDatabaseFactory::getDatabaseConnection();
              
              
              Severity: Minor
              Found in testdata/index.php - About 1 hr to fix

                Method getFormConfirm has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getFormConfirm(): \XoopsThemeForm
                    {
                        $moduleDirName      = \basename(__DIR__);
                        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
                        //in order to be accessable from user and admin area this should be place in language common.php
                Severity: Minor
                Found in class/Common/Confirm.php - About 1 hr to fix

                  Method getCountsByCat has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getCountsByCat($catId, $status, $inSubCat = false)
                      {
                          //        global $resultCatCounts;
                  
                          $ret       = [];
                  Severity: Minor
                  Found in class/ItemHandler.php - About 1 hr to fix

                    Method storeUpload has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function storeUpload($postField, $allowedMimetypes, &$errors)
                        {
                            /** @var MimetypeHandler $mimetypeHandler */
                            $mimetypeHandler = $this->helper->getHandler('Mimetype');
                            $itemId          = $this->getVar('itemid');
                    Severity: Minor
                    Found in class/File.php - About 1 hr to fix

                      Method getServerStats has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function getServerStats()
                          {
                              //mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
                              $moduleDirName      = \basename(\dirname(__DIR__, 2));
                              $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
                      Severity: Minor
                      Found in class/Common/ServerStats.php - About 1 hr to fix

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

                                if (('blank.gif' !== $arrCat['topic_imgurl']) && ('' !== $arrCat['topic_imgurl'])) {
                                    if (copy($GLOBALS['xoops']->path('uploads/AMS/topics/' . $arrCat['topic_imgurl']), $GLOBALS['xoops']->path('uploads/' . PUBLISHER_DIRNAME . '/images/category/' . $arrCat['topic_imgurl']))) {
                                        $categoryObj->setVar('image', $arrCat['topic_imgurl']);
                        
                                        //======== there is no need to add the category images to Image Manager, because they are handled directly from /images/category/ folder
                        Severity: Major
                        Found in admin/import/ams.php and 1 other location - About 1 hr to fix
                        admin/import/xnews.php on lines 242..267

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language