Skip to content

Commit 0155f76

Browse files
committed
Adds Peck analyse step
1 parent 039d7fc commit 0155f76

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

app/Commands/Analyse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public function handle(): int
9393
$packageAnalyser->getStepsForTable()[15],
9494
$packageAnalyser->getStepsForTable()[16],
9595
$packageAnalyser->getStepsForTable()[17],
96+
$packageAnalyser->getStepsForTable()[18],
9697
new TableSeparator,
9798
[new TableCell('Ran <info>'.$amountOfAnalysisSteps.'</info> analysis steps. '.$violationText.$omitText, ['colspan' => 3])],
9899
]);

app/Domain/PackageAnalyser.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function __construct(readonly string $directoryToAnalyse)
4747
['id' => 'cli-phar', 'summary' => 'Distribute CLI/TUI binaries via PHAR.', 'status' => ViolationStatus::Irrelevant],
4848
['id' => 'composer-scripts', 'summary' => 'Utilise Composer scripts.', 'status' => ViolationStatus::False],
4949
['id' => 'eol-php', 'summary' => 'Use a supported PHP version.', 'status' => ViolationStatus::False],
50+
['id' => 'peck', 'summary' => 'Utilise Peck for detecting spelling mistakes.', 'status' => ViolationStatus::False],
5051
];
5152

5253
$this->stepIds = Arr::pluck($this->steps, 'id');
@@ -123,6 +124,9 @@ public function analyse(array $stepsToOmit): int
123124
case 'vcs':
124125
$this->alternateStepStatus('vcs', $this->checkVcsExistence(), $stepsToOmit);
125126
break;
127+
case 'peck':
128+
$this->alternateStepStatus('peck', $this->checkPeckExistence(), $stepsToOmit);
129+
break;
126130
case 'cli-binary':
127131
$this->alternateStepStatus('cli-binary', $this->checkCliBinaryDirectoryExistence(), $stepsToOmit);
128132
break;
@@ -326,6 +330,19 @@ private function checkVcsExistence(): ViolationStatus
326330
return ViolationStatus::False;
327331
}
328332

333+
private function checkPeckExistence(): ViolationStatus
334+
{
335+
$finder = new Finder;
336+
$finder->ignoreDotFiles(false);
337+
$finder->ignoreVCS(false);
338+
339+
if ($finder->depth(0)->path('vendor/bin')->in($this->directoryToAnalyse)->contains('peck')) {
340+
return ViolationStatus::True;
341+
}
342+
343+
return ViolationStatus::False;
344+
}
345+
329346
public function getDirectoryToAnalyse(): string
330347
{
331348
return $this->directoryToAnalyse;

tests/Feature/AnalyseCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
});
1616

1717
it('prints number of analysis steps', function () {
18-
$this->artisan('analyse '.$this->temporaryDirectory)->expectsOutputToContain('Ran 18 analysis steps');
18+
$this->artisan('analyse '.$this->temporaryDirectory)->expectsOutputToContain('Ran 19 analysis steps');
1919
});
2020

2121
it('has success emoji for successful analyse step', function () {

0 commit comments

Comments
 (0)