XoopsModules25x/wfdownloads

View on GitHub

Showing 279 of 279 total issues

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

    private function moveDoColumns()
    {
        $tableName    = 'wfdownloads_posts_text';
        $srcTableName = 'wfdownloads_posts';
        if ($this->tableHandler->useTable($tableName)
Severity: Major
Found in class/Common/Migrate.php and 1 other location - About 3 hrs to fix
class/Migrate.php on lines 95..110

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

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

    public static function createThumb($imgName, $imgPath, $imgSavePath, $width = 100, $height = 100, $quality = 100, $update = false, $aspect = 1)
    {
        $helper = Helper::getInstance();

        // Paths
Severity: Minor
Found in class/Utility.php - About 3 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 editCategory has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCats = 4, $categoryObj = null)
    {
        $helper = Helper::getInstance();

        // if there is a parameter, and the id exists, retrieve data: we're editing a category
Severity: Minor
Found in class/Utility.php - About 3 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 largeDownload has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public static function largeDownload($filePath, $fileMimetype)
    {
        /* You may need these ini settings too */
        \set_time_limit(0);
        \ini_set('memory_limit', '512M');
Severity: Minor
Found in class/Utility.php - About 3 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 main.php has 298 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 language/english/main.php - About 3 hrs to fix

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

    if (('' != $categoryObj->getVar('imgurl'))
        && is_file(XOOPS_ROOT_PATH . '/' . $helper->getConfig('catimage') . '/' . $categoryObj->getVar('imgurl'))) {
        if ($helper->getConfig('usethumbs') && function_exists('gd_info')) {
            $imgurl = Utility::createThumb(
                $categoryObj->getVar('imgurl'),
    Severity: Major
    Found in singlefile.php and 1 other location - About 2 hrs to fix
    viewcat.php on lines 191..208

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

    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 (('' !== $subCategoryObj->getVar('imgurl')) && is_file(XOOPS_ROOT_PATH . '/' . $helper->getConfig('catimage') . '/' . $subCategoryObj->getVar('imgurl'))) {
                if ($helper->getConfig('usethumbs') && function_exists('gd_info')) {
                    $imageURL = Utility::createThumb(
                        $subCategoryObj->getVar('imgurl'),
                        $helper->getConfig('catimage'),
    Severity: Major
    Found in viewcat.php and 1 other location - About 2 hrs to fix
    singlefile.php on lines 94..112

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

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

        public static function checkVerModule($helper, $source = 'github', $default = 'master')
        {
            $moduleDirName      = \basename(dirname(__DIR__, 2));
            $moduleDirNameUpper = mb_strtoupper($moduleDirName);
            $update             = '';
    Severity: Minor
    Found in class/Common/VersionChecks.php - About 2 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

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

            $cachetimes = [
                '0' => _NOCACHE,
                '30' => sprintf(_SECONDS, 30),
                '60' => _MINUTE,
                '300' => sprintf(_MINUTES, 5),
    Severity: Major
    Found in admin/blocksadmin.php and 1 other location - About 2 hrs to fix
    admin/blockform.php on lines 100..112

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

    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

        [
                                      '0' => _NOCACHE,
                                      '30' => sprintf(_SECONDS, 30),
                                      '60' => _MINUTE,
                                      '300' => sprintf(_MINUTES, 5),
    Severity: Major
    Found in admin/blockform.php and 1 other location - About 2 hrs to fix
    admin/blocksadmin.php on lines 117..129

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

    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 addElement has a Cognitive Complexity of 21 (exceeds 5 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 2 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 import_wmpdownloads_to_wfdownloads has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function import_wmpdownloads_to_wfdownloads()
    {
        echo '<br>';
        echo _AM_WFDOWNLOADS_IMPORT_IMPORTINGDATA;
        echo '<br>';
    Severity: Major
    Found in admin/import.php - About 2 hrs to fix

      Method createThumb has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function createThumb($imgName, $imgPath, $imgSavePath, $width = 100, $height = 100, $quality = 100, $update = false, $aspect = 1)
          {
              $helper = Helper::getInstance();
      
              // Paths
      Severity: Major
      Found in class/Utility.php - About 2 hrs to fix

        Method import_mydownloads_to_wfdownloads has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function import_mydownloads_to_wfdownloads()
        {
            echo '<br>';
            echo _AM_WFDOWNLOADS_IMPORT_IMPORTINGDATA;
            echo '<br>';
        Severity: Major
        Found in admin/import.php - About 2 hrs to fix

          DbupdaterTable has 25 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class DbupdaterTable
          {
              /**
               * @var string $_name name of the table
               */
          Severity: Minor
          Found in class/DbupdaterTable.php - About 2 hrs to fix

            Method import_pddownloads_to_wfdownloads has 69 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function import_pddownloads_to_wfdownloads()
            {
                echo '<br>';
                echo _AM_WFDOWNLOADS_IMPORT_IMPORTINGDATA;
                echo '<br>';
            Severity: Major
            Found in admin/import.php - About 2 hrs to fix

              Function getListTypeAsArray has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function getListTypeAsArray($dirname, $type = '', $prefix = '', $noselection = 1)
                  {
                      $filelist = [];
                      switch (\trim($type)) {
                          case 'images':
              Severity: Minor
              Found in class/WfsLists.php - About 2 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 isBlockCloned has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options = null)
                  {
                      xoops_loadLanguage('admin', 'system');
                      xoops_loadLanguage('admin/blocksadmin', 'system');
                      xoops_loadLanguage('admin/groups', 'system');
              Severity: Minor
              Found in admin/blocksadmin.php - About 2 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

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

                      if (Utility::checkModule('wmpdownloads')) {
                          $moduleVersion = round(Utility::checkModule('wmpdownloads') / 100, 2);
                          $button        = new XoopsFormButton(_AM_WFDOWNLOADS_IMPORT_WMPOWNLOADS . '<br>' . $moduleVersion, 'wmp_button', _AM_WFDOWNLOADS_IMPORT_BUTTON_IMPORT, 'submit');
                          $button->setExtra("onclick='document.forms.form.op.value=\"import.wmpownloads\"'");
                          $form->addElement($button);
              Severity: Major
              Found in admin/import.php and 3 other locations - About 2 hrs to fix
              admin/import.php on lines 159..169
              admin/import.php on lines 172..182
              admin/import.php on lines 198..208

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

              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 (Utility::checkModule('tdmdownloads')) {
                          $moduleVersion = round(Utility::checkModule('tdmdownloads') / 100, 2);
                          $button        = new XoopsFormButton(_AM_WFDOWNLOADS_IMPORT_TDMDOWNLOADS . '<br>' . $moduleVersion, 'wmp_button', _AM_WFDOWNLOADS_IMPORT_BUTTON_IMPORT, 'submit');
                          $button->setExtra("onclick='document.forms.form.op.value=\"import.TDMDownloads\"'");
                          $form->addElement($button);
              Severity: Major
              Found in admin/import.php and 3 other locations - About 2 hrs to fix
              admin/import.php on lines 159..169
              admin/import.php on lines 172..182
              admin/import.php on lines 185..195

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

              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