Skip to content

Commit

Permalink
Uses --test instead of --pretend
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Jun 16, 2022
1 parent 1e640ac commit ac21528
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 57 deletions.
6 changes: 3 additions & 3 deletions app/Commands/DefaultCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DefaultCommand extends Command
*
* @var string
*/
protected $description = 'Fixes the coding style of the given project';
protected $description = 'Fixes the project\'s coding style';

/**
* Creates a new command instance.
Expand Down Expand Up @@ -67,7 +67,7 @@ protected function configure()
new InputArgument('path', InputArgument::OPTIONAL, 'The project\'s path.', (string) getcwd()),
new InputOption('preset', '', InputOption::VALUE_REQUIRED, 'The preset that should be used', 'psr12'),
new InputOption('risky', '', InputOption::VALUE_NONE, 'If risky fixers are allowed to be used.'),
new InputOption('pretend', '', InputOption::VALUE_NONE, 'Display the fixable issues instead of actually fix them.'),
new InputOption('test', '', InputOption::VALUE_NONE, 'If the project\'s coding style should be tested instead.'),
]
);
}
Expand Down Expand Up @@ -141,7 +141,7 @@ public function handle()
*/
private function exit($changed)
{
$failure = count($changed) > 0
$failure = ($this->option('test') && count($changed) > 0)
|| count($this->errorsManager->getInvalidErrors()) > 0
|| count($this->errorsManager->getExceptionErrors()) > 0
|| count($this->errorsManager->getLintErrors()) > 0;
Expand Down
2 changes: 1 addition & 1 deletion app/Factories/ConfigurationResolverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function fromIO($input, $output)
sprintf('%s.php', $preset),
]),
'diff' => true,
'dry-run' => $input->getOption('pretend'),
'dry-run' => $input->getOption('test'),
'path-mode' => ConfigurationResolver::PATH_MODE_OVERRIDE,
'cache-file' => implode(DIRECTORY_SEPARATOR, [
realpath(sys_get_temp_dir()),
Expand Down
2 changes: 1 addition & 1 deletion app/Output/Concerns/InteractsWithSymbols.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getSymbol($status)
$statusSymbol = $this->statuses[$status];

if (! isset($statusSymbol['symbol'])) {
$statusSymbol = $this->input->getOption('pretend')
$statusSymbol = $this->input->getOption('test')
? $statusSymbol[0]
: $statusSymbol[1];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Output/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function handle($errorsManager, $reportSummary, $path, $total)
view('footer', [
'total' => $total,
'issues' => $this->getIssues($path, $errorsManager, $reportSummary),
'pretending' => $reportSummary->isDryRun(),
'testing' => $reportSummary->isDryRun(),
'isVerbose' => $this->output->isVerbose(),
'preset' => $this->presets[(string) $this->input->getOption('preset')],
]),
Expand Down
4 changes: 2 additions & 2 deletions app/ValueObjects/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public function symbol()
/**
* Returns the issue's description.
*
* @param bool $pretending
* @param bool $testing
* @return string
*/
public function description($pretending)
public function description($testing)
{
if (! empty($this->payload['source'])) {
return $this->payload['source']->getMessage();
Expand Down
Binary file modified builds/pint
Binary file not shown.
85 changes: 37 additions & 48 deletions resources/views/footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,50 @@

<div>
<span>
@if($issues->isNotEmpty() > 0)
<div class="flex space-x-1">
<span class="px-2 bg-red text-white uppercase font-bold">
FAIL
</span>
<span class="flex-1 content-repeat-[.] text-gray"></span>
<span>
<span>
{{ $total }} {{ str('file')->plural($total) }}
</span>
<div class="flex space-x-1">

@php
$nonFixableErrors = $issues->filter->isError();
@endphp

@if ($nonFixableErrors->isNotEmpty())
<span>
, {{ $nonFixableErrors->count() }} {{ str('error')->plural($nonFixableErrors) }}
</span>
@endif
@php
$fixableErrors = $issues->reject->isError();
$nonFixableErrors = $issues->filter->isError();
@endphp

@php
$fixableErrors = $issues->reject->isError();
@endphp

@if ($fixableErrors->isNotEmpty())
<span>
@if ($pretending)
, {{ $fixableErrors->count() }} style {{ str('issue')->plural($fixableErrors) }}
@else
, {{ $fixableErrors->count() }} style {{ str('issues')->plural($fixableErrors) }} fixed
@endif
</span>
@endif
@if($issues->count() == 0)
<span class="px-2 bg-green text-gray uppercase font-bold">
PASS
</span>
@elseif($nonFixableErrors->count() == 0 && ! $testing)
<span class="px-2 bg-green text-gray uppercase font-bold">
FIXED
</span>
@else
<span class="px-2 bg-red text-white uppercase font-bold">
FAIL
</span>
@endif

<span class="flex-1 content-repeat-[.] text-gray"></span>
<span>
<span>
{{ $total }} {{ str('file')->plural($total) }}
</span>
</div>
@else
<div class="flex space-x-1">
<span class="px-2 bg-green text-gray uppercase font-bold">
PASS

@if ($nonFixableErrors->isNotEmpty())
<span>
, {{ $nonFixableErrors->count() }} {{ str('error')->plural($nonFixableErrors) }}
</span>
<span class="flex-1 content-repeat-[.] text-gray"></span>
@endif

@if ($fixableErrors->isNotEmpty())
<span>
<span>
{{ $total }} {{ str('file')->plural($total) }}
</span>
<span>
@if ($issues->isNotEmpty())
, {{ $issues->isNotEmpty() }} {{ str('file')->plural($total) }} fixed
@if ($testing)
, {{ $fixableErrors->count() }} style {{ str('issue')->plural($fixableErrors) }}
@else
, {{ $fixableErrors->count() }} style {{ str('issue')->plural($fixableErrors) }} fixed
@endif
</span>
</span>
</div>
@endif
@endif
</span>
</div>
</span>
</div>

Expand All @@ -80,7 +69,7 @@
</span>
</span>
<span class="flex-1 truncate text-gray text-right">
{{ $issue->description($pretending) }}
{{ $issue->description($testing) }}
</span>
</div>
@endforeach
Expand Down
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function run($command, $arguments)
$output = new BufferedOutput();

$statusCode = resolve(Kernel::class)->call($command, array_merge([
'--pretend' => true,
'--test' => true,
], $arguments), $output);

return [$statusCode, $output];
Expand Down

0 comments on commit ac21528

Please sign in to comment.