mambax7/tdmdownloads

View on GitHub

Showing 207 of 207 total issues

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

        if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) {
            $adminlink = '<a href="'
                         . XOOPS_URL
                         . '/modules/'
                         . $moduleDirName
Severity: Major
Found in index.php and 1 other location - About 1 hr to fix
viewcat.php on lines 271..287

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

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

function tdmdownloads_search($queryarray, $andor, $limit, $offset, $userid)
{
    global $xoopsDB;
    $moduleDirName = basename(dirname(__DIR__));
    $sql           = 'SELECT lid, cid, title, description, submitter, date FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status != 0';
Severity: Minor
Found in include/search.inc.php - About 1 hr to fix

    Method getForm has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getForm($lid, $action = false)
        {
            //        global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
            if (!$action) {
                $action = $_SERVER['REQUEST_URI'];
    Severity: Minor
    Found in class/Rating.php - About 1 hr to fix

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

                      if (0 === $downloads_field[$i]->getVar('status_def')) {
                          $objdata   = $fielddataHandler->create();
                          $fieldName = 'champ' . $downloads_field[$i]->getVar('fid');
                          $objdata->setVar('data', \Xmf\Request::getString($fieldName, '', 'POST'));
                          $objdata->setVar('lid', $lidDownloads);
      Severity: Major
      Found in submit.php and 1 other location - About 1 hr to fix
      modfile.php on lines 235..244

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

      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 (0 == $downloads_field[$i]->getVar('status_def')) {
                              //$objdata = $modifiedfielddataHandler->create();
                              $objdata   = $modifieddataHandler->create();
                              $fieldName = 'champ' . $downloads_field[$i]->getVar('fid');
                              $objdata->setVar('moddata', \Xmf\Request::getString($fieldName, '', 'POST'));
      Severity: Major
      Found in modfile.php and 1 other location - About 1 hr to fix
      submit.php on lines 251..258

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

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

          public function cloneBlock($bid): void
          {
              //require __DIR__ . '/admin_header.php';
              //        \xoops_cp_header();
      
      
      Severity: Minor
      Found in class/Common/Blocksadmin.php - About 1 hr to fix

        Method createLogo has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function createLogo($dirname)
            {
                if (!\extension_loaded('gd')) {
                    return false;
                }
        Severity: Minor
        Found in class/Cloner.php - About 1 hr to fix

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

              public function editBlock($bid): void
              {
                  //        require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
                  //        \xoops_cp_header();
                  \xoops_loadLanguage('admin', 'system');
          Severity: Minor
          Found in class/Common/Blocksadmin.php - About 1 hr to fix

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

            function loadTableFromArrayWithReplace($table, $data, $search, $replace)
            {
                /** @var \XoopsMySQLDatabase $db */
                $db            = \XoopsDatabaseFactory::getDatabaseConnection();
                $prefixedTable = $db->prefix($table);
            Severity: Minor
            Found in testdata/index.php - About 1 hr to fix

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

                  public function orderBlock(
                      $bid,
                      $oldtitle,
                      $oldside,
                      $oldweight,
              Severity: Minor
              Found in class/Common/Blocksadmin.php - About 1 hr to fix

                Function rrmdir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function rrmdir(string $src): bool
                    {
                        // 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 isBlockCloned has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups): void
                    {
                        \xoops_loadLanguage('admin', 'system');
                        \xoops_loadLanguage('admin/blocksadmin', 'system');
                        \xoops_loadLanguage('admin/groups', 'system');
                Severity: Minor
                Found in class/Common/Blocksadmin.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 tdmdownloads_search has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function tdmdownloads_search($queryarray, $andor, $limit, $offset, $userid)
                {
                    global $xoopsDB;
                    $moduleDirName = basename(dirname(__DIR__));
                    $sql           = 'SELECT lid, cid, title, description, submitter, date FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status != 0';
                Severity: Minor
                Found in include/search.inc.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 tdmdownloads_tag_iteminfo has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function tdmdownloads_tag_iteminfo(&$items)
                {
                    if (empty($items) || !is_array($items)) {
                        return false;
                    }
                Severity: Minor
                Found in extra/plugins/tag/tdmdownloads.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

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

                    case 'update_status':
                        $obj = $fieldHandler->get(\Xmf\Request::getInt('fid', 0, 'REQUEST'));
                        $obj->setVar('status', \Xmf\Request::getInt('aff', 0, 'REQUEST'));
                        if ($fieldHandler->insert($obj)) {
                            redirect_header('field.php?op=list', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE);
                Severity: Major
                Found in admin/field.php and 1 other location - About 1 hr to fix
                admin/field.php on lines 73..80

                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

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

                    case 'update_search':
                        $obj = $fieldHandler->get(\Xmf\Request::getInt('fid', 0, 'REQUEST'));
                        $obj->setVar('search', \Xmf\Request::getInt('aff', 0, 'REQUEST'));
                        if ($fieldHandler->insert($obj)) {
                            redirect_header('field.php?op=list', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE);
                Severity: Major
                Found in admin/field.php and 1 other location - About 1 hr to fix
                admin/field.php on lines 65..72

                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

                Method getStatusImage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getStatusImage($time, $status)
                    {
                        global $xoopsModuleConfig;
                        $moduleDirName = \basename(\dirname(__DIR__));
                        $helper        = Helper::getInstance();
                Severity: Minor
                Found in class/Utility.php - About 1 hr to fix

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

                          if ($xoopsUser) {
                              if (!$xoopsUser->isAdmin($xoopsModule->mid())) {
                                  $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN'));
                              }
                          } else {
                  Severity: Major
                  Found in class/Downloads.php and 1 other location - About 1 hr to fix
                  class/Modified.php on lines 128..134

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

                  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 ($xoopsUser) {
                              if (!$xoopsUser->isAdmin($xoopsModule->mid())) {
                                  $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN'));
                              }
                          } else {
                  Severity: Major
                  Found in class/Modified.php and 1 other location - About 1 hr to fix
                  class/Downloads.php on lines 123..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 104.

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

                      public static function getStatusImage($time, $status)
                      {
                          $moduleDirName = \basename(\dirname(__DIR__));
                          $helper    = Helper::getInstance();
                          $count     = 7;
                  Severity: Minor
                  Found in class/Utilities.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language