XoopsModules25x/xfguestbook

View on GitHub

Showing 1,027 of 1,027 total issues

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

    public static function deleteDirectory($src)
    {
        // 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

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

function flagUpload($country_code)
{
    global $xoopsModule, $maxsize, $maxwidth, $maxheight, $format;
    /** @var Helper $helper */
    $helper = Helper::getInstance();
Severity: Minor
Found in admin/country_manager.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 countryShow has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function countryShow()
{
    global $action, $start, $xoopsModule, $pathIcon16;
    /** @var Helper $helper */
    $helper = Helper::getInstance();
Severity: Major
Found in admin/country_manager.php - About 2 hrs to fix

    Method xoops_module_update_xfguestbook has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function xoops_module_update_xfguestbook(\XoopsModule $module, $previousVersion = null)
    {
        global $xoopsDB;
        $moduleDirName      = basename(dirname(__DIR__));
        $moduleDirNameUpper = mb_strtoupper($moduleDirName);
    Severity: Major
    Found in include/onupdate.php - About 2 hrs to fix

      Function b_xfguestbook_show has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function b_xfguestbook_show($options)
      {
          global $xoopsModule, $xoopsModuleConfig, $xoopsDB;
          /** @var Helper $helper */
          $helper = Helper::getInstance();
      Severity: Minor
      Found in blocks/xfguestbook_new.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

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

      function xfgb_getCountry($criteria = null, $limit = 0, $start = 0)
      {
          global $xoopsDB, $action;
          $ret = [];
      
      
      Severity: Major
      Found in admin/country_manager.php and 1 other location - About 1 hr to fix
      class/Utility.php on lines 55..70

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

      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 getCountry($criteria = null, $limit = 0, $start = 0)
          {
              global $xoopsDB, $action;
              $ret = [];
              $sql = 'SELECT * FROM ' . $xoopsDB->prefix('xfguestbook_country');
      Severity: Major
      Found in class/Utility.php and 1 other location - About 1 hr to fix
      admin/country_manager.php on lines 212..228

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

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

          public static function upload()
          {
              global $xoopsModule, $preview_name, $msgstop;
              /** @var Helper $helper */
              $helper = Helper::getInstance();
      Severity: Minor
      Found in class/Utility.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 b_xfguestbook_show has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function b_xfguestbook_show($options)
      {
          global $xoopsModule, $xoopsModuleConfig, $xoopsDB;
          /** @var Helper $helper */
          $helper = Helper::getInstance();
      Severity: Minor
      Found in blocks/xfguestbook_new.php - About 1 hr to fix

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

        function xfguestbook_admin_menu($currentoption = 0, $breadcrumb = '')
        {
            /* Nice buttons styles */
            echo "
                <style type='text/css'>
        Severity: Minor
        Found in include/cp_functions.php - About 1 hr to fix

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

              public static function checkVerModule($helper, $source = 'github', $default = 'master')
              {
                  $moduleDirName      = \basename(dirname(__DIR__, 2));
                  $moduleDirNameUpper = mb_strtoupper($moduleDirName);
                  $update             = '';
          Severity: Minor
          Found in class/Common/VersionChecks.php - About 1 hr to fix

            Avoid excessively long variable names like $array_allowed_mimetypes. Keep variable name length under 20.
            Open

                $array_allowed_mimetypes = ['image/' . $format];
            Severity: Minor
            Found in admin/country_manager.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $array_allowed_mimetypes. Keep variable name length under 20.
            Open

                            $array_allowed_mimetypes = ['image/gif', 'image/pjpeg', 'image/jpeg', 'image/x-png'];
            Severity: Minor
            Found in class/Utility.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

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

            function loadTableFromArrayWithReplace($table, $data, $search, $replace)
            {
                /** @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

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

            function banish()
            {
                global $msgHandler, $xoopsDB;
                $msg_count = (!empty($_POST['msg_id']) && is_array($_POST['msg_id'])) ? count($_POST['msg_id']) : 0;
                if ($msg_count > 0) {
            Severity: Minor
            Found in admin/main.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 badIpShow has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function badIpShow()
            {
                global $action, $start, $xoopsModule, $xoopsModuleConfig;
                $myts      = \MyTextSanitizer::getInstance();
                $limit     = 15;
            Severity: Minor
            Found in admin/ip_manager.php - About 1 hr to fix

              Method executeSQL has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function executeSQL($sql_file_path)
              {
                  global $xoopsModule;
                  $error = false;
                  // $reservedTables = array('avatar', 'avatar_users_link', 'block_module_link', 'xoopscomments', 'config', 'configcategory', 'configoption', 'image', 'imagebody', 'imagecategory', 'imgset', 'imgset_tplset_link', 'imgsetimg', 'groups','groups_users_link','group_permission', 'online', 'bannerclient', 'banner', 'bannerfinish', 'ranks', 'session', 'smiles', 'users', 'newblocks', 'modules', 'tplfile', 'tplset', 'tplsource', 'xoopsnotifications', 'banner', 'bannerclient', 'bannerfinish');
              Severity: Minor
              Found in include/cp_functions.php - About 1 hr to fix

                Method xoops_module_install_xfguestbook has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function xoops_module_install_xfguestbook(\XoopsModule $module)
                {
                    require_once dirname(__DIR__) . '/preloads/autoloader.php';
                
                    $moduleDirName = basename(dirname(__DIR__));
                Severity: Minor
                Found in include/oninstall.php - About 1 hr to fix

                  Function delete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function delete()
                  {
                      global $msgHandler, $xoopsModule;
                      $msg_count = (!empty($_POST['msg_id']) && is_array($_POST['msg_id'])) ? count($_POST['msg_id']) : 0;
                      if ($msg_count > 0) {
                  Severity: Minor
                  Found in admin/main.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 rrmdir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function rrmdir($src)
                      {
                          // 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 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