diff --git a/administrator/components/com_jedchecker/libraries/rules/framework.ini b/administrator/components/com_jedchecker/libraries/rules/framework.ini index 40435d8..fc3db99 100644 --- a/administrator/components/com_jedchecker/libraries/rules/framework.ini +++ b/administrator/components/com_jedchecker/libraries/rules/framework.ini @@ -19,7 +19,8 @@ ; ; 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" 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" diff --git a/administrator/components/com_jedchecker/libraries/rules/framework.php b/administrator/components/com_jedchecker/libraries/rules/framework.php index 6f9edb2..09ca835 100644 --- a/administrator/components/com_jedchecker/libraries/rules/framework.php +++ b/administrator/components/com_jedchecker/libraries/rules/framework.php @@ -45,7 +45,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule protected $tests = false; - protected $leftover_folders; + protected $regex_leftover_folders; /** * Initiates the file search and check @@ -56,7 +56,16 @@ class JedcheckerRulesFramework extends JEDcheckerRule { // Warn about code versioning files included $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) $folders = JFolder::folders($this->basedir, $regex_leftover_folders, true, true, array(), array()); @@ -73,7 +82,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule if ($files !== false) { - // Warn on leftover filess found + // Warn on leftover files found foreach ($files as $file) { $this->report->addWarning($file, JText::_("COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE")); @@ -106,15 +115,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule */ private function excludeResource($file) { - foreach ($this->leftover_folders as $leftover_folder) - { - if (strpos($file, '/' . $leftover_folder . '/') !== false) - { - return true; - } - } - - return false; + return (bool) preg_match('/\/' . $this->regex_leftover_folders . '\//', $file); } /**