Skip to content

Commit

Permalink
Raising minimum coverage threshold again
Browse files Browse the repository at this point in the history
Squished some mutants in between: the reason why
mutants were uncovered is that closures were not
being covered at all. Replacing the closures with
PHP 8.1 short closure declarations fixes this,
working around the coverage issue.
  • Loading branch information
Ocramius committed Sep 19, 2022
1 parent 435cfad commit d458075
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 38 deletions.
2 changes: 1 addition & 1 deletion infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"mutators": {
"@default": true
},
"minMsi": 95.4,
"minMsi": 98,
"minCoveredMsi": 100
}
3 changes: 1 addition & 2 deletions src/Changelog/ChangelogReleaseNotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public function merge(self $next): self
{
if ($this->changelogEntry && $next->changelogEntry) {
throw new RuntimeException(
'Aborting: Both current release notes and next contain a ChangelogEntry;'
. ' only one CreateReleaseText implementation should resolve one.',
'Aborting: Both current release notes and next contain a ChangelogEntry; only one CreateReleaseText implementation should resolve one.',
);
}

Expand Down
10 changes: 7 additions & 3 deletions src/Git/Value/MergeTargetCandidateBranches.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public static function fromAllBranches(BranchName ...$branches): self
return $branch->isReleaseBranch();
});

$mergeTargetBranches = Vec\sort($mergeTargetBranches, static function (BranchName $a, BranchName $b): int {
return $a->majorAndMinor() <=> $b->majorAndMinor();
});
$mergeTargetBranches = Vec\sort($mergeTargetBranches, self::branchOrder(...));

return new self($mergeTargetBranches);
}
Expand Down Expand Up @@ -98,4 +96,10 @@ public function contains(BranchName $needle): bool
static fn (BranchName $branch): bool => $needle->equals($branch)
);
}

/** @return -1|0|1 */
private static function branchOrder(BranchName $a, BranchName $b): int
{
return $a->majorAndMinor() <=> $b->majorAndMinor();
}
}
19 changes: 11 additions & 8 deletions src/Github/CreateReleaseTextViaKeepAChangelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,20 @@ private function updateReleaseDate(string $changelog, string $version): string
*/
private function removeDefaultContents(string $changelog): string
{
$contents = Iter\reduce(
return Type\non_empty_string()->assert(Iter\reduce(
self::DEFAULT_SECTIONS,
static fn (string $changelog, string $section): string => Regex\replace(
$changelog,
"/\n\#{3} " . $section . "\n\n- Nothing.\n/s",
'',
),
self::removeEmptyDefaultChangelogSection(...),
$changelog,
);
));
}

return Type\non_empty_string()->assert($contents);
private static function removeEmptyDefaultChangelogSection(string $changelog, string $section): string
{
return Regex\replace(
$changelog,
"/\n\#{3} " . $section . "\n\n- Nothing.\n/s",
'',
);
}

/**
Expand Down
27 changes: 15 additions & 12 deletions src/Monolog/ConvertLogContextHttpRequestsIntoStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ public function __invoke(LogRecord $record): LogRecord
$record->channel,
$record->level,
$record->message,
array_map(static function ($item): mixed {
if (! $item instanceof RequestInterface) {
return $item;
}

return $item->getMethod()
. ' '
. $item
->getUri()
->withUserInfo('')
->__toString();
}, $record->context),
array_map(self::contextItemToMessage(...), $record->context),
$record->extra,
$record->formatted,
);
}

private static function contextItemToMessage(mixed $item): mixed
{
if (! $item instanceof RequestInterface) {
return $item;
}

return $item->getMethod()
. ' '
. $item
->getUri()
->withUserInfo('')
->__toString();
}
}
27 changes: 15 additions & 12 deletions src/Monolog/ConvertLogContextHttpResponsesIntoStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ public function __invoke(LogRecord $record): LogRecord
$record->channel,
$record->level,
$record->message,
array_map(static function ($item): mixed {
if (! $item instanceof ResponseInterface) {
return $item;
}

return $item->getStatusCode()
. ' "'
. $item
->getBody()
->__toString()
. '"';
}, $record->context),
array_map(self::contextItemToMessage(...), $record->context),
$record->extra,
$record->formatted,
);
}

private static function contextItemToMessage(mixed $item): mixed
{
if (! $item instanceof ResponseInterface) {
return $item;
}

return $item->getStatusCode()
. ' "'
. $item
->getBody()
->__toString()
. '"';
}
}

0 comments on commit d458075

Please sign in to comment.