Skip to content

Commit 1926b40

Browse files
committed
Add ignore line
1 parent 742a9ce commit 1926b40

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"phpstan/phpstan": "^0.11",
2727
"nette/utils": "2.5.*",
2828
"webmozart/path-util": "^2.3",
29-
"thecodingmachine/safe": "^0.1.9"
29+
"thecodingmachine/safe": "^0.1.9",
30+
"nette/neon": "^3.0.0"
3031
},
3132
"license": "MIT",
3233
"require-dev": {

src/FileOutput.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace noximo;
56

67
use Nette\IOException;
8+
use Nette\Neon\Neon;
79
use Nette\Utils\FileSystem;
810
use Nette\Utils\RegexpException;
911
use Nette\Utils\Strings;
@@ -14,16 +16,24 @@
1416

1517
class FileOutput implements ErrorFormatter
1618
{
19+
/** @var string */
1720
public const ERROR = 'error';
1821

22+
/** @var string */
1923
public const LINK = 'link';
2024

25+
/** @var string */
2126
public const LINE = 'line';
2227

28+
/** @var string */
2329
public const FILES = 'files';
2430

31+
/** @var string */
2532
public const UNKNOWN = 'unknown';
2633

34+
/** @var string */
35+
public const IGNORE = 'ignore';
36+
2737
/** @var string */
2838
private $link = 'editor://open/?file=%file&line=%line';
2939

@@ -51,7 +61,7 @@ public function __construct(string $outputFile, ?ErrorFormatter $defaultFormatte
5161
$this->defaultFormatter = $defaultFormatterClass;
5262
$cwd = \Safe\getcwd() . DIRECTORY_SEPARATOR;
5363
try {
54-
$outputFile = Strings::replace($outputFile, '{time}', (string)time());
64+
$outputFile = Strings::replace($outputFile, '{time}', (string) time());
5565
} catch (RegexpException $e) {
5666
}
5767

@@ -114,9 +124,10 @@ private function generateFile(AnalysisResult $analysisResult): void
114124
$line = $fileSpecificError->getLine() ?? 1;
115125
$link = strtr($this->link, ['%file' => $file, '%line' => $line]);
116126
$output[self::FILES][$file][] = [
117-
self::ERROR => $this->formatMessage($fileSpecificError->getMessage()),
127+
self::ERROR => self::formatMessage($fileSpecificError->getMessage()),
118128
self::LINK => $link,
119129
self::LINE => $line,
130+
self::IGNORE => Neon::encode($fileSpecificError->getMessage()),
120131
];
121132
}
122133

@@ -126,13 +137,12 @@ private function generateFile(AnalysisResult $analysisResult): void
126137
});
127138
}
128139
unset($file);
129-
130140
}
131141

132142
FileSystem::write($this->outputFile, $this->getTable($output));
133143
}
134144

135-
private function formatMessage(string $message): string
145+
private static function formatMessage(string $message): string
136146
{
137147
$words = explode(' ', $message);
138148
$words = array_map(function ($word) {

src/table.phtml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace noximo;
@@ -112,6 +113,10 @@ namespace noximo;
112113
<?= $error[FileOutput::ERROR] ?>
113114
</td>
114115
</tr>
116+
<tr>
117+
<td></td>
118+
<td><?= $error[FileOutput::IGNORE] ?></td>
119+
</tr>
115120
<?php endforeach ?>
116121
<?php endforeach ?>
117122
<?php endif ?>

0 commit comments

Comments
 (0)