Skip to content

Commit

Permalink
Fix error message accuracy (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-granados authored Mar 15, 2024
1 parent a2f456d commit 86f3e7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Rules/ReturnTypeCoverageRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* @var string
*/
public const ERROR_MESSAGE = 'Out of %d possible return types, only %d - %.1f %% actually have it. Add more return types to get over %d %%';
public const ERROR_MESSAGE = 'Out of %d possible return types, only %d - %.1f %% actually have it. Add more return types to get over %s %%';

public function __construct(
private TypeCoverageFormatter $typeCoverageFormatter,
Expand Down
5 changes: 4 additions & 1 deletion src/ValueObject/TypeCountAndMissingTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public function getMissingTypeLinesByFilePath(): array

public function getCoveragePercentage(): float
{
return 100 * ($this->getTypedCount() / $this->totalCount);
$relative = 100 * ($this->getTypedCount() / $this->totalCount);

// round down with one decimal, to make error message clear that required value is not reached yet
return floor($relative * 10) / 10;
}

private function getTypedCount(): int
Expand Down

0 comments on commit 86f3e7c

Please sign in to comment.