Global variable or function should never be used 22

More information: https://insight.symfony.com/what-we-analyse/php.use_global_variable_or_function

in blocks/blocks.php, line 25
  1. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
  2. /**
  3. * @return mixed
  4. */
  5. function about_block_menu_show()

    about_block_menu_show() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  6. {
  7. $moduleDirName = basename(dirname(__DIR__));
  8. xoops_load('constants', $moduleDirName);
  9. $abtHelper = Xmf\Module\Helper::getHelper($moduleDirName);
in blocks/blocks.php, line 56
  1. /**
  2. * @param $options
  3. * @return array|bool
  4. */
  5. function about_block_page_show($options)

    about_block_page_show() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  6. {
  7. if (empty($options[0])) {
  8. return false;
  9. }
  10. $moduleDirName = basename(dirname(__DIR__));
in blocks/blocks.php, line 90
  1. /**
  2. * @param $options
  3. * @return string
  4. */
  5. function about_block_page_edit($options)

    about_block_page_edit() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  6. {
  7. $moduleDirName = basename(dirname(__DIR__));
  8. $abtHelper = Xmf\Module\Helper::getHelper($moduleDirName);
  9. xoops_load('constants', $moduleDirName);
  1. *
  2. * @param XoopsModule $module
  3. *
  4. * @return bool true if ready to install, false if not
  5. */
  6. function xoops_module_pre_install_about(XoopsModule $module)

    xoops_module_pre_install_about() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by zyspec
  7. {
  8. $utilsClass = ucfirst($module->dirname()) . 'Utility';
  9. if (!class_exists($utilsClass)) {
  10. xoops_load('utility', $module->dirname());
  11. }
  1. /**
  2. * @param XoopsModule $module
  3. * @return bool true if install successful, false if not
  4. */
  5. function xoops_module_install_about(XoopsModule $module)

    xoops_module_install_about() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by zyspec
  6. {
  7. $success = true;
  8. $data_file = XOOPS_ROOT_PATH . '/modules/about/sql/mysql.about.sql';
  9. $GLOBALS['xoopsDB']->queryF('SET NAMES utf8');
  10. if (!$GLOBALS['xoopsDB']->queryFromFile($data_file)) {
  1. *
  2. * @param XoopsModule $module
  3. *
  4. * @return bool true if ready to install, false if not
  5. */
  6. function xoops_module_pre_update_about(XoopsModule $module)

    xoops_module_pre_update_about() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by zyspec
  7. {
  8. $utilsClass = ucfirst($module->dirname()) . 'Utility';
  9. if (!class_exists($utilsClass)) {
  10. xoops_load('utility', $module->dirname());
  11. }
  1. /**
  2. * @param XoopsModule $module
  3. * @param null $prev_version
  4. * @return bool true if update successful, false if not
  5. */
  6. function xoops_module_update_about(XoopsModule $module, $prev_version = null)

    xoops_module_update_about() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  7. {
  8. $success = true;
  9. // Delete files from previous version (if they exist)
  10. $oldFiles = array(XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/include/xoopsformloader.php',
  11. XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/include/blockform.php',
  1. *
  2. * @param XoopsModule $module
  3. *
  4. * @return bool true if successfully executed uninstall of module, false if not
  5. */
  6. function xoops_module_uninstall_about(XoopsModule $module)

    xoops_module_uninstall_about() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by zyspec
  7. {
  8. $moduleDirName = $module->dirname();
  9. $aboutHelper = Xmf\Module\Helper::getHelper($moduleDirName);
  10. $utilsClass = ucfirst($moduleDirName) . 'Utility';
  11. if (!class_exists($utilsClass)) {
in include/functions.php, line 11
  1. * @param $dir
  2. * @param int $mode
  3. * @param bool $recursive
  4. * @return bool
  5. */
  6. function aboutmkdirs($dir, $mode = 0777, $recursive = true)

    aboutmkdirs() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  7. {
  8. if ('' === $dir || null === $dir) {
  9. return $dir;
  10. }
  11. if ('/' === $dir || is_dir($dir)) {
  1. * @var string $page page name
  2. * @var string $style template style
  3. *
  4. * @return string template file name, using default style if style is invalid
  5. */
  6. function about_getTemplate($page = 'index', $style = null)

    about_getTemplate() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  7. {
  8. global $xoops;
  9. $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
  10. $style = empty($style) ? '' : '_' . $style;
  1. *
  2. * @return string template file name, using default style if style is invalid
  3. */
  4. function about_getTemplate($page = 'index', $style = null)
  5. {
  6. global $xoops;

    $xoops adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  7. $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
  8. $style = empty($style) ? '' : '_' . $style;
  9. $file_name = "{$GLOBALS['artdirname']}_{$page}{$style}.tpl";
  10. if (file_exists($template_dir . $file_name)) {
  1. * @var string $page page name
  2. * @param bool|boolean $refresh recreate the data
  3. * @return array
  4. *
  5. */
  6. function &about_getTemplateList($page = 'index', $refresh = false)

    about_getTemplateList() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  7. {
  8. $TplFiles = about_getTplPageList($page, $refresh);
  9. $template = array();
  10. if (is_array($TplFiles) && count($TplFiles) > 0) {
  11. foreach (array_keys($TplFiles) as $temp) {
  1. *
  2. * @var string $style
  3. *
  4. * @return string file URL, false if not found
  5. */
  6. function about_getCss($style = 'default')

    about_getCss() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  7. {
  8. global $xoops;
  9. if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . strtolower($style) . '.css'))) {
  10. return $xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . strtolower($style) . '.css', true);
  1. *
  2. * @return string file URL, false if not found
  3. */
  4. function about_getCss($style = 'default')
  5. {
  6. global $xoops;

    $xoops adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  7. if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . strtolower($style) . '.css'))) {
  8. return $xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . strtolower($style) . '.css', true);
  9. }
  1. *
  2. * @var string $style
  3. *
  4. * @return string
  5. */
  6. function about_getModuleHeader($style = 'default')

    about_getModuleHeader() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  7. {
  8. $xoops_module_header = '<link rel="stylesheet" type="text/css" href="' . about_getCss($style) . '">';
  9. return $xoops_module_header;
  10. }
  1. * @var string $page page name
  2. *
  3. * @param bool $refresh
  4. * @return array
  5. */
  6. function &about_getTplPageList($page = '', $refresh = true)

    about_getTplPageList() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  7. {
  8. $list = null;
  9. $cache_file = empty($page) ? 'template-list' : 'template-page';
  10. /*
  1. /**
  2. * @param bool $index_by_page
  3. * @return array
  4. */
  5. function &about_template_lookup($index_by_page = false)

    about_template_lookup() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  6. {
  7. require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
  8. $files = XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
  9. $list = array();
in admin/admin.page.php, line 133
  1. if (!$pageHandler->getCount()) {
  2. $page_obj->setVar('page_index', AboutConstants::DEFAULT_INDEX);
  3. }
  4. // Set submitter
  5. global $xoopsUser;

    $xoopsUser adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by zyspec
  6. $page_obj->setVar('page_author', $xoopsUser->getVar('uid'));
  7. $page_obj->setVar('page_pushtime', time());
  8. /* removed - this is now done during module install/update
  9. require_once $abtHelper->path("include/functions.php");
in include/vars.php, line 21
  1. * @since 1.0.0
  2. * @author Mengjue Shao <magic.shao@gmail.com>
  3. * @author Susheng Yang <ezskyyoung@gmail.com>
  4. */
  5. $GLOBALS['artdirname'] = basename(dirname(__DIR__));

    $artdirname adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  6. // include customized variables
  7. if (is_object($GLOBALS['xoopsModule']) && $GLOBALS['artdirname'] == $GLOBALS['xoopsModule']->getVar('dirname', 'n')) {
  8. }
in xoops_version.php, line 61
  1. $modversion['onUninstall'] = 'include/action.module.php';
  2. // Menu
  3. $modversion['system_menu'] = 1;
  4. $modversion['hasMain'] = 1;
  5. global $xoopsModuleConfig, $xoopsUser, $xoopsModule;

    $xoopsModule adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  6. //sql
  7. $modversion['sqlfile']['mysql'] = 'sql/mysql.sql';
  8. $modversion['tables'] = array(
  9. 'about_page'
in xoops_version.php, line 61
  1. $modversion['onUninstall'] = 'include/action.module.php';
  2. // Menu
  3. $modversion['system_menu'] = 1;
  4. $modversion['hasMain'] = 1;
  5. global $xoopsModuleConfig, $xoopsUser, $xoopsModule;

    $xoopsUser adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  6. //sql
  7. $modversion['sqlfile']['mysql'] = 'sql/mysql.sql';
  8. $modversion['tables'] = array(
  9. 'about_page'
in xoops_version.php, line 61
  1. $modversion['onUninstall'] = 'include/action.module.php';
  2. // Menu
  3. $modversion['system_menu'] = 1;
  4. $modversion['hasMain'] = 1;
  5. global $xoopsModuleConfig, $xoopsUser, $xoopsModule;

    $xoopsModuleConfig adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by mambax7
  6. //sql
  7. $modversion['sqlfile']['mysql'] = 'sql/mysql.sql';
  8. $modversion['tables'] = array(
  9. 'about_page'

exit() and die() functions should be avoided 10

More information: https://insight.symfony.com/what-we-analyse/php.use_exit_function

in admin/menu.php, line 24
  1. * @since 1.0.0
  2. * @author Mengjue Shao <magic.shao@gmail.com>
  3. * @author Susheng Yang <ezskyyoung@gmail.com>
  4. */
  5. defined('XOOPS_ROOT_PATH') || exit('Restricted access');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by zyspec
  6. $adminmenu = array(array('title' => _MI_ABOUT_HOME,
  7. 'link' => 'admin/index.php',
  8. 'icon' => Xmf\Module\Admin::menuIconPath('home.png')
  9. ),
in blocks/blocks.php, line 21
  1. * @since 1.0.0
  2. * @author Mengjue Shao <magic.shao@gmail.com>
  3. * @author Susheng Yang <ezskyyoung@gmail.com>
  4. */
  5. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by mambax7
  6. /**
  7. * @return mixed
  8. */
  9. function about_block_menu_show()
  10. {
in class/blockform.php, line 20
  1. * @package about
  2. * @since 1.0.0
  3. * @author Susheng Yang <ezskyyoung@gmail.com>
  4. */
  5. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by mambax7
  6. include_once XOOPS_ROOT_PATH . '/class/xoopsform/form.php';
  7. /**
  8. * Class AboutBlockForm
in class/constants.php, line 42
  1. * @author:: zyspec <owners@zyspec.com>
  2. * @package:: about
  3. * @since:: 1.05
  4. **/
  5. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by mambax7
  6. /**
  7. * Interface AboutConstants
  8. */
  9. interface AboutConstants
in class/page.php, line 21
  1. * @since 1.0.0
  2. * @author Mengjue Shao <magic.shao@gmail.com>
  3. * @author Susheng Yang <ezskyyoung@gmail.com>
  4. */
  5. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by mambax7
  6. /**
  7. * Class AboutPage
  8. */
  9. class AboutPage extends XoopsObject
in class/tree.php, line 3
  1. <?php
  2. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by mambax7
  3. require_once XOOPS_ROOT_PATH . '/class/tree.php';
  4. if (!class_exists('AboutTree')) {
  5. /**
  1. <?php
  2. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by mambax7
  3. /**
  4. *
  5. * Prepares system prior to attempting to install module
  6. *
in include/form.page.php, line 21
  1. * @since 1.0.0
  2. * @author Mengjue Shao <magic.shao@gmail.com>
  3. * @author Susheng Yang <ezskyyoung@gmail.com>
  4. */
  5. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by zyspec
  6. $moduleDirName = basename(dirname(__DIR__));
  7. $abtHelper = Xmf\Module\Helper::getHelper($moduleDirName);
  8. include_once __DIR__ . '/functions.render.php';
  1. <?php
  2. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by mambax7
  3. /**
  4. * @param $dir
  5. * @param int $mode
  6. * @param bool $recursive
  1. * @package article
  2. * @since 1.0
  3. * @author Taiwen Jiang <phppp@users.sourceforge.net>
  4. */
  5. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by mambax7
  6. include __DIR__ . '/vars.php';
  7. define($GLOBALS['artdirname'] . '_FUNCTIONS_RENDER_LOADED', true);
  8. /**

Source code should not contain TODO comments 4

More information: https://insight.symfony.com/what-we-analyse/task_todo_comment

in class/utility.php, line 160
  1. /**
  2. *
  3. * Recursively remove directory
  4. *
  5. * @todo currently won't remove directories with hidden files, should it?

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by zyspec
  6. *
  7. * @param string $src directory to remove (delete)
  8. *
  9. * @return bool true on success
  10. */
  1. * http://www.opensource.org/licenses/mit-license.php
  2. */
  3. ;(function($) {
  4. // TODO rewrite as a widget, removing all the extra plugins

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by zyspec
  5. $.extend($.fn, {
  6. swapClass: function(c1, c2) {
  7. var c1Elements = this.filter('.' + c1);
  8. this.filter('.' + c2).removeClass(c2).addClass(c1);
  9. c1Elements.removeClass(c1).addClass(c2);
  1. }
  2. // return all items with sublists
  3. return this.filter(":has(>ul)");
  4. },
  5. applyClasses: function(settings, toggler) {
  6. // TODO use event delegation

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by zyspec
  7. this.filter(":has(>ul):not(:has(>a))").find(">span").unbind("click.treeview").bind("click.treeview", function(event) {
  8. // don't handle click events on children, eg. checkboxes
  9. if ( this == event.target )
  10. toggler.apply($(this).next());
  11. }).add( $("a", this) ).hoverClass();
  1. case "location":
  2. var current = this.find("a").filter(function() {
  3. return location.href.toLowerCase().indexOf(this.href.toLowerCase()) == 0;
  4. });
  5. if ( current.length ) {
  6. // TODO update the open/closed classes

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by zyspec
  7. var items = current.addClass("selected").parents("ul, li").add( current.next() ).show();
  8. if (settings.prerendered) {
  9. // if prerendered is on, replicate the basic class swapping
  10. items.filter("li")
  11. .swapClass( CLASSES.collapsable, CLASSES.expandable )

Error silenced by the at sign (@)

More information: https://insight.symfony.com/what-we-analyse/php.silenced_error

  1. if (!is_array($list) || $refresh) {
  2. $list = about_template_lookup(!empty($page));
  3. }
  4. $ret = empty($page) ? $list : @$list[$page];

    Adding "@" before $list[$page] prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by mambax7
  5. return $ret;
  6. }
  7. /**

User specific files should not appear in .gitignore

More information: https://insight.symfony.com/what-we-analyse/git.user_specific_ignored_file

in .gitignore, line 5
  1. # no backup files, editor temp
  2. *~
  3. \#*
  4. *.bak
  5. .idea/

    .idea/ is user-specific and should not appear in a project .gitignore. Consider adding it to the user global .gitignore instead.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by mambax7

Commented code should not be committed 15

More information: https://insight.symfony.com/what-we-analyse/php.commented_out_code

in blocks/blocks.php, line 110
  1. $page_title = '';
  2. foreach ($pages as $k => $v) {
  3. $page_title = '<a href="' . $abtHelper->url("index.php?page_id={$k}") . '" target="_blank">' . $v['page_title'] . '</a>';
  4. $options_page[$k] = empty($v['page_image']) ? $page_title : $page_title . '<img src="' . $abtHelper->url('assets/images/picture.png') . '">';
  5. }
  6. // include_once dirname(__DIR__) . '/include/xoopsformloader.php';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by zyspec
  7. xoops_load('blockform', $moduleDirName);
  8. $form = new AboutBlockForm();
  9. $page_select = new XoopsFormRadio(_MB_ABOUT_BLOCKPAGE, 'options[0]', $options[0], '<br>');
  10. $page_select->addOptionArray($options_page);
  11. $form->addElement($page_select);
in class/page.php, line 46
  1. $this->initVar('page_blank', XOBJ_DTYPE_INT, 0);
  2. $this->initVar('page_menu_status', XOBJ_DTYPE_INT, 0);
  3. $this->initVar('page_type', XOBJ_DTYPE_INT, 0);
  4. $this->initVar('page_status', XOBJ_DTYPE_INT, 0);
  5. $this->initVar('page_order', XOBJ_DTYPE_INT, 0);
  6. //$this->initVar('page_url', XOBJ_DTYPE_TXTBOX,"");

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by mambax7
  7. $this->initVar('page_index', XOBJ_DTYPE_INT, 0);
  8. $this->initVar('page_tpl', XOBJ_DTYPE_TXTBOX, '');
  9. $this->initVar('dohtml', XOBJ_DTYPE_INT, 1);
  10. $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0);
  11. $this->initVar('doxcode', XOBJ_DTYPE_INT, 0);
  1. $data_file = XOOPS_ROOT_PATH . '/modules/about/sql/mysql.about.sql';
  2. $GLOBALS['xoopsDB']->queryF('SET NAMES utf8');
  3. if (!$GLOBALS['xoopsDB']->queryFromFile($data_file)) {
  4. $module->setErrors('Pre-set data was not installed');
  5. // preset info not set, but don't 'fail' install because of this
  6. //$success = false;

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by zyspec
  7. }
  8. // Delete files from previous version (if they exist)
  9. // this is only executed if this version copied over old version without running module update
  10. $oldFiles = array(XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/include/xoopsformloader.php',
in include/form.page.php, line 27
  1. $moduleDirName = basename(dirname(__DIR__));
  2. $abtHelper = Xmf\Module\Helper::getHelper($moduleDirName);
  3. include_once __DIR__ . '/functions.render.php';
  4. //include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by zyspec
  5. $pageHandler = $abtHelper->getHandler('page');
  6. $pageType = isset($_REQUEST['type']) ? Xmf\Request::getInt('type', 0) : $page_obj->getVar('page_type');
  7. $format = empty($format) ? 'e' : $format;
in include/form.page.php, line 115
  1. $form->addElement(new XoopsFormRadioYN(_AM_ABOUT_PAGE_STATUS, 'page_status', $list_status, $yes = _AM_ABOUT_PAGE_SUB, $no = _AM_ABOUT_PAGE_DRAFT));
  2. $form->addElement(new XoopsFormHidden('id', $page_obj->getVar('page_id')));
  3. $form->addElement(new XoopsFormHidden('page_type', $pageType));
  4. $form->addElement(new XoopsFormHidden('op', 'save'));
  5. //$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by zyspec
  6. $form->addElement(new XoopsFormButtonTray('submit', _SUBMIT, 'submit'));
  7. return $form;
  1. function &about_getTplPageList($page = '', $refresh = true)
  2. {
  3. $list = null;
  4. $cache_file = empty($page) ? 'template-list' : 'template-page';
  5. /*

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by mambax7
  6. load_functions("cache");
  7. $list = mod_loadCacheFile($cache_file, $GLOBALS["artdirname"]);
  8. */
  9. xoops_load('xoopscache');
  1. $cache_file = empty($index_by_page) ? 'template-list' : 'template-page';
  2. xoops_load('xoopscache');
  3. $key = $GLOBALS['artdirname'] . "_{$cache_file}";
  4. XoopsCache::write($key, $list);
  5. //load_functions("cache");

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by mambax7
  6. //mod_createCacheFile($list, $cache_file, $GLOBALS["artdirname"]);
  7. return $list;
  8. }
  1. xoops_load('xoopscache');
  2. $key = $GLOBALS['artdirname'] . "_{$cache_file}";
  3. XoopsCache::write($key, $list);
  4. //load_functions("cache");
  5. //mod_createCacheFile($list, $cache_file, $GLOBALS["artdirname"]);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by mambax7
  6. return $list;
  7. }
in admin/admin.page.php, line 38
  1. switch ($op) {
  2. default:
  3. case 'list':
  4. // Page order
  5. if (isset($_POST['page_order'])) {
  6. $page_order = Xmf\Request::getArray('page_order', array(), 'POST'); //$_POST['page_order'];

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by zyspec
  7. foreach ($page_order as $page_id => $order) {
  8. $page_obj = $pageHandler->get($page_id);
  9. if ($page_order[$page_id] != $page_obj->getVar('page_order')) {
  10. $page_obj->setVar('page_order', $page_order[$page_id]);
  11. $pageHandler->insert($page_obj);
in xoops_version.php, line 31
  1. $modversion['credits'] = 'xoops.org.cn';
  2. $modversion['help'] = 'page=help';
  3. $modversion['license'] = 'GNU GPL 2.0 or later';
  4. $modversion['license_url'] = 'www.gnu.org/licenses/gpl-2.0.html';
  5. //$moduleDirName = basename(__DIR__);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by mambax7
  6. $modversion['dirname'] = basename(__DIR__);
  7. //$modversion['dirmoduleadmin'] = 'Frameworks/moduleclasses/moduleadmin';
  8. //$modversion['sysicons16'] = 'Frameworks/moduleclasses/icons/16';
  9. //$modversion['sysicons32'] = 'Frameworks/moduleclasses/icons/32';
in xoops_version.php, line 34
  1. $modversion['license_url'] = 'www.gnu.org/licenses/gpl-2.0.html';
  2. //$moduleDirName = basename(__DIR__);
  3. $modversion['dirname'] = basename(__DIR__);
  4. //$modversion['dirmoduleadmin'] = 'Frameworks/moduleclasses/moduleadmin';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by mambax7
  5. //$modversion['sysicons16'] = 'Frameworks/moduleclasses/icons/16';
  6. //$modversion['sysicons32'] = 'Frameworks/moduleclasses/icons/32';
  7. $modversion['modicons16'] = 'assets/images/icons/16';
  8. $modversion['modicons32'] = 'assets/images/icons/32';
  9. $modversion['module_website_url'] = 'www.xoops.org';
in xoops_version.php, line 35
  1. //$moduleDirName = basename(__DIR__);
  2. $modversion['dirname'] = basename(__DIR__);
  3. //$modversion['dirmoduleadmin'] = 'Frameworks/moduleclasses/moduleadmin';
  4. //$modversion['sysicons16'] = 'Frameworks/moduleclasses/icons/16';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by mambax7
  5. //$modversion['sysicons32'] = 'Frameworks/moduleclasses/icons/32';
  6. $modversion['modicons16'] = 'assets/images/icons/16';
  7. $modversion['modicons32'] = 'assets/images/icons/32';
  8. $modversion['module_website_url'] = 'www.xoops.org';
  9. $modversion['module_website_name'] = 'XOOPS';
in xoops_version.php, line 36
  1. //$moduleDirName = basename(__DIR__);
  2. $modversion['dirname'] = basename(__DIR__);
  3. //$modversion['dirmoduleadmin'] = 'Frameworks/moduleclasses/moduleadmin';
  4. //$modversion['sysicons16'] = 'Frameworks/moduleclasses/icons/16';
  5. //$modversion['sysicons32'] = 'Frameworks/moduleclasses/icons/32';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by mambax7
  6. $modversion['modicons16'] = 'assets/images/icons/16';
  7. $modversion['modicons32'] = 'assets/images/icons/32';
  8. $modversion['module_website_url'] = 'www.xoops.org';
  9. $modversion['module_website_name'] = 'XOOPS';
  10. $modversion['min_php'] = '5.5';
in index.php, line 25
  1. require_once __DIR__ . '/header.php';
  2. require_once __DIR__ . '/include/functions.render.php';
  3. $page_id = Xmf\Request::getInt('page_id', 0);
  4. //$page_id = isset($_REQUEST['page_id']) ? $_REQUEST['page_id'] : '';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by zyspec
  5. $pageHandler = $abtHelper->getHandler('page');
  6. $myts = MyTextSanitizer::getInstance();
  7. // Menu
in index.php, line 52
  1. $page_text = trim($v['page_text']);
  2. $menu[$k]['page_text'] = false;
  3. if (preg_match('/https?\:\/\//', $page_text)) {
  4. $menu[$k]['page_text'] = true;
  5. }
  6. // $menu[$k]['page_text'] = trim($v['page_text']) === 'http://' ? true : false;

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by zyspec
  7. }
  8. $page_menu = $pageHandler->menuTree($menu);
  9. // Display
  10. if (AboutConstants::PAGE == $abtHelper->getConfig('display', AboutConstants::PAGE) || !empty($page_id)) {

Unused method, property, variable or parameter 2

More information: https://insight.symfony.com/what-we-analyse/php.unused_local_variable_or_private_member

Updated rule! We've recently tweaked this rule. This may explain the disappearance of false positives, or new suggestions not linked to any activity in the code.
  1. /**
  2. * @param XoopsModule $module
  3. * @param null $prev_version
  4. * @return bool true if update successful, false if not
  5. */
  6. function xoops_module_update_about(XoopsModule $module, $prev_version = null)

    This prev_version argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by mambax7
  7. {
  8. $success = true;
  9. // Delete files from previous version (if they exist)
  10. $oldFiles = array(XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/include/xoopsformloader.php',
  11. XOOPS_ROOT_PATH . '/modules/' . $module->dirname() . '/include/blockform.php',
in class/utility.php, line 178
  1. // If source is not a directory stop processing
  2. if (!is_dir($src)) {
  3. return false;
  4. }
  5. $success = true;

    This success local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by zyspec
  6. // Open the source directory to read in files
  7. $iterator = new DirectoryIterator($src);
  8. foreach ($iterator as $fObj) {
  9. if ($fObj->isFile()) {

Interfaces names should end with "Interface"

More information: https://insight.symfony.com/what-we-analyse/php.interface_has_no_interface_suffix

in class/constants.php, line 47
  1. defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
  2. /**
  3. * Interface AboutConstants
  4. */
  5. interface AboutConstants

    Interface AboutConstants should be named AboutConstantsInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by zyspec
  6. {
  7. /**#@+
  8. * Constant definition
  9. */
  10. /**

Class should be unique per PHP file

More information: https://insight.symfony.com/what-we-analyse/php.file_contains_more_than_one_class

This file contains 2 classes. Keeping only one class per file is a standard in the PHP community, since it promotes interoperability and maintainability.

Time to fix: about 4 hours
Open Issue Permalink
Collective
  • AboutPage (defined at line 26)
  • AboutPageHandler (defined at line 60)