XoopsModules25x/xoopsfaq

View on GitHub

Showing 48 of 48 total issues

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

<?php declare(strict_types=1);
/*
 You may not change or alter any portion of this comment or credits of
 supporting developers from this source code or any supporting source code
 which is considered copyrighted (c) material of the original comment or credit
Severity: Major
Found in include/search.php and 1 other location - About 4 days to fix
include/search.inc.php on lines 1..122

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

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

<?php declare(strict_types=1);
/*
 You may not change or alter any portion of this comment or credits of
 supporting developers from this source code or any supporting source code
 which is considered copyrighted (c) material of the original comment or credit
Severity: Major
Found in include/search.inc.php and 1 other location - About 4 days to fix
include/search.php on lines 1..122

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

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

function xoopsfaq_rss(int $max = 10)
{
    /** @var CategoryHandler $categoryHandler */
    /** @var ContentsHandler $contentsHandler */
    /** @var Helper $helper */
Severity: Major
Found in include/rss.php and 1 other location - About 1 day to fix
include/rss.inc.php on lines 37..81

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

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

function xoopsfaq_rss(int $max = 10)
{
    /** @var Xoopsfaq\CategoryHandler $categoryHandler */
    /** @var Xoopsfaq\ContentsHandler $contentsHandler */
    $helper          = Helper::getInstance();
Severity: Major
Found in include/rss.inc.php and 1 other location - About 1 day to fix
include/rss.php on lines 38..83

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

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

    public static function truncateHtml(
        string $text,
        ?int   $length = null,
        string $ending = '...',
        bool   $exact = false,
Severity: Minor
Found in class/Common/SysUtility.php - About 1 day 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 xoops_module_update_xoopsfaq has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

function xoops_module_update_xoopsfaq(XoopsModule $module, string $prev_version)
{
    $moduleDirName = $module->getVar('dirname');
    $helper        = Helper::getInstance();
    //    if (!class_exists('Xoopsfaq\Utility')) {
Severity: Minor
Found in include/onupdate.php - About 4 hrs 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 renderAdminListing has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function renderAdminListing($sort = null): string
    {
        $sort ??= 'id';
        //        if (!\class_exists('Xoopsfaq\Utility')) {
        //            \xoops_load('utility', \basename(\dirname(__DIR__)));
Severity: Major
Found in class/ContentsHandler.php - About 3 hrs to fix

    Method renderForm has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function renderForm()
        {
            /** @var CategoryHandler $categoryHandler */
            /** @var Helper $helper */
            $helper          = Helper::getHelper($this->dirname);
    Severity: Major
    Found in class/Contents.php - About 3 hrs to fix

      Function checkVerModule has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function checkVerModule(Helper $helper, ?string $source = null, ?string $default = null): ?array
          {
              $source             ??= 'github';
              $default            ??= 'master';
              $moduleDirName      = \basename(\dirname(__DIR__, 2));
      Severity: Minor
      Found in class/Common/VersionChecks.php - About 2 hrs 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 truncateHtml has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function truncateHtml(
              string $text,
              ?int   $length = null,
              string $ending = '...',
              bool   $exact = false,
      Severity: Major
      Found in class/Common/SysUtility.php - About 2 hrs to fix

        File SysUtility.php has 270 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php declare(strict_types=1);
        
        namespace XoopsModules\Xoopsfaq\Common;
        
        /*
        Severity: Minor
        Found in class/Common/SysUtility.php - About 2 hrs to fix

          Function deleteDirectory has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              final public static function deleteDirectory(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 2 hrs 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 xoopsfaq_search has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function xoopsfaq_search($queryarray, $andor, $limit, $offset, $userid)
          {
              $ret = [];
              if (0 != $userid) {
                  return $ret;
          Severity: Major
          Found in include/search.php - About 2 hrs to fix

            Method xoopsfaq_search has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function xoopsfaq_search($queryarray, $andor, $limit, $offset, $userid)
            {
                $ret = [];
                if (0 != $userid) {
                    return $ret;
            Severity: Major
            Found in include/search.inc.php - About 2 hrs to fix

              Method b_xoopsfaq_recent_show has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function b_xoopsfaq_recent_show(array $options)
              {
                  $moduleDirName = \basename(\dirname(__DIR__));
              
                  $myts = \MyTextSanitizer::getInstance();
              Severity: Major
              Found in blocks/xoopsfaq_recent.php - About 2 hrs to fix

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

                    public static function queryAndCheck(\XoopsMySQLDatabase $xoopsDB, string $sql, ?int $limit = null, ?int $start = null): \mysqli_result
                    {
                        $limit ??= 0;
                        $start ??= 0;
                        $result = $xoopsDB->query($sql, $limit, $start);
                Severity: Major
                Found in class/Common/SysUtility.php and 1 other location - About 2 hrs to fix
                class/Common/SysUtility.php on lines 451..464

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

                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 queryFAndCheck(\XoopsMySQLDatabase $xoopsDB, string $sql, ?int $limit = null, ?int $start = null): \mysqli_result
                    {
                        $limit ??= 0;
                        $start ??= 0;
                        $result = $xoopsDB->queryF($sql, $limit, $start);
                Severity: Major
                Found in class/Common/SysUtility.php and 1 other location - About 2 hrs to fix
                class/Common/SysUtility.php on lines 426..439

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

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

                function b_xoopsfaq_random_show(array $options)
                {
                    $moduleDirName = \basename(\dirname(__DIR__));
                    $myts          = \MyTextSanitizer::getInstance();
                
                Severity: Minor
                Found in blocks/xoopsfaq_rand.php - About 1 hr to fix

                  Function b_xoopsfaq_recent_show has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function b_xoopsfaq_recent_show(array $options)
                  {
                      $moduleDirName = \basename(\dirname(__DIR__));
                  
                      $myts = \MyTextSanitizer::getInstance();
                  Severity: Minor
                  Found in blocks/xoopsfaq_recent.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 xoops_module_update_xoopsfaq has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function xoops_module_update_xoopsfaq(XoopsModule $module, string $prev_version)
                  {
                      $moduleDirName = $module->getVar('dirname');
                      $helper        = Helper::getInstance();
                      //    if (!class_exists('Xoopsfaq\Utility')) {
                  Severity: Minor
                  Found in include/onupdate.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language