XoopsModules25x/wfdownloads

View on GitHub

Showing 279 of 279 total issues

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

    case 'mirror.delete':
        $mirror_id = Request::getInt('mirror_id', 0);
        $ok        = Request::getBool('ok', false, 'POST');
        if (!$mirrorObj = $helper->getHandler('Mirror')->get($mirror_id)) {
            redirect_header($currentFile, 4, _AM_WFDOWNLOADS_ERROR_MIRRORNOTFOUND);
Severity: Major
Found in admin/mirrors.php and 2 other locations - About 1 day to fix
admin/mimetypes.php on lines 153..174
admin/reviews.php on lines 39..60

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

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

    case 'mimetype.delete':
        $mime_id = Request::getInt('mime_id', 0);
        $ok      = Request::getBool('ok', false, 'POST');
        if (!$mimetypeObj = $helper->getHandler('Mimetype')->get($mime_id)) {
            redirect_header($currentFile, 4, _AM_WFDOWNLOADS_ERROR_MIMETYPENOTFOUND);
Severity: Major
Found in admin/mimetypes.php and 2 other locations - About 1 day to fix
admin/mirrors.php on lines 36..57
admin/reviews.php on lines 39..60

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

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

<?php

namespace XoopsModules\Wfdownloads\Common;

/*
Severity: Major
Found in class/Common/ObjectTree.php and 1 other location - About 1 day to fix
class/ObjectTree.php on lines 1..87

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

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 onupdate.php has 541 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
 You may not change or alter any portion of this comment or credits
 of supporting developers from this source code or any supporting source code
 which is considered copyrighted (c) material of the original comment or credit authors.
Severity: Major
Found in include/onupdate.php - About 1 day to fix

    Method update_tables_to_322 has 213 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function update_tables_to_322($module)
    {
        $dbupdater = new Wfdownloads\Dbupdater();
    
        // create wfdownloads_meta table
    Severity: Major
    Found in include/onupdate.php - About 1 day to fix

      Method listBlocks has 212 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function listBlocks()
          {
              global $xoopsModule, $pathIcon16;
              require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
              $moduleDirName = basename(dirname(__DIR__));
      Severity: Major
      Found in admin/blocksadmin.php - About 1 day to fix

        Function xoops_module_update_wfdownloads has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
        Open

        function xoops_module_update_wfdownloads(XoopsModule $module, $previousVersion = null)
        {
            $moduleDirName      = basename(dirname(__DIR__));
            $moduleDirNameUpper = mb_strtoupper($moduleDirName);
        
        
        Severity: Minor
        Found in include/onupdate.php - About 1 day 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 truncateHtml has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
            {
                if ($considerHtml) {
                    // if the plain text is shorter than the maximum length, return the whole text
                    if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
        Severity: Minor
        Found in class/Utility.php - About 1 day 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 truncateHtml has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
            {
                if ($considerHtml) {
                    // if the plain text is shorter than the maximum length, return the whole text
                    if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
        Severity: Minor
        Found in class/Common/SysUtility.php - About 1 day 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

        Utility has 56 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Utility extends Common\SysUtility
        {
            //--------------- Custom module methods -----------------------------
            /**
             * @param     $categoryObj
        Severity: Major
        Found in class/Utility.php - About 1 day to fix

          File blocksadmin.php has 499 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * You may not change or alter any portion of this comment or credits
           * of supporting developers from this source code or any supporting source code
           * which is considered copyrighted (c) material of the original comment or credit authors.
          Severity: Minor
          Found in admin/blocksadmin.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

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

                      if (!$isANewRecord && ($downloadObj->getVar('version') != $version)) {
                          // Trigger the three events related to modified files (one for the file, category, and global event categories respectively)
                          $tags                  = [];
                          $tags['FILE_NAME']     = $title;
                          $tags['FILE_URL']      = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&amp;lid={$lid}";
              Severity: Major
              Found in submit.php and 1 other location - About 6 hrs to fix
              admin/downloads.php on lines 344..360

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

              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 (!$thisIsANewRecord && ($downloadObj->getVar('version') != $version)) {
                          // Trigger the three events related to modified files (one for the file, category, and global event categories respectively)
                          $tags                  = [];
                          $tags['FILE_NAME']     = $title;
                          $tags['FILE_URL']      = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&amp;lid={$lid}";
              Severity: Major
              Found in admin/downloads.php and 1 other location - About 6 hrs to fix
              submit.php on lines 381..397

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

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

                Method import_wfd_to_wfdownloads has 165 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function import_wfd_to_wfdownloads()
                {
                    /** @var \XoopsModuleHandler $moduleHandler */
                    $moduleHandler = xoops_getHandler('module');
                    // Get destination module/handlers/configs
                Severity: Major
                Found in admin/import.php - About 6 hrs to fix

                  Function listBlocks has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                  Open

                      function listBlocks()
                      {
                          global $xoopsModule, $pathIcon16;
                          require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
                          $moduleDirName = basename(dirname(__DIR__));
                  Severity: Minor
                  Found in admin/blocksadmin.php - About 6 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

                  File jquery.magnific-popup.min.js has 427 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  /*! Magnific Popup - v0.9.9 - 2013-12-27
                   * http://dimsemenov.com/plugins/magnific-popup/
                   * Copyright (c) 2013 Dmitry Semenov; */
                  (function (e) {
                      var t, n, i, o, r, a, s, l = "Close", c = "BeforeClose", d = "AfterClose", u = "BeforeAppend", p = "MarkupParse", f = "Open", m = "Change", g = "mfp", h = "." + g, v = "mfp-ready", C = "mfp-removing", y = "mfp-prevent-close", w = function () {
                  Severity: Minor
                  Found in assets/js/magnific/jquery.magnific-popup.min.js - About 6 hrs to fix

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

                    <?php
                    /*
                     You may not change or alter any portion of this comment or credits
                     of supporting developers from this source code or any supporting source code
                     which is considered copyrighted (c) material of the original comment or credit authors.
                    Severity: Minor
                    Found in submit.php - About 6 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language