Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/ComposerCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class ComposerCollector implements Collector

private string $cwd;

private string $composerJsonPath;

/** @var string[] */
private array $additionalProdPaths = [];

Expand Down Expand Up @@ -74,6 +76,7 @@ private function runComposerDependencyAnalyser(): AnalysisResult
$composerJson = $initializer->initComposerJson(options: $options);
$initializer->initComposerAutoloader(composerJson: $composerJson);
$configuration = $initializer->initConfiguration(options: $options, composerJson: $composerJson);
$this->composerJsonPath = dirname($composerJson->composerVendorDir).'/composer.json';

$configuration->ignoreErrors([ErrorType::UNKNOWN_CLASS, ErrorType::UNKNOWN_FUNCTION]);

Expand Down Expand Up @@ -142,14 +145,14 @@ private function reformatResults(AnalysisResult $results): array
),
array_map(
fn ($error) => RuleErrorBuilder::message("Prod dependency used only in dev paths: {$error}")
->file('composer.json')
->file($this->composerJsonPath)
->tip('This should probably be moved to "require-dev" section in composer.json')
->identifier('composer.prodInDev')
->build(),
$results->getProdDependencyOnlyInDevErrors()),
array_map(
fn ($error) => RuleErrorBuilder::message("Unused dependency detected: {$error}")
->file('composer.json')
->file($this->composerJsonPath)
->tip('This is listed in composer.json, but no usage was found in scanned paths')
->identifier('composer.unused')
->build(),
Expand Down