31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-09 16:42:22 +00:00

fix displaying unmodified file content in error message(s)

This commit is contained in:
Denis Ryabov 2022-08-03 16:33:39 +03:00
parent a33ff617d8
commit 989bde3625
3 changed files with 6 additions and 3 deletions

View File

@ -105,6 +105,7 @@ class JedcheckerRulesEncoding extends JEDcheckerRule
protected function find($file)
{
$content = file_get_contents($file);
$origContent = JEDCheckerHelper::splitLines($content);
// Exclude comments
$content = JEDCheckerHelper::cleanPhpCode(
@ -120,7 +121,7 @@ class JedcheckerRulesEncoding extends JEDcheckerRule
if (preg_match($this->encodingsRegex, $line))
{
$found = true;
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_ERROR_ENCODING'), $i + 1, $line);
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_ERROR_ENCODING'), $i + 1, $origContent[$i]);
}
}

View File

@ -106,6 +106,7 @@ class JedcheckerRulesErrorreporting extends JEDcheckerRule
protected function find($file)
{
$content = file_get_contents($file);
$origContent = JEDCheckerHelper::splitLines($content);
// Exclude non-code content
$content = JEDCheckerHelper::cleanPhpCode(
@ -121,7 +122,7 @@ class JedcheckerRulesErrorreporting extends JEDcheckerRule
if (preg_match($this->errorreportingRegex, $line))
{
$found = true;
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_ERROR_ERRORREPORTING'), $i + 1, $line);
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_ERROR_ERRORREPORTING'), $i + 1, $origContent[$i]);
}
}

View File

@ -340,6 +340,7 @@ class JedcheckerRulesJamss extends JEDcheckerRule
}
else
{
$origContent = JEDCheckerHelper::splitLines($content);
$scopes = array(
'full' => $content,
'clean' => JEDCheckerHelper::cleanPhpCode($content, JEDCheckerHelper::CLEAN_COMMENTS),
@ -403,8 +404,8 @@ class JedcheckerRulesJamss extends JEDcheckerRule
$end = strlen($scoped_content);
}
$first_code = substr($scoped_content, $start, min($end - $start, 200));
$first_line = $this->calculate_line_number($offset, $scoped_content);
$first_code = $origContent[$first_line - 1];
break;
}