mambax7/gwiki

View on GitHub

Showing 181 of 181 total issues

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

if ($pageX['pageFound']) {
    $xoTheme->addMeta('meta', 'keywords', htmlspecialchars($pageX['meta_keywords'], ENT_QUOTES, null, false));
    $xoTheme->addMeta('meta', 'description', htmlspecialchars($pageX['meta_description'], ENT_QUOTES, null, false));
}
Severity: Major
Found in extras/gwiki.php and 2 other locations - About 50 mins to fix
index.php on lines 109..112
showdiff.php on lines 74..77

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

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 showDOMNode has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

function showDOMNode(&$out, DOMNode $domNode, $nest, $lt, $ld, $nop)
Severity: Minor
Found in wizard.php - About 45 mins to fix

    Method gwiki_search has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function gwiki_search($queryarray, $andor, $limit, $offset, $userid, $prefix = null)
    Severity: Minor
    Found in include/search.inc.php - About 45 mins to fix

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

          public function getUserNamespaces($createonly = false)
          {
              global $xoopsUser, $xoopsDB;
      
              $dir = $this->wikiDir;
      Severity: Minor
      Found in class/GwikiPage.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

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

      function confirmAction($action, $keyword = '', $id = -1)
      {
          adminTableStart(_AD_GWIKI_CONFIRM, 1);
          echo '<tr><td width="100%" >';
          echo '<div class="confirmMsg">';
      Severity: Minor
      Found in admin/pages.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

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

          private function getIndexTabs()
          {
              global $xoopsDB;
      
              $tabs = [];
      Severity: Minor
      Found in class/GwikiPage.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

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

          function gwiki_notify_iteminfo($category, $item_id)
          {
              global $xoopsDB;
              $helper = Helper::getInstance();
      
      
      Severity: Minor
      Found in include/notification.inc.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

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

          private function renderBox($matches)
          {
              $type  = $matches[1];
              $title = $matches[2];
              $body  = $matches[3];
      Severity: Minor
      Found in class/GwikiPage.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

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

          public function renderPageSetToc(&$page, $level, $tocclass = 'wikitocpage')
          {
              $toc = $this->fetchPageSetToc($page);
              if (!$toc) {
                  return false;
      Severity: Minor
      Found in class/GwikiPage.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

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

      function updateFile($newfile, &$input)
      {
          global $uploadpath, $xoopsDB;
          // For now, images are stored in individual directories for each page.
          // We can change the directory distribution later, as the entire path
      Severity: Minor
      Found in ajaxfileedit.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

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

          echo '<tr class="head">'
               . '<th>'
               . _AD_GWIKI_FILES_KEYWORD
               . '</th>'
               . '<th>'
      Severity: Minor
      Found in admin/attachments.php and 1 other location - About 45 mins to fix
      admin/prefixes.php on lines 106..125

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

      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

          echo '<tr class="head">'
               . '<th>'
               . _AD_GWIKI_NAMESPACE_PREFIX
               . '</th>'
               . '<th>'
      Severity: Minor
      Found in admin/prefixes.php and 1 other location - About 45 mins to fix
      admin/attachments.php on lines 136..155

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

      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

      Consider simplifying this complex logical expression.
      Open

              if (!('code' === $type || 'info' === $type || 'note' === $type || 'tip' === $type || 'warn' === $type
                    || 'folded' === $type)) {
                  $type = 'info';
              }
      Severity: Major
      Found in class/GwikiPage.php - About 40 mins to fix

        Method _printDiff has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected function _printDiff($c, $s1, $s2, $i, $j)
        Severity: Minor
        Found in class/Library/Diff.php - About 35 mins to fix

          Method _printDiff has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              protected function _printDiff($c, $s1, $s2, $i, $j)
          Severity: Minor
          Found in include/Diff.php - About 35 mins to fix

            Method truncateHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
            Severity: Minor
            Found in class/Common/SysUtility.php - About 35 mins to fix

              Function updatePageLinks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function updatePageLinks($render = false)
                  {
                      global $xoopsDB;
              
                      if ($render) {
              Severity: Minor
              Found in class/GwikiPage.php - About 35 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 prepOut has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function prepOut(&$var)
              {
                  if (is_array($var)) {
                      foreach ($var as $i => $v) {
                          $var[$i] = prepOut($v);
              Severity: Minor
              Found in extras/gwiki.php - About 35 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 makeKeywordFromPrefix has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function makeKeywordFromPrefix($nsid, $page)
                  {
                      if ($nsid >= 0) {
                          $pfx = $this->getPrefixFromId($nsid);
                          if (empty($page)) {
              Severity: Minor
              Found in class/GwikiPage.php - About 35 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 prepOut has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function prepOut(&$var)
              {
                  if (is_array($var)) {
                      foreach ($var as $i => $v) {
                          $var[$i] = prepOut($v);
              Severity: Minor
              Found in include/functions.php - About 35 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