From 21330dc612b062a2a14a1662b936a71912742240 Mon Sep 17 00:00:00 2001 From: Samuel Akopyan Date: Tue, 27 Oct 2026 22:38:17 +0200 Subject: [PATCH] Fix DivisionByZeroError in CodeCloneMap::averageSize() when no clones found --- src/CodeCloneMap.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/CodeCloneMap.php b/src/CodeCloneMap.php index 54516f4..69057cf 100644 --- a/src/CodeCloneMap.php +++ b/src/CodeCloneMap.php @@ -124,7 +124,13 @@ public function isEmpty(): bool public function averageSize(): float { - return $this->numberOfDuplicatedLines() / $this->count(); + $count = $this->count(); + + if ($count === 0) { + return 0.0; + } + + return $this->numberOfDuplicatedLines() / $count; } public function largestSize(): int