mambax7/randomquote

View on GitHub

Showing 45 of 45 total issues

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

    public static function meta_keywords($content)
    {
        global $xoopsTpl, $xoTheme;
        $myts    = \MyTextSanitizer::getInstance();
        $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content));
Severity: Major
Found in class/utility.php and 1 other location - About 1 hr to fix
class/utility.php on lines 116..126

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

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

    public static function meta_description($content)
    {
        global $xoopsTpl, $xoTheme;
        $myts    = \MyTextSanitizer::getInstance();
        $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content));
Severity: Major
Found in class/utility.php and 1 other location - About 1 hr to fix
class/utility.php on lines 101..111

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

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

function randomquote_search($queryarray, $andor, $limit, $offset, $userid)
{
    $ret = array();
    if (0 != (int)$userid) {
        return $ret;
Severity: Minor
Found in include/search.inc.php - About 1 hr to fix

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

            function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid)
            {
                $permissionArray = $myArray;
                if ($id > 0) {
                    $sql = 'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name` = '" . $permissionName . "' AND `gperm_itemid`= $id;";
    Severity: Minor
    Found in admin/category.php - About 1 hr to fix

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

          public static function xcopy($source, $dest)
          {
              // Check for symlinks
              if (is_link($source)) {
                  return symlink(readlink($source), $dest);
      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 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

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

      function randomquote_tag_iteminfo(&$items)
      {
          if (empty($items) || !is_array($items)) {
              return false;
          }
      Severity: Minor
      Found in include/plugin.tag.php - About 1 hr to fix

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

            public static function getServerStats()
            {
                //mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
                $moduleDirName      = basename(dirname(dirname(__DIR__)));
                $moduleDirNameUpper = strtoupper($moduleDirName);
        Severity: Minor
        Found in class/common/ServerStats.php - About 1 hr to fix

          Method randomquote_tag_synchronization has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function randomquote_tag_synchronization($mid)
          {
              $moduleDirName = basename(dirname(__DIR__));
              require_once $GLOBALS['xoops']->path("/modules/{$moduleDirName}/class/constants.php");
          
          
          Severity: Minor
          Found in include/plugin.tag.php - About 1 hr to fix

            Method deleteDirectory has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function deleteDirectory($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

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

                      if ($quotesTempRows > $quotesPaginationLimit) {
                          require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
              
                          $pagenav = new \XoopsPageNav($quotesTempRows, $quotesPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . '');
                          $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : '');
              Severity: Minor
              Found in admin/quotes.php and 1 other location - About 55 mins to fix
              admin/category.php on lines 60..65

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

              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 ($categoryTempRows > $categoryPaginationLimit) {
                          require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
              
                          $pagenav = new \XoopsPageNav($categoryTempRows, $categoryPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . '');
                          $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : '');
              Severity: Minor
              Found in admin/category.php and 1 other location - About 55 mins to fix
              admin/quotes.php on lines 60..65

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

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

              function xoops_module_install_randomquote(\XoopsModule $module)
              {
                  include __DIR__ . '/../preloads/autoloader.php';
              
                  $moduleDirName = basename(dirname(__DIR__));
              Severity: Minor
              Found in include/oninstall.php - About 55 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 rmove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function rmove($src, $dest)
                  {
                      // 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 55 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 rcopy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function rcopy($src, $dest)
                  {
                      // 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 55 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 setPermissions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid)
                      {
                          $permissionArray = $myArray;
                          if ($id > 0) {
                              $sql = 'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name` = '" . $permissionName . "' AND `gperm_itemid`= $id;";
              Severity: Minor
              Found in admin/category.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 setPermissions has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid)
              Severity: Minor
              Found in admin/category.php - About 45 mins to fix

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

                    public static function recurseCopy($src, $dst)
                    {
                        $dir = opendir($src);
                        @mkdir($dst);
                        while (false !== ($file = readdir($dir))) {
                Severity: Minor
                Found in class/common/FilesManagement.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

                Avoid deeply nested control flow statements.
                Open

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

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

                  function showRandomquoteBlockViews($options)
                  {
                      $moduleDirName = basename(dirname(__DIR__));
                      //    require_once XOOPS_ROOT_PATH . '/modules/randomquote/class/quotes.php';
                      $utility = new randomquote\Utility();
                  Severity: Minor
                  Found in blocks/views.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

                  Severity
                  Category
                  Status
                  Source
                  Language