mambax7/gwiki

View on GitHub
admin/prefixes.php

Summary

Maintainability
F
3 days
Test Coverage

File prefixes.php has 514 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * admin/prefixes.php - manage wiki namespaces
 *
Severity: Major
Found in admin/prefixes.php - About 1 day to fix

    Method showPrefixes has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function showPrefixes()
    {
        global $xoopsDB;
        /*
        gwiki_prefix
    Severity: Major
    Found in admin/prefixes.php - About 3 hrs to fix

      Method updatePrefix has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function updatePrefix($pid)
      {
          global $xoopsDB, $wikiPage;
      
          $row = getPrefix($pid);
      Severity: Minor
      Found in admin/prefixes.php - About 1 hr to fix

        Method installTemplate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function installTemplate($pid, $delete = false)
        {
            global $xoopsModule;
        
            $template = getPrefix($pid);
        Severity: Minor
        Found in admin/prefixes.php - About 1 hr to fix

          Method updateTemplate has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function updateTemplate($pid)
          {
              global $xoopsDB, $wikiPage;
          
              $row = getPrefix($pid);
          Severity: Minor
          Found in admin/prefixes.php - About 1 hr to fix

            Function updatePrefix has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

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

            function showPrefixes()
            {
                global $xoopsDB;
                /*
                gwiki_prefix
            Severity: Minor
            Found in admin/prefixes.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 installTemplate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            function installTemplate($pid, $delete = false)
            {
                global $xoopsModule;
            
                $template = getPrefix($pid);
            Severity: Minor
            Found in admin/prefixes.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 prefixForm has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function prefixForm($row, $action)
            {
                if (empty($row)) {
                    return false;
                }
            Severity: Minor
            Found in admin/prefixes.php - About 1 hr to fix

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

              function prefixForm($row, $action)
              {
                  if (empty($row)) {
                      return false;
                  }
              Severity: Minor
              Found in admin/prefixes.php - About 25 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 setPrefixGroups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function setPrefixGroups($pid, $groups)
              {
                  global $xoopsDB;
              
                  $sql = 'DELETE FROM ' . $xoopsDB->prefix('gwiki_group_prefix');
              Severity: Minor
              Found in admin/prefixes.php - About 25 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 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

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

              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

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

                      echo '<tr class="'
                           . (($i % 2) ? 'even' : 'odd')
                           . '"><td><a href="prefixes.php?pid='
                           . $row['prefix_id']
                           . '&op=edit">'
              Severity: Minor
              Found in admin/prefixes.php and 1 other location - About 30 mins to fix
              admin/attachments.php on lines 187..198

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

              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

              There are no issues that match your filters.

              Category
              Status