From e03c5854fd730cd0c131d0fd8001fdc1dc3ca429 Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Fri, 15 Mar 2024 16:54:14 +0100 Subject: [PATCH] Fixes #29 --- src/Rules/ReturnTypeCoverageRule.php | 2 +- src/ValueObject/TypeCountAndMissingTypes.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Rules/ReturnTypeCoverageRule.php b/src/Rules/ReturnTypeCoverageRule.php index bc56f4a..38e67e8 100644 --- a/src/Rules/ReturnTypeCoverageRule.php +++ b/src/Rules/ReturnTypeCoverageRule.php @@ -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, diff --git a/src/ValueObject/TypeCountAndMissingTypes.php b/src/ValueObject/TypeCountAndMissingTypes.php index 8ee3669..08f31e4 100644 --- a/src/ValueObject/TypeCountAndMissingTypes.php +++ b/src/ValueObject/TypeCountAndMissingTypes.php @@ -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