XoopsModules25x/xoopsfaq

View on GitHub

Showing 40 of 48 total issues

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

                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

                    Method b_xoopsfaq_recent_edit has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function b_xoopsfaq_recent_edit(array $options)
                    {
                        $moduleDirName = \basename(\dirname(__DIR__));
                        xoops_load('XoopsFormSelect');
                    
                    Severity: Minor
                    Found in blocks/xoopsfaq_recent.php - About 1 hr to fix

                      Method checkVerModule has 44 lines of code (exceeds 25 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 1 hr to fix

                        Method b_xoopsfaq_category_show has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Method renderAdminListing has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

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

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

                            function b_xoopsfaq_category_show(array $options)
                            {
                                $moduleDirName = \basename(\dirname(__DIR__));
                            
                                $myts = \MyTextSanitizer::getInstance();
                            Severity: Minor
                            Found in blocks/xoopsfaq_category.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 loadTableFromArrayWithReplace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function loadTableFromArrayWithReplace(string $table, array $data, string $search, int $replace): int
                            {
                                /** @var \XoopsMySQLDatabase $db */
                                $db = \XoopsDatabaseFactory::getDatabaseConnection();
                            
                            Severity: Minor
                            Found in testdata/index.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

                            Severity
                            Category
                            Status
                            Source
                            Language