33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2025-01-03 22:57:21 +00:00

Apply naming rules to the main manifest file(s?) only (others are checked for URLs, ASCII, length, and menu name only)

This commit is contained in:
Denis Ryabov 2021-05-17 23:42:59 +03:00
parent 907bbd1d75
commit c50e39e357

View File

@ -74,15 +74,22 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
$manifestFound = false;
if (count($files))
{
$topLevelDepth = substr_count($files[0], '/');
// Iterate through all the xml files
foreach ($files as $file)
{
$isTopLevel = substr_count($file, '/') === $topLevelDepth;
// Try to find the license
if ($this->find($file))
if ($this->find($file, $isTopLevel))
{
$manifestFound = true;
}
}
}
if (!$manifestFound)
{
@ -94,10 +101,11 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
* Reads a file and searches for the license
*
* @param string $file - The path to the file
* @param bool $isTopLevel - Is the file located in the top-level manifests directory?
*
* @return boolean True if the manifest file was found, otherwise False.
*/
protected function find($file)
protected function find($file, $isTopLevel)
{
$xml = JFactory::getXml($file);
@ -136,6 +144,8 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
$this->report->addInfo($file, implode('<br />', $info));
if ($isTopLevel)
{
// NM3 - Listing name contains “module” or “plugin”
// (and other reserved words)
if (preg_match('/\b(?:module|plugin|component|template|extension|free)\b/i', $extensionName, $match))
@ -191,6 +201,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
{
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG', $extensionName));
}
}
// Validate URLs
$this->validateDomain($file, (string) $xml->authorUrl);
@ -210,7 +221,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
}
}
if ($type === 'plugin')
if ($isTopLevel && $type === 'plugin')
{
// The name of your plugin must comply with the JED naming conventions - plugins in the form “{Type} - {Extension Name}”.
$parts = explode(' - ', $extensionName, 2);