mambax7/tdmdownloads

View on GitHub

Showing 207 of 207 total issues

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

    case 'new_cat':
        //Affichage de la partie haute de l'administration de Xoops
        xoops_cp_header();
        $adminObject = Admin::getInstance();
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__)));
Severity: Major
Found in admin/category.php and 1 other location - About 2 hrs to fix
admin/field.php on lines 82..95

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

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

    case 'new_field':
        //Affichage de la partie haute de l'administration de Xoops
        xoops_cp_header();
        $adminObject = Admin::getInstance();
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__)));
Severity: Major
Found in admin/field.php and 1 other location - About 2 hrs to fix
admin/category.php on lines 73..85

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

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

function update_tdmdownloads_v201($module)
{
    $moduleDirName      = \basename(\dirname(__DIR__));
    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
    $helper             = Helper::getInstance();
Severity: Major
Found in include/onupdate.php - About 2 hrs to fix

    Function deleteDirectory has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function deleteDirectory(string $src): bool
        {
            // 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 2 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

    Function cloneFileFolder has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function cloneFileFolder($path)
        {
            global $patKeys;
            global $patValues;
    
    
    Severity: Minor
    Found in class/Cloner.php - About 2 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

    Function render has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function render($block = null)
        {
            \xoops_load('XoopsFormLoader');
            \xoops_loadLanguage('common', $this->moduleDirNameUpper);
    
    
    Severity: Minor
    Found in class/Common/Blocksadmin.php - About 2 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 getFormImages has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getFormImages($action = false)
        {
            $moduleDirName      = \basename(\dirname(__DIR__, 2));
            $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
            $helper             = Helper::getInstance();
    Severity: Major
    Found in class/Common/Images.php - About 2 hrs to fix

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

              if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
                  $uploader->setPrefix('downloads_');
                  $uploader->fetchMedia($_POST['xoops_upload_file'][0]);
                  if ($uploader->upload()) {
                      $obj->setVar('img', $uploader->getSavedFileName());
      Severity: Major
      Found in admin/field.php and 1 other location - About 2 hrs to fix
      admin/category.php on lines 329..340

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

      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 ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
                  $uploader->setPrefix('downloads_');
                  $uploader->fetchMedia($_POST['xoops_upload_file'][0]);
                  if ($uploader->upload()) {
                      $obj->setVar('cat_imgurl', $uploader->getSavedFileName());
      Severity: Major
      Found in admin/category.php and 1 other location - About 2 hrs to fix
      admin/field.php on lines 186..197

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

      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

      File submit.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      use XoopsModules\Tag\{
          Helper as TagHelper,
          Tag,
      Severity: Minor
      Found in submit.php - About 2 hrs to fix

        Method resizeImage has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $imageMimetype)
            {
                // check file extension
                switch ($imageMimetype) {
                    case 'image/png':
        Severity: Major
        Found in class/Common/ImageResizer.php - About 2 hrs to fix

          File modified.php has 255 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          declare(strict_types=1);
          
          /**
          Severity: Minor
          Found in admin/modified.php - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                    if (\Xmf\Request::hasVar('ok', 'REQUEST') && 1 == \Xmf\Request::getInt('ok', 0, 'REQUEST')) {
                        if (!$GLOBALS['xoopsSecurity']->check()) {
                            redirect_header('category.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
                        }
                        // supression des téléchargements de la catégorie
            Severity: Critical
            Found in admin/category.php - About 2 hrs to fix

              Method isBlockCloned has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups): void
                  {
                      \xoops_loadLanguage('admin', 'system');
                      \xoops_loadLanguage('admin/blocksadmin', 'system');
                      \xoops_loadLanguage('admin/groups', 'system');
              Severity: Minor
              Found in class/Common/Blocksadmin.php - About 2 hrs to fix

                Method resizeAndCrop has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest_h, $quality = 90)
                    {
                        // check file extension
                        switch ($src_mimetype) {
                            case 'image/png':
                Severity: Minor
                Found in class/Common/ImageResizer.php - About 2 hrs to fix

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

                              if ('' == Xmf\Request::getString('sizeValue', '')) {
                                  if (0 == $mediaSize) {
                                      $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', '')));
                                  } else {
                                      $obj->setVar('size', $utility::convertFileSize($mediaSize));
                  Severity: Major
                  Found in modfile.php and 2 other locations - About 1 hr to fix
                  admin/downloads.php on lines 668..676
                  submit.php on lines 218..226

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

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

                          if ('' == Xmf\Request::getString('sizeValue', '')) {
                              if (0 == $mediaSize) {
                                  $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', '')));
                              } else {
                                  $obj->setVar('size', $utility::convertFileSize($mediaSize));
                  Severity: Major
                  Found in admin/downloads.php and 2 other locations - About 1 hr to fix
                  modfile.php on lines 211..219
                  submit.php on lines 218..226

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

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

                          if ('' == Xmf\Request::getString('sizeValue', '')) {
                              if (0 == $mediaSize) {
                                  $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', '')));
                              } else {
                                  $obj->setVar('size', $utility::convertFileSize($mediaSize));
                  Severity: Major
                  Found in submit.php and 2 other locations - About 1 hr to fix
                  admin/downloads.php on lines 668..676
                  modfile.php on lines 211..219

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

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

                      public function getForm($action = false)
                      {
                          $helper        = Helper::getInstance();
                          $moduleDirName = \basename(\dirname(__DIR__));
                          if (!$action) {
                  Severity: Minor
                  Found in class/Field.php - About 1 hr to fix

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

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