mambax7/tdmdownloads

View on GitHub

Showing 207 of 207 total issues

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

    public function mergeImage($src_url, $dest_url, $pos, $of)
    {
        $dest = \imagecreatefromjpeg($dest_url);
        $src  = \imagecreatefromjpeg($src_url);
        // ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
Severity: Minor
Found in class/Common/ImageResizer.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 cloneFolder has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function cloneFolder($pathSource, $pathTarget)
    {
        if (\is_dir($pathSource)) {
            // Create new dir
            if (!\mkdir($pathTarget) && !\is_dir($pathTarget)) {
Severity: Minor
Found in class/Utilities.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 mergeImage has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function mergeImage($src_url, $dest_url, $pos, $of)
    {
        $dest = \imagecreatefromjpeg($dest_url);
        $src  = \imagecreatefromjpeg($src_url);
        // ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
Severity: Minor
Found in class/Common/ImageResizer.php - About 1 hr to fix

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

        public static function checkVerModule(Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
        {
            $moduleDirName      = \basename(\dirname(__DIR__, 2));
            $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
            $update             = '';
    Severity: Minor
    Found in class/Common/VersionChecks.php - About 1 hr to fix

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

      function update_tdmdownloads_v200(&$module)
      {
          // Update size
          $moduleDirName = basename(dirname(__DIR__));
          $db            = \XoopsDatabaseFactory::getDatabaseConnection();
      Severity: Minor
      Found in include/onupdate.php - About 1 hr to fix

        Method getPathTreeUrl has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getPathTreeUrl($mytree, $key, $category_array, $title, $prefix = '', $link = false, $order = 'ASC', $lasturl = false)
            {
                global $xoopsModule;
                $categoryParent = $mytree->getAllParent($key);
                if ('ASC' === $order) {
        Severity: Minor
        Found in class/Utility.php - About 1 hr to fix

          Method updateBlock has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups): void
              {
                  $myblock = new \XoopsBlock($bid);
                  $myblock->setVar('title', $btitle);
                  $myblock->setVar('weight', $bweight);
          Severity: Minor
          Found in class/Common/Blocksadmin.php - About 1 hr to fix

            Method getPathTreeUrl has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function getPathTreeUrl(
                    $mytree,
                    $key,
                    $category_array,
                    $title,
            Severity: Minor
            Found in class/Utilities.php - About 1 hr to fix

              Function convertSizeToString has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function convertSizeToString($sizeString)
                  {
                      $mysizeString = '';
                      if ('' != $sizeString) {
                          $size_value_arr = \explode(' ', $sizeString);
              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 getNumbersOfEntries has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getNumbersOfEntries($mytree, $categories, $entries, $cid)
                  {
                      $count     = 0;
                      $child_arr = [];
                      if (\in_array($cid, $categories)) {
              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 resizeAndCrop has a Cognitive Complexity of 13 (exceeds 5 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 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 getNumbersOfEntries has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function getNumbersOfEntries($mytree, $categories, $entries, $cid)
                  {
                      $count     = 0;
                      $child_arr = [];
                      if (\in_array($cid, $categories)) {
              Severity: Minor
              Found in class/Utilities.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 13 (exceeds 5 allowed). Consider refactoring.
              Open

              function rrmdir($src)
              {
                  if (is_dir($src)) {
                      $dir = opendir($src);
                      while (false !== ($file = readdir($dir))) {
              Severity: Minor
              Found in include/onupdate.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

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

                      if ($counter > 0) {
                          $form->addElement(new \XoopsFormHidden('op', 'import_mydownloads'));
                          $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false));
                      } else {
                          $form->addElement(new \XoopsFormHidden('op', 'cancel'));
              Severity: Major
              Found in admin/import.php and 1 other location - About 1 hr to fix
              admin/import.php on lines 367..373

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

              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

                      if ($counter > 0) {
                          $form->addElement(new \XoopsFormHidden('op', 'import_mydownloads'));
                          $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false));
                      } else {
                          $form->addElement(new \XoopsFormHidden('op', 'cancel'));
              Severity: Major
              Found in admin/import.php and 1 other location - About 1 hr to fix
              admin/import.php on lines 318..324

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

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

              function tdmdownloads_notify_iteminfo($category, $item_id)
              {
                  global $xoopsModule, $xoopsModuleConfig, $xoopsConfig;
                  $moduleDirName = basename(dirname(__DIR__));
                  $item_id       = (int)$item_id;
              Severity: Minor
              Found in include/notification.inc.php - About 1 hr to fix

                Method __construct has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __construct($target)
                    {
                        $moduleDirName      = \basename(\dirname(__DIR__, 2));
                        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
                        /** @var \XoopsModules\Tdmdownloads\Helper $this- >helper */
                Severity: Minor
                Found in class/Form/UploadForm.php - About 1 hr to fix

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

                              if (true === \Xmf\Request::getBool('new_file', false, 'REQUEST')) {
                                  $urlfile = substr_replace($obj->getVar('url'), '', 0, mb_strlen($uploadurl_downloads));
                                  // permet de donner le chemin du fichier
                                  $urlfile = $uploaddir_downloads . $urlfile;
                                  // si le fichier est sur le serveur il es détruit
                  Severity: Major
                  Found in admin/modified.php and 1 other location - About 1 hr to fix
                  admin/modified.php on lines 235..244

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

                  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

                          if (true === \Xmf\Request::getBool('new_file', false, 'REQUEST')) {
                              $urlfile = substr_replace($obj->getVar('url'), '', 0, mb_strlen($uploadurl_downloads));
                              // permet de donner le chemin du fichier
                              $urlfile = $uploaddir_downloads . $urlfile;
                              // si le fichier est sur le serveur il es détruit
                  Severity: Major
                  Found in admin/modified.php and 1 other location - About 1 hr to fix
                  admin/modified.php on lines 190..199

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

                  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

                          if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) {
                              $adminlink = '<a href="'
                                           . XOOPS_URL
                                           . '/modules/'
                                           . $moduleDirName
                  Severity: Major
                  Found in viewcat.php and 1 other location - About 1 hr to fix
                  index.php on lines 225..241

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

                  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