|
5 | 5 | namespace noximo;
|
6 | 6 |
|
7 | 7 | use Nette\IOException;
|
8 |
| -use Nette\Neon\Neon; |
9 | 8 | use Nette\Utils\FileSystem;
|
10 | 9 | use Nette\Utils\RegexpException;
|
11 | 10 | use Nette\Utils\Strings;
|
@@ -61,7 +60,7 @@ public function __construct(string $outputFile, ?ErrorFormatter $defaultFormatte
|
61 | 60 | $this->defaultFormatter = $defaultFormatterClass;
|
62 | 61 | $cwd = \Safe\getcwd() . DIRECTORY_SEPARATOR;
|
63 | 62 | try {
|
64 |
| - $outputFile = Strings::replace($outputFile, '{time}', (string) time()); |
| 63 | + $outputFile = Strings::replace($outputFile, '{time}', (string)time()); |
65 | 64 | } catch (RegexpException $e) {
|
66 | 65 | }
|
67 | 66 |
|
@@ -127,7 +126,7 @@ private function generateFile(AnalysisResult $analysisResult): void
|
127 | 126 | self::ERROR => self::formatMessage($fileSpecificError->getMessage()),
|
128 | 127 | self::LINK => $link,
|
129 | 128 | self::LINE => $line,
|
130 |
| - self::IGNORE => Neon::encode($fileSpecificError->getMessage()), |
| 129 | + self::IGNORE => self::formatRegex($fileSpecificError->getMessage()), |
131 | 130 | ];
|
132 | 131 | }
|
133 | 132 |
|
@@ -155,4 +154,23 @@ private static function formatMessage(string $message): string
|
155 | 154 |
|
156 | 155 | return implode(' ', $words);
|
157 | 156 | }
|
| 157 | + |
| 158 | + /** |
| 159 | + * @param string $message |
| 160 | + * @return string |
| 161 | + * @throws RegexpException |
| 162 | + */ |
| 163 | + private static function formatRegex(string $message): string |
| 164 | + { |
| 165 | + $quotes = "'"; |
| 166 | + $message = rtrim($message, '.'); |
| 167 | + $message = preg_quote($message, '#'); |
| 168 | + |
| 169 | + if (Strings::contains($message, "'")) { |
| 170 | + $quotes = '"'; |
| 171 | + $message = Strings::replace($message, '/\\\\/', '\\\\\\'); |
| 172 | + } |
| 173 | + |
| 174 | + return "- $quotes#" . $message . "#$quotes"; |
| 175 | + } |
158 | 176 | }
|
0 commit comments