XoopsModules25x/wfdownloads

View on GitHub
class/Download.php

Summary

Maintainability
F
1 wk
Test Coverage

File Download.php has 758 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace XoopsModules\Wfdownloads;

/*
Severity: Major
Found in class/Download.php - About 1 day to fix

    Method getAdminForm has 285 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getAdminForm($title, $customArray = []) // $custom array added April 22, 2006 by jwe
        {
            require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    
            $use_mirrors = $this->helper->getConfig('enable_mirrors');
    Severity: Major
    Found in class/Download.php - About 1 day to fix

      Function getDownloadInfo has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getDownloadInfo()
          {
              \xoops_load('XoopsUserUtility');
      
              $download['id']  = $this->getVar('lid');
      Severity: Minor
      Found in class/Download.php - About 7 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 getForm has 184 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getForm($customArray = []) // $custom array added April 22, 2006 by jwe)
          {
              require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
              require_once XOOPS_ROOT_PATH . '/class/tree.php';
      
      
      Severity: Major
      Found in class/Download.php - About 7 hrs to fix

        Method getDownloadInfo has 169 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getDownloadInfo()
            {
                \xoops_load('XoopsUserUtility');
        
                $download['id']  = $this->getVar('lid');
        Severity: Major
        Found in class/Download.php - About 6 hrs to fix

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

              public function getForm($customArray = []) // $custom array added April 22, 2006 by jwe)
              {
                  require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
                  require_once XOOPS_ROOT_PATH . '/class/tree.php';
          
          
          Severity: Minor
          Found in class/Download.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

          Function getAdminForm has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getAdminForm($title, $customArray = []) // $custom array added April 22, 2006 by jwe
              {
                  require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
          
                  $use_mirrors = $this->helper->getConfig('enable_mirrors');
          Severity: Minor
          Found in class/Download.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 __construct has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct($id = null)
              {
                  /** @var \XoopsModules\Wfdownloads\Helper $this ->helper */
                  $this->helper = Helper::getInstance();
                  $this->db     = \XoopsDatabaseFactory::getDatabaseConnection();
          Severity: Major
          Found in class/Download.php - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                    if (!\is_object($GLOBALS['xoopsUser'])
                        && (\_WFDOWNLOADS_ANONPOST_MIRROR == $this->helper->getConfig('anonpost')
                            || \_WFDOWNLOADS_ANONPOST_BOTH == $this->helper->getConfig('anonpost'))
                        && (\_WFDOWNLOADS_SUBMISSIONS_MIRROR == $this->helper->getConfig('submissions')
                            || \_WFDOWNLOADS_SUBMISSIONS_BOTH == $this->helper->getConfig('submissions'))
            Severity: Critical
            Found in class/Download.php - About 2 hrs to fix

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

                          if (Utility::checkModule('formulize')) {
                              require_once XOOPS_ROOT_PATH . '/modules/formulize/include/formdisplay.php';
                              require_once XOOPS_ROOT_PATH . '/modules/formulize/include/functions.php';
                              $sform = compileElements(// is a Formulize function
                                  $customArray['fid'],
              Severity: Major
              Found in class/Download.php and 1 other location - About 4 hrs to fix
              class/Download.php on lines 579..603

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

              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 (Utility::checkModule('formulize')) {
                              require_once XOOPS_ROOT_PATH . '/modules/formulize/include/formdisplay.php';
                              require_once XOOPS_ROOT_PATH . '/modules/formulize/include/functions.php';
                              $sform = compileElements(// is a Formulize function
                                  $customArray['fid'],
              Severity: Major
              Found in class/Download.php and 1 other location - About 4 hrs to fix
              class/Download.php on lines 850..874

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

              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 (Utility::checkVerXoops($GLOBALS['xoopsModule'], '2.5.9')) {
                          $catSelect = $categoryObjsTree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', \_AM_WFDOWNLOADS_FILE_CATEGORY);
                          $sform->addElement($catSelect);
                      } else {
                          $sform->addElement(new \XoopsFormLabel(\_AM_WFDOWNLOADS_FILE_CATEGORY, $categoryObjsTree->makeSelBox('cid', 'title', '-', $this->getVar('cid', 'e'))));
              Severity: Major
              Found in class/Download.php and 2 other locations - About 2 hrs to fix
              class/Download.php on lines 483..488
              class/Download.php on lines 1031..1036

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

              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 (Utility::checkVerXoops($GLOBALS['xoopsModule'], '2.5.9')) {
                          $catSelect = $categoryObjsTree->makeSelectElement('cid', 'title', '-', $this->getVar('cid'), true, 0, '', \_MD_WFDOWNLOADS_CATEGORYC);
                          $sform->addElement($catSelect);
                      } else {
                          $sform->addElement(new \XoopsFormLabel(\_MD_WFDOWNLOADS_CATEGORYC, $categoryObjsTree->makeSelBox('cid', 'title', '-', $this->getVar('cid', 'e'))));
              Severity: Major
              Found in class/Download.php and 2 other locations - About 2 hrs to fix
              class/Download.php on lines 483..488
              class/Download.php on lines 724..729

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

              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 (Utility::checkVerXoops($GLOBALS['xoopsModule'], '2.5.9')) {
                              $catSelect = $categoryObjsTree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', \_MD_WFDOWNLOADS_CATEGORYC);
                              $sform->addElement($catSelect);
                          } else {
                              $sform->addElement(new \XoopsFormLabel(\_MD_WFDOWNLOADS_CATEGORYC, $categoryObjsTree->makeSelBox('cid', 'title', '-', $this->getVar('cid', 'e'))));
              Severity: Major
              Found in class/Download.php and 2 other locations - About 2 hrs to fix
              class/Download.php on lines 724..729
              class/Download.php on lines 1031..1036

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

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

                      if ('' != $this->getVar('screenshot4')) {
                          $indeximage_tray4->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . '/' . $this->helper->getConfig('screenshots') . '/' . $this->getVar('screenshot4', 'e') . "' id='image4' alt='' title='screenshot 4'>"));
                      } else {
                          $indeximage_tray4->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . "/uploads/blank.png' id='image4' alt='' title=''>"));
                      }
              Severity: Major
              Found in class/Download.php and 3 other locations - About 1 hr to fix
              class/Download.php on lines 891..895
              class/Download.php on lines 905..909
              class/Download.php on lines 919..923

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

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

                      if ('' != $this->getVar('screenshot2')) {
                          $indeximage_tray2->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . '/' . $this->helper->getConfig('screenshots') . '/' . $this->getVar('screenshot2', 'e') . "' id='image2' alt='' title='screenshot 2'>"));
                      } else {
                          $indeximage_tray2->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . "/uploads/blank.png' id='image2' alt='' title=''>"));
                      }
              Severity: Major
              Found in class/Download.php and 3 other locations - About 1 hr to fix
              class/Download.php on lines 891..895
              class/Download.php on lines 919..923
              class/Download.php on lines 933..937

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

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

                      if ('' != $this->getVar('screenshot')) { // IN PROGRESS
                          $indeximage_tray1->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . '/' . $this->helper->getConfig('screenshots') . '/' . $this->getVar('screenshot', 'e') . "' id='image1' alt='' title='screenshot 1'>"));
                      } else {
                          $indeximage_tray1->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . "/uploads/blank.png' id='image1' alt='' title=''>"));
                      }
              Severity: Major
              Found in class/Download.php and 3 other locations - About 1 hr to fix
              class/Download.php on lines 905..909
              class/Download.php on lines 919..923
              class/Download.php on lines 933..937

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

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

                      if ('' != $this->getVar('screenshot3')) {
                          $indeximage_tray3->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . '/' . $this->helper->getConfig('screenshots') . '/' . $this->getVar('screenshot3', 'e') . "' id='image3' alt='' title='screenshot 3'>"));
                      } else {
                          $indeximage_tray3->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . "/uploads/blank.png' id='image3' alt='' title=''>"));
                      }
              Severity: Major
              Found in class/Download.php and 3 other locations - About 1 hr to fix
              class/Download.php on lines 891..895
              class/Download.php on lines 905..909
              class/Download.php on lines 933..937

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

              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

              There are no issues that match your filters.

              Category
              Status