Skip to content

Commit 16a8935

Browse files
committed
Properly format ignore string
1 parent 1926b40 commit 16a8935

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/FileOutput.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace noximo;
66

77
use Nette\IOException;
8-
use Nette\Neon\Neon;
98
use Nette\Utils\FileSystem;
109
use Nette\Utils\RegexpException;
1110
use Nette\Utils\Strings;
@@ -61,7 +60,7 @@ public function __construct(string $outputFile, ?ErrorFormatter $defaultFormatte
6160
$this->defaultFormatter = $defaultFormatterClass;
6261
$cwd = \Safe\getcwd() . DIRECTORY_SEPARATOR;
6362
try {
64-
$outputFile = Strings::replace($outputFile, '{time}', (string) time());
63+
$outputFile = Strings::replace($outputFile, '{time}', (string)time());
6564
} catch (RegexpException $e) {
6665
}
6766

@@ -127,7 +126,7 @@ private function generateFile(AnalysisResult $analysisResult): void
127126
self::ERROR => self::formatMessage($fileSpecificError->getMessage()),
128127
self::LINK => $link,
129128
self::LINE => $line,
130-
self::IGNORE => Neon::encode($fileSpecificError->getMessage()),
129+
self::IGNORE => self::formatRegex($fileSpecificError->getMessage()),
131130
];
132131
}
133132

@@ -155,4 +154,23 @@ private static function formatMessage(string $message): string
155154

156155
return implode(' ', $words);
157156
}
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+
}
158176
}

src/table.phtml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ namespace noximo;
6262
background: #374d63
6363
}
6464

65+
.regex {
66+
color: #00000085;
67+
}
68+
6569
#thanks {
6670
margin-top: 50px;
6771
font-size: 0.65em;
@@ -111,12 +115,10 @@ namespace noximo;
111115
</td>
112116
<td>
113117
<?= $error[FileOutput::ERROR] ?>
118+
<br>
119+
<small class="regex"><?= $error[FileOutput::IGNORE] ?></small>
114120
</td>
115121
</tr>
116-
<tr>
117-
<td></td>
118-
<td><?= $error[FileOutput::IGNORE] ?></td>
119-
</tr>
120122
<?php endforeach ?>
121123
<?php endforeach ?>
122124
<?php endif ?>

0 commit comments

Comments
 (0)