Skip to content

Commit

Permalink
Simplify results output; all words on one line for quick ctrl-c ctrl-v
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoiq committed Nov 24, 2021
1 parent 88c28e3 commit ff49f80
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
],
"tests:coverage": "php vendor/bin/tester tests -c tests --colors 1 -p phpdbg --coverage tests/coverage.html --coverage-src source",

"phpstan:run": "php vendor/bin/phpstan analyse -c build/phpstan.neon",
"phpstan:run": "php vendor/bin/phpstan analyze -c build/phpstan.neon",
"phpstan:all": [
"php81 vendor/phpstan/phpstan/phpstan analyse -c build/phpstan.neon",
"php80 vendor/phpstan/phpstan/phpstan analyse -c build/phpstan.neon",
"php74 vendor/phpstan/phpstan/phpstan analyse -c build/phpstan.neon",
"php73 vendor/phpstan/phpstan/phpstan analyse -c build/phpstan.neon",
"php72 vendor/phpstan/phpstan/phpstan analyse -c build/phpstan.neon",
"php71 vendor/phpstan/phpstan/phpstan analyse -c build/phpstan.neon"
"php81 vendor/phpstan/phpstan/phpstan analyze -c build/phpstan.neon",
"php80 vendor/phpstan/phpstan/phpstan analyze -c build/phpstan.neon",
"php74 vendor/phpstan/phpstan/phpstan analyze -c build/phpstan.neon",
"php73 vendor/phpstan/phpstan/phpstan analyze -c build/phpstan.neon",
"php72 vendor/phpstan/phpstan/phpstan analyze -c build/phpstan.neon",
"php71 vendor/phpstan/phpstan/phpstan analyze -c build/phpstan.neon"
],

"lint:run": "php vendor/bin/parallel-lint source tests",
Expand Down
28 changes: 20 additions & 8 deletions source/ResultFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use function implode;
use function mb_strlen;
use function mb_substr;
use function sort;
use function sprintf;
use function str_replace;
use function strlen;
Expand Down Expand Up @@ -171,9 +172,15 @@ public function formatErrors(Result $result): string
*/
public function formatFileErrors(string $fileName, array $errors, int $maxWidth): string
{
$output = '' . C::lcyan($this->stripBaseDir($fileName)) . C::gray(' (')
$head = '' . C::lcyan($this->stripBaseDir($fileName)) . C::gray(' (')
. implode(', ', $this->dictionaryResolver->getDictionariesForFileName($fileName)) . C::gray("):\n");

$foot = '';
$words = [];
foreach ($errors as $word) {
if ($word->block !== true) {
$words[] = $word->word;
}
$row = trim($word->row);
$padding = $word->block === true ? 35 : 27;
if ($word->context !== null) {
Expand All @@ -185,18 +192,23 @@ public function formatFileErrors(string $fileName, array $errors, int $maxWidth)
}
$row = str_replace(
[$word->word, "\n", "\t"],
[C::yellow($word->word), C::cyan('\\n'), C::cyan('\\t')],
[C::lred($word->word), C::cyan('\\n'), C::cyan('\\t')],
$row
);

$intro = $word->block === true ? ' - unused ignore "' : ' - found "';
$output .= C::gray($intro) . $word->word . C::gray('"')
. ($word->context !== null ? C::gray(' (') . $word->context . C::gray(')') : '')
. C::gray(' in "') . $row
. C::gray('" at row ') . $word->rowNumber . "\n";
if ($word->block === true) {
$foot .= ' ' . $word->rowNumber . ':' . C::gray(' unused ignore: ') . C::lred($word->word) . "\n";
} else {
$foot .= ' ' . $word->rowNumber . ':'
. ($word->context !== null ? C::gray(' (') . $word->context . C::gray(')') : '')
. C::gray(' "') . $row . C::gray('"') . "\n";
}
}
$words = array_unique($words);
sort($words);
$words = ' ' . C::lred(implode(' ', $words));

return $output;
return $head . $words . "\n" . $foot;
}

public function formatErrorsShort(Result $result): string
Expand Down

0 comments on commit ff49f80

Please sign in to comment.