Skip to content

Fix DivisionByZeroError in CodeCloneMap::averageSize() when no clones found - #5

Merged
dimadeush merged 1 commit into
systemsdk:masterfrom
apphp:fix/average-size-division-by-zero
Oct 27, 2026
Merged

dimadeush merged 1 commit into
systemsdk:masterfrom
apphp:fix/average-size-division-by-zero

Conversation

@apphp

@apphp apphp commented Oct 27, 2026

Copy link
Copy Markdown

Fix DivisionByZeroError in CodeCloneMap::averageSize()

averageSize() divided the number of duplicated lines by the clone count without checking for zero. When no clones were found, Log\Json called it from writeHeader() and the run crashed with DivisionByZeroError. The text logger was unaffected because it checks isEmpty() first.

averageSize() now returns 0.0 when there are no clones, so every logger is covered. In the JSON report this gives "averageCloneSize": 0.

@apphp
apphp force-pushed the fix/average-size-division-by-zero branch from 419872f to 21330dc Compare October 27, 2026 20:43
@dimadeush
dimadeush merged commit 262f687 into systemsdk:master Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants