mambax7/gwiki

View on GitHub

Showing 181 of 181 total issues

Function _printDiff has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _printDiff($c, $s1, $s2, $i, $j)
    {
        $diff = '';
        if ($i >= 0 && $j >= 0 && $s1[$i] === $s2[$j]) {
            $diff .= $this->_printDiff($c, $s1, $s2, $i - 1, $j - 1);
Severity: Minor
Found in class/Library/Diff.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 _lsm has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _lsm($s1, $s2)
    {
        $mStart = 0;
        $mEnd   = count($s1) - 1;
        $nStart = 0;
Severity: Minor
Found in include/Diff.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 updatePageLinks has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function updatePageLinks($render = false)
    {
        global $xoopsDB;

        if ($render) {
Severity: Minor
Found in class/GwikiPage.php - About 1 hr to fix

    Method obtainPage has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function obtainPage()
    {
        global $wikiPage, $xoopsTpl, $token;
    
        $wikiPage = new Gwiki\GwikiPage();
    Severity: Minor
    Found in wizard.php - About 1 hr to fix

      Method renderGallery has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function renderGallery($matches)
          {
              global $xoopsDB;
      
              $source = '';
      Severity: Minor
      Found in class/GwikiPage.php - About 1 hr to fix

        Method loadSampleData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function loadSampleData()
        {
            global $xoopsConfig;
            $moduleDirName      = \basename(\dirname(__DIR__));
            $moduleDirNameUpper = mb_strtoupper($moduleDirName);
        Severity: Minor
        Found in testdata/index.php - About 1 hr to fix

          Method getIndexTabs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getIndexTabs()
              {
                  global $xoopsDB;
          
                  $tabs = [];
          Severity: Minor
          Found in class/GwikiPage.php - About 1 hr to fix

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

                public function getPrefix($keyword)
                {
                    /*
                     gwiki_prefix columns
                      prefix_id
            Severity: Minor
            Found in class/GwikiPage.php - About 1 hr to fix

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

                      if (!$tplfileHandler->insert($tplfile)) {
                          echo '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars($file, ENT_QUOTES | ENT_HTML5) . '</b> to the database.</span><br>';
                      } else {
                          $tplid = $tplfile->getVar('tpl_id');
                          echo 'Template <b>' . htmlspecialchars($file, ENT_QUOTES | ENT_HTML5) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)<br>';
              Severity: Minor
              Found in admin/prefixes.php and 1 other location - About 55 mins to fix
              admin/prefixes.php on lines 449..454

              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 (!$tplfileHandler->forceUpdate($tplfile)) {
                      echo '<span style="color:#ff0000;">ERROR: Could not update template <b>' . htmlspecialchars($file, ENT_QUOTES | ENT_HTML5) . '</b> to the database.</span><br>';
                  } else {
                      $tplid = $tplfile->getVar('tpl_id');
                      echo 'Template <b>' . htmlspecialchars($file, ENT_QUOTES | ENT_HTML5) . '</b> updated to the database. (ID: <b>' . $tplid . '</b>)<br>';
              Severity: Minor
              Found in admin/prefixes.php and 1 other location - About 55 mins to fix
              admin/prefixes.php on lines 442..447

              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

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

                  if (empty($row['template'])) {
                      $template = '<a href="prefixes.php?pid=' . $row['prefix_id'] . '&op=newtemplate">' . _AD_GWIKI_TEMPLATE_ADD . '</a>';
                  } else {
                      $template = '<a href="prefixes.php?pid=' . $row['prefix_id'] . '&op=edittemplate" title="' . _AD_GWIKI_TEMPLATE_EDIT . '">' . htmlspecialchars($row['template'], ENT_QUOTES) . '</a>';
                  }
              Severity: Minor
              Found in admin/prefixes.php and 1 other location - About 55 mins to fix
              admin/prefixes.php on lines 136..140

              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

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

                      if (empty($row['template'])) {
                          $template = '<a href="prefixes.php?pid=' . $row['prefix_id'] . '&op=newtemplate">' . _AD_GWIKI_TEMPLATE_ADD . '</a>';
                      } else {
                          $template = '<a href="prefixes.php?pid=' . $row['prefix_id'] . '&op=edittemplate" title="' . _AD_GWIKI_TEMPLATE_EDIT . '">' . htmlspecialchars($row['template'], ENT_QUOTES) . '</a>';
                      }
              Severity: Minor
              Found in admin/prefixes.php and 1 other location - About 55 mins to fix
              admin/prefixes.php on lines 208..212

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

              function updateTemplate($pid)
              {
                  global $xoopsDB, $wikiPage;
              
                  $row = getPrefix($pid);
              Severity: Minor
              Found in admin/prefixes.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 recurseCopy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function recurseCopy($src, $dst)
                  {
                      $dir = \opendir($src);
                      //        @mkdir($dst);
                      if (!@\mkdir($dst) && !\is_dir($dst)) {
              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 getExtensionInfo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function getExtensionInfo($filename)
              {
                  global $whitelist;
              
                  $fi = [];
              Severity: Minor
              Found in ajaxfileedit.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 doImportText has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function doImportText($page, $dir)
              {
                  $import   = '';
                  $pathname = XOOPS_ROOT_PATH . '/uploads/' . $dir . '/';
                  if (isset($_POST['xoops_upload_file'][0])) {
              Severity: Minor
              Found in wizard.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

              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

              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 showdiff.php and 2 other locations - About 50 mins to fix
              extras/gwiki.php on lines 148..151
              index.php on lines 109..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 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

              Severity
              Category
              Status
              Source
              Language