33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-12-01 01:03:55 +00:00

Extended list of leftover files/folders

This commit is contained in:
Denis Ryabov 2021-05-09 18:43:33 +03:00
parent 21a4a72356
commit 1b2bdbe41e
2 changed files with 15 additions and 13 deletions

View File

@ -19,7 +19,8 @@
; ;
; ref: docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_3.0_and_Joomla_Platform_12.1 ; ref: docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_3.0_and_Joomla_Platform_12.1
leftover_folders=".DS_Store,.svn,.git,__MACOSX" leftover_folders="__MACOSX,Desktop.ini,desktop.ini,Thumbs.db,node_modules,php-cs-fixer,phpcs,PHP_CodeSniffer,php_codesniffer,.*,*.bak,*.orig,*.php.*,*.test,*.tmp,*~,*.log,*_log,*.lock,*.pid,*.diff,*.patch,*.phar"
leftover_folders_whitelist=".htaccess"
error_groups="directdb" error_groups="directdb"
directdb="mysql_connect,mysql_query,mysql_close,mysql_escape_string,new mysqli,mysqli_connect,mysqli_query,mysqli_close,mysqli_escape_string,mysqli_real_escape_string" directdb="mysql_connect,mysql_query,mysql_close,mysql_escape_string,new mysqli,mysqli_connect,mysqli_query,mysqli_close,mysqli_escape_string,mysqli_real_escape_string"

View File

@ -45,7 +45,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule
protected $tests = false; protected $tests = false;
protected $leftover_folders; protected $regex_leftover_folders;
/** /**
* Initiates the file search and check * Initiates the file search and check
@ -56,7 +56,16 @@ class JedcheckerRulesFramework extends JEDcheckerRule
{ {
// Warn about code versioning files included // Warn about code versioning files included
$leftover_folders = $this->params->get('leftover_folders'); $leftover_folders = $this->params->get('leftover_folders');
$regex_leftover_folders = '(?:' . str_replace(',', '|', preg_quote($leftover_folders, '/')) . ')$'; $leftover_folders_whitelist = $this->params->get('leftover_folders_whitelist');
$this->regex_leftover_folders = '';
if (!empty($leftover_folders_whitelist))
{
$this->regex_leftover_folders .= '(?!(?:' . str_replace(array(',', '\*'), array('|', '.*'), preg_quote($leftover_folders_whitelist, '/')) . '))';
}
$this->regex_leftover_folders .= '(?:' . str_replace(array(',', '\*'), array('|', '.*'), preg_quote($leftover_folders, '/')) . ')';
$regex_leftover_folders = '^' . $this->regex_leftover_folders . '$';
// Get matched files and folder (w/o default exclusion list) // Get matched files and folder (w/o default exclusion list)
$folders = JFolder::folders($this->basedir, $regex_leftover_folders, true, true, array(), array()); $folders = JFolder::folders($this->basedir, $regex_leftover_folders, true, true, array(), array());
@ -73,7 +82,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule
if ($files !== false) if ($files !== false)
{ {
// Warn on leftover filess found // Warn on leftover files found
foreach ($files as $file) foreach ($files as $file)
{ {
$this->report->addWarning($file, JText::_("COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE")); $this->report->addWarning($file, JText::_("COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE"));
@ -106,15 +115,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule
*/ */
private function excludeResource($file) private function excludeResource($file)
{ {
foreach ($this->leftover_folders as $leftover_folder) return (bool) preg_match('/\/' . $this->regex_leftover_folders . '\//', $file);
{
if (strpos($file, '/' . $leftover_folder . '/') !== false)
{
return true;
}
}
return false;
} }
/** /**