Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shepherd: send a list of issues (instead of array with int keys) #9845

Merged
merged 3 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/Psalm/Plugin/EventHandler/Event/AfterAnalysisEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class AfterAnalysisEvent
{
private Codebase $codebase;
/**
* @var IssueData[][]
* @var array<string, list<IssueData>> where string key is a filepath
*/
private array $issues;
private array $build_info;
Expand All @@ -19,7 +19,7 @@ final class AfterAnalysisEvent
/**
* Called after analysis is complete
*
* @param array<string, list<IssueData>> $issues
* @param array<string, list<IssueData>> $issues where string key is a filepath
* @internal
*/
public function __construct(
Expand All @@ -40,7 +40,7 @@ public function getCodebase(): Codebase
}

/**
* @return IssueData[][]
* @return array<string, list<IssueData>> where string key is a filepath
*/
public function getIssues(): array
{
Expand Down
8 changes: 4 additions & 4 deletions src/Psalm/Plugin/Shepherd.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ private static function collectPayloadToSend(AfterAnalysisEvent $event): ?array
return null;
}

$issues = $event->getIssues();
$normalized_data = $issues === [] ? [] : array_filter(
array_merge(...array_values($issues)),
$issues_grouped_by_filename = $event->getIssues();
$normalized_data = $issues_grouped_by_filename === [] ? [] : array_values(array_filter(
array_merge(...array_values($issues_grouped_by_filename)), // flatten an array
static fn(IssueData $i): bool => $i->severity === IssueData::SEVERITY_ERROR,
);
));

$codebase = $event->getCodebase();

Expand Down