MCPcopy Create free account
hub / github.com/code-pushup/cli / getAuditImpactValue

Function getAuditImpactValue

packages/ci/src/lib/issues.ts:152–181  ·  view source on GitHub ↗
(
  { audit, plugin }: IssueContext,
  report: Report,
)

Source from the content-addressed store, hash-verified

150}
151
152export function getAuditImpactValue(
153 { audit, plugin }: IssueContext,
154 report: Report,
155): number {
156 if (!report.categories) {
157 return 0;
158 }
159 return report.categories
160 .map((category): number => {
161 const weights = category.refs.map((ref): number => {
162 if (ref.plugin !== plugin.slug) {
163 return 0;
164 }
165
166 switch (ref.type) {
167 case 'audit':
168 return ref.slug === audit.slug ? ref.weight : 0;
169
170 case 'group':
171 return calculateGroupImpact(ref, audit, report);
172 }
173 });
174
175 return (
176 weights.reduce((acc, weight) => acc + weight, 0) /
177 category.refs.reduce((acc, { weight }) => acc + weight, 0)
178 );
179 })
180 .reduce((acc, value) => acc + value, 0);
181}
182
183export function calculateGroupImpact(
184 ref: CategoryRef,

Callers 2

Calls 1

calculateGroupImpactFunction · 0.85

Tested by

no test coverage detected