33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-28 15:56:31 +00:00

unify code lines displaying

This commit is contained in:
Denis Ryabov 2021-04-04 12:07:11 +03:00
parent 118846b53b
commit ab4acc2bba

View File

@ -93,16 +93,14 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
// Report incorrect comment character // Report incorrect comment character
if ($line[0] === '#') if ($line[0] === '#')
{ {
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_INCORRECT_COMMENT') . $this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_INCORRECT_COMMENT'), $lineno, $line);
'<br>' . htmlspecialchars($line), $lineno);
continue; continue;
} }
// Check for "=" character in the line // Check for "=" character in the line
if (strpos($line, '=') === false) if (strpos($line, '=') === false)
{ {
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_WRONG_LINE') . $this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_WRONG_LINE'), $lineno, $line);
'<br>' . htmlspecialchars($line), $lineno);
continue; continue;
} }
@ -114,32 +112,28 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
// Check for empty key // Check for empty key
if ($key === '') if ($key === '')
{ {
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_EMPTY') . $this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_EMPTY'), $lineno, $line);
'<br>' . htmlspecialchars($line), $lineno);
continue; continue;
} }
// Check for spaces in the key name // Check for spaces in the key name
if (strpos($key, ' ') !== false) if (strpos($key, ' ') !== false)
{ {
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_WHITESPACE') . $this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_WHITESPACE'), $lineno, $line);
'<br>' . htmlspecialchars($line), $lineno);
continue; continue;
} }
// Check for invalid characters (see https://www.php.net/manual/en/function.parse-ini-file.php) // Check for invalid characters (see https://www.php.net/manual/en/function.parse-ini-file.php)
if (strpbrk($key, '{}|&~![()^"') !== false) if (strpbrk($key, '{}|&~![()^"') !== false)
{ {
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_INVALID_CHARACTER') . $this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_INVALID_CHARACTER'), $lineno, $line);
'<br>' . htmlspecialchars($line), $lineno);
continue; continue;
} }
// Check for invalid key names (see https://www.php.net/manual/en/function.parse-ini-file.php) // Check for invalid key names (see https://www.php.net/manual/en/function.parse-ini-file.php)
if (in_array($key, array('null', 'yes', 'no', 'true', 'false', 'on', 'off', 'none'), true)) if (in_array($key, array('null', 'yes', 'no', 'true', 'false', 'on', 'off', 'none'), true))
{ {
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_RESERVED') . $this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_RESERVED'), $lineno, $line);
'<br>' . htmlspecialchars($line), $lineno);
continue; continue;
} }
@ -147,16 +141,14 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
if (strlen($value) <2 || $value[0] !== '"' || substr($value, -1) !== '"') if (strlen($value) <2 || $value[0] !== '"' || substr($value, -1) !== '"')
{ {
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_TRANSLATION_QUOTES') . $this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_TRANSLATION_QUOTES'), $lineno, $line);
'<br>' . htmlspecialchars($line), $lineno);
continue; continue;
} }
// Check for empty value // Check for empty value
if ($value === '""') if ($value === '""')
{ {
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_TRANSLATION_EMPTY') . $this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_TRANSLATION_EMPTY'), $lineno, $line);
'<br>' . htmlspecialchars($line), $lineno);
continue; continue;
} }
@ -166,8 +158,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
// Check for legacy "_QQ_" code (deprecated since Joomla! 3.9 if favor of escaped double quote \"; removed in Joomla! 4) // Check for legacy "_QQ_" code (deprecated since Joomla! 3.9 if favor of escaped double quote \"; removed in Joomla! 4)
if (strpos($value, '"_QQ_"') !== false) if (strpos($value, '"_QQ_"') !== false)
{ {
$this->report->addInfo($file, JText::_('COM_JEDCHECKER_LANG_QQ_DEPRECATED') . $this->report->addInfo($file, JText::_('COM_JEDCHECKER_LANG_QQ_DEPRECATED'), $lineno, $line);
'<br>' . htmlspecialchars($line), $lineno);
} }
} }