XoopsModules25x/wfdownloads

View on GitHub

Showing 279 of 279 total issues

Avoid deeply nested control flow statements.
Open

                            if (is_file($templateFolder . $v)) {
                                unlink($templateFolder . $v);
                            }
Severity: Major
Found in include/onupdate.php - About 45 mins to fix

    Function wfdownloads_top_show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function wfdownloads_top_show($options)
    {
        if (!class_exists(Helper::class)) {
            return false;
        }
    Severity: Minor
    Found in blocks/top.php - About 45 mins 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 makeMySelBox has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
    Severity: Minor
    Found in class/Common/XoopsTree.php - About 45 mins to fix

      Function displayImage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function displayImage($image = '', $href = '', $imgSource = '', $altText = '')
          {
              $helper = Helper::getInstance();
      
              $showImage = '';
      Severity: Minor
      Found in class/Utility.php - About 45 mins 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

      Consider simplifying this complex logical expression.
      Open

      if (0 == $downloadObj->getVar('published') || $downloadObj->getVar('published') > time()
          || true === $downloadObj->getVar('offline')
          || (0 != $downloadObj->getVar('expired')
              && $downloadObj->getVar('expired') < time())
          || _WFDOWNLOADS_STATUS_WAITING == $downloadObj->getVar('status')) {
      Severity: Major
      Found in singlefile.php - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

        if (0 == $downloadObj->getVar('published') || $downloadObj->getVar('published') > time()
            || 1 === $downloadObj->getVar('offline')
            || (1 === $downloadObj->getVar('expired')
                && $downloadObj->getVar('expired') < time())
            || _WFDOWNLOADS_STATUS_WAITING == $downloadObj->getVar('status')) {
        Severity: Major
        Found in brokenfile.php - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

          if (0 == $downloadObj->getVar('published') || $downloadObj->getVar('published') > time()
              || true === $downloadObj->getVar('offline')
              || (0 != $downloadObj->getVar('expired')
                  && $downloadObj->getVar('expired') < time())
              || _WFDOWNLOADS_STATUS_WAITING == $downloadObj->getVar('status')) {
          Severity: Major
          Found in mirror.php - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

            if (0 == $downloadObj->getVar('published') || $downloadObj->getVar('published') > time()
                || true === $downloadObj->getVar('offline')
                || (0 != $downloadObj->getVar('expired')
                    && $downloadObj->getVar('expired') < time())
                || _WFDOWNLOADS_STATUS_WAITING == $downloadObj->getVar('status')) {
            Severity: Major
            Found in review.php - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

              if (0 == $downloadObj->getVar('published') || $downloadObj->getVar('published') > time() || true === $downloadObj->getVar('offline')
                  || (0 != $downloadObj->getVar('expired')
                      && $downloadObj->getVar('expired') < time())
                  || _WFDOWNLOADS_STATUS_WAITING == $downloadObj->getVar('status')) {
                  redirect_header('index.php', 3, _MD_WFDOWNLOADS_NODOWNLOAD);
              Severity: Major
              Found in visit.php - About 40 mins to fix

                Method makeSelBoxOptionsArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function makeSelBoxOptionsArray($fieldName, $key, &$optionsArray, $prefix_orig, $prefix_curr = '')
                Severity: Minor
                Found in class/Common/ObjectTree.php - About 35 mins to fix

                  Method truncateHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
                  Severity: Minor
                  Found in class/Utility.php - About 35 mins to fix

                    Method makeSelBoxOptionsArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function makeSelBoxOptionsArray($fieldName, $key, &$optionsArray, $prefix_orig, $prefix_curr = '')
                    Severity: Minor
                    Found in class/ObjectTree.php - About 35 mins to fix

                      Method truncateHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
                      Severity: Minor
                      Found in class/Common/SysUtility.php - About 35 mins to fix

                        Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public function __construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth = 0, $maxHeight = 0)
                        Severity: Minor
                        Found in class/MediaImgUploader.php - About 35 mins to fix

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

                                  for (e = 1; (t.direction ? o : i) >= e; e++)t._preloadItem(t.index + e);
                          Severity: Minor
                          Found in assets/js/magnific/jquery.magnific-popup.min.js and 1 other location - About 35 mins to fix
                          assets/js/magnific/jquery.magnific-popup.min.js on lines 378..378

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

                          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

                                          var i = n.arrowMarkup, o = t.arrowLeft = e(i.replace(/%title%/gi, n.tPrev).replace(/%dir%/gi, "left")).addClass(y), a = t.arrowRight = e(i.replace(/%title%/gi, n.tNext).replace(/%dir%/gi, "right")).addClass(y), s = r ? "mfpFastClick" : "click";
                          Severity: Minor
                          Found in assets/js/magnific/jquery.magnific-popup.min.js and 1 other location - About 35 mins to fix
                          assets/js/magnific/jquery.magnific-popup.min.js on lines 355..355

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

                          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

                                  for (e = 1; (t.direction ? i : o) >= e; e++)t._preloadItem(t.index - e)
                          Severity: Minor
                          Found in assets/js/magnific/jquery.magnific-popup.min.js and 1 other location - About 35 mins to fix
                          assets/js/magnific/jquery.magnific-popup.min.js on lines 377..377

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

                          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

                          Function get_table_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function get_table_info($table, $default_fields)
                          {
                              $result = $GLOBALS['xoopsDB']->query('SHOW COLUMNS FROM ' . $table);
                              while (false !== ($existing_field = $GLOBALS['xoopsDB']->fetchArray($result))) {
                                  $fields[$existing_field['Field']] = $existing_field['Type'];
                          Severity: Minor
                          Found in include/onupdate.php - About 35 mins 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 delete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function delete(\XoopsObject $download, $force = false)
                              {
                                  if (parent::delete($download, $force)) {
                                      $criteria = new \Criteria('lid', (int)$download->getVar('lid'));
                                      $this->helper->getHandler('Rating')->deleteAll($criteria);
                          Severity: Minor
                          Found in class/DownloadHandler.php - About 35 mins 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 wfdownloads_createLogo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function wfdownloads_createLogo($dirname)
                          {
                              $helper = Helper::getInstance();
                              // Check extension/functions
                              if (!extension_loaded('gd')) {
                          Severity: Minor
                          Found in admin/clone.php - About 35 mins 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

                          Severity
                          Category
                          Status
                          Source
                          Language