MCPcopy Create free account
hub / github.com/Permify/permify / calculateTotalCoverage

Function calculateTotalCoverage

pkg/development/coverage/coverage.go:302–328  ·  view source on GitHub ↗

calculateTotalCoverage calculates average coverage percentages across all entities

(entities []EntityCoverageInfo)

Source from the content-addressed store, hash-verified

300
301// calculateTotalCoverage calculates average coverage percentages across all entities
302func calculateTotalCoverage(entities []EntityCoverageInfo) (int, int, int) {
303 var (
304 totalRelationships int
305 totalCoveredRelationships int
306 totalAttributes int
307 totalCoveredAttributes int
308 totalAssertions int
309 totalCoveredAssertions int
310 )
311
312 for _, entity := range entities {
313 totalRelationships++
314 totalCoveredRelationships += entity.CoverageRelationshipsPercent
315
316 totalAttributes++
317 totalCoveredAttributes += entity.CoverageAttributesPercent
318
319 for _, assertionPercent := range entity.CoverageAssertionsPercent {
320 totalAssertions++
321 totalCoveredAssertions += assertionPercent
322 }
323 }
324
325 return calculateAverageCoverage(totalRelationships, totalCoveredRelationships),
326 calculateAverageCoverage(totalAttributes, totalCoveredAttributes),
327 calculateAverageCoverage(totalAssertions, totalCoveredAssertions)
328}
329
330// calculateAverageCoverage calculates average coverage with zero-division guard
331func calculateAverageCoverage(total, covered int) int {

Callers 1

buildSchemaCoverageInfoFunction · 0.85

Calls 1

calculateAverageCoverageFunction · 0.85

Tested by

no test coverage detected