All Files / internal/utils / percent.go

100% Statements 4/4
100% Functions 1/1
100% Lines 8/8
package utils

import "math"

func Percent(covered, total int64) float64 {
        if total == 0 {
                total = 1 // Avoid zero denominator.
        }

        percent := 100.0 * float64(covered) / float64(total)

        return math.Round(percent*100) / 100 // Round to two decimal places.
}