XoopsModules25x/wfdownloads

View on GitHub

Showing 279 of 279 total issues

Function makeMySelBox has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
    {
        if ('' == $sel_name) {
            $sel_name = $this->id;
        }
Severity: Minor
Found in class/XoopsTree.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 convertorderbyin has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function convertorderbyin($orderby)
    {
        switch (\trim($orderby)) {
            case 'titleA':
                $orderby = 'title ASC';
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 getUserAverage has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getUserAverage($criteria = null)
    {
        $groupby = false;
        $field   = '';
        if (null !== $criteria && $criteria instanceof \CriteriaElement) {
Severity: Minor
Found in class/RatingHandler.php - About 1 hr to fix

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

            if (1 == $helper->getConfig('multicats')) {
                $eachentry['catid'] = (int)$categoryID;
                $resultF            = $xoopsDB->query('SELECT name FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID = $categoryID ORDER BY name ASC");
                while (list($name) = $xoopsDB->fetchRow($resultF)) {
                    $eachentry['catname'] = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5);
    Severity: Major
    Found in letter.php and 1 other location - About 1 hr to fix
    letter.php on lines 172..178

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

    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 (1 == $helper->getConfig('multicats')) {
                $eachentry['catid'] = (int)$categoryID;
                $resultF            = $xoopsDB->query('SELECT name FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID = $categoryID ORDER BY name ASC");
                while (list($name) = $xoopsDB->fetchRow($resultF)) {
                    $eachentry['catname'] = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5);
    Severity: Major
    Found in letter.php and 1 other location - About 1 hr to fix
    letter.php on lines 102..108

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

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

        public function addElement($formElement, $required = false, $row = null, $column = null)
        {
            if (null === $row) {
                $row = $this->_rows;
            }
    Severity: Minor
    Found in class/MulticolumnsThemeForm.php - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if (!is_object($GLOBALS['xoopsUser'])
                  && (_WFDOWNLOADS_ANONPOST_MIRROR == $helper->getConfig('anonpost')
                      || _WFDOWNLOADS_ANONPOST_BOTH == $helper->getConfig('anonpost'))
                  && (_WFDOWNLOADS_SUBMISSIONS_MIRROR == $helper->getConfig('submissions')
                      || _WFDOWNLOADS_SUBMISSIONS_BOTH == $helper->getConfig('submissions'))) {
      Severity: Critical
      Found in mirror.php - About 1 hr to fix

        Function initZoom has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            }}, proto                                      : {initZoom: function () {
                var e, n = t.st.zoom, i = ".zoom";
                if (n.enabled && t.supportsTransition) {
                    var o, r, a = n.duration, s = function (e) {
                        var t = e.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"), i = "all " + n.duration / 1e3 + "s " + n.easing, o = {position: "fixed", zIndex: 9999, left: 0, top: 0, "-webkit-backface-visibility": "hidden"}, r = "transition";
        Severity: Minor
        Found in assets/js/magnific/jquery.magnific-popup.min.js - About 1 hr to fix

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

          function wfdownloads_notify_iteminfo($category, $item_id)
          {
              global $xoopsModule, $xoopsModuleConfig;
          
              if (empty($xoopsModule) || 'wfdownloads' !== $xoopsModule->dirname()) {
          Severity: Minor
          Found in include/notification.inc.php - About 1 hr to fix

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

                public static function getFileStatus($file_path, $original_file_path = null, $redirectFile = null)
                {
                    global $pathIcon16;
            
                    if (empty($file_path)) {
            Severity: Minor
            Found in class/Common/FileChecker.php - About 1 hr to fix

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

                  public static function convertOrderByTrans($orderby)
                  {
                      $orderbyTrans = '';
                      if ('title ASC' === $orderby) {
                          $orderbyTrans = \_MD_WFDOWNLOADS_TITLEATOZ;
              Severity: Minor
              Found in class/Utility.php - About 1 hr to fix

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

                    public static function isNewImage($published)
                    {
                        if ($published <= 0) {
                            $indicator['image']   = 'assets/images/icon/download.gif';
                            $indicator['alttext'] = \_MD_WFDOWNLOADS_NO_FILES;
                Severity: Minor
                Found in class/Utility.php - About 1 hr to fix

                  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 getUserAverage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getUserAverage($criteria = null)
                      {
                          $groupby = false;
                          $field   = '';
                          if (null !== $criteria && $criteria instanceof \CriteriaElement) {
                  Severity: Minor
                  Found in class/RatingHandler.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 xoops_module_install_wfdownloads has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function xoops_module_install_wfdownloads(XoopsModule $module)
                  {
                      global $xoopsModule;
                      require_once dirname(__DIR__, 3) . '/mainfile.php';
                      require_once __DIR__ . '/common.php';
                  Severity: Minor
                  Found in include/oninstall.php - About 1 hr to fix

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

                        public static function lettersChoice()
                        {
                            $helper = Helper::getInstance();
                    
                            $criteria = $helper->getHandler('Download')->getActiveCriteria();
                    Severity: Minor
                    Found in class/Utility.php - About 1 hr to fix

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

                      function wfdownloads_top_show($options)
                      {
                          if (!class_exists(Helper::class)) {
                              return false;
                          }
                      Severity: Minor
                      Found in blocks/top.php - About 1 hr to fix

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

                            public static function convertorderbyout($orderby)
                            {
                                if ('title ASC' === $orderby) {
                                    $orderby = 'titleA';
                                }
                        Severity: Minor
                        Found in class/Utility.php - About 1 hr to fix

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

                                  if ((0 != $helper->getConfig('com_rule')) || ((0 != $helper->getConfig('com_rule')) && is_object($xoopsUser))) {
                                      if (0 != $comments) {
                                          $eachentry['comments'] = "<a href='entry.php?entryID=" . $eachentry['id'] . "'>" . $comments . '&nbsp;' . _COMMENTS . '</a>';
                                      } else {
                                          $eachentry['comments'] = '';
                          Severity: Major
                          Found in letter.php and 1 other location - About 1 hr to fix
                          letter.php on lines 113..119

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

                          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 ((0 != $helper->getConfig('com_rule')) || ((0 != $helper->getConfig('com_rule')) && is_object($xoopsUser))) {
                                      if (0 != $comments) {
                                          $eachentry['comments'] = "<a href='entry.php?entryID=" . $eachentry['id'] . "'>" . $comments . '&nbsp;' . _COMMENTS . '</a>';
                                      } else {
                                          $eachentry['comments'] = '';
                          Severity: Major
                          Found in letter.php and 1 other location - About 1 hr to fix
                          letter.php on lines 187..193

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

                          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