@getcodesentinel/codesentinel 1.23.1 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-report-app/assets/index-3QxuPnP4.css +1 -0
- package/dist/html-report-app/assets/index-BWlhuMc2.js +9 -0
- package/dist/html-report-app/index.html +2 -2
- package/dist/index.js +205 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/html-report-app/assets/index-BJzktu6y.js +0 -9
- package/dist/html-report-app/assets/index-CVTvBtpa.css +0 -1
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap"
|
|
15
15
|
rel="stylesheet"
|
|
16
16
|
/>
|
|
17
|
-
<script type="module" crossorigin src="./assets/index-
|
|
18
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
17
|
+
<script type="module" crossorigin src="./assets/index-BWlhuMc2.js"></script>
|
|
18
|
+
<link rel="stylesheet" crossorigin href="./assets/index-3QxuPnP4.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
|
21
21
|
<div id="root"></div>
|
package/dist/index.js
CHANGED
|
@@ -2035,6 +2035,136 @@ var cycleDetails = (snapshot) => snapshot.analysis.structural.cycles.map((cycle,
|
|
|
2035
2035
|
path: nodes.join(" -> ")
|
|
2036
2036
|
};
|
|
2037
2037
|
});
|
|
2038
|
+
var structuralArchitectureMetrics = (snapshot) => {
|
|
2039
|
+
const metrics = snapshot.analysis.structural.metrics;
|
|
2040
|
+
const nodeCount = metrics.nodeCount;
|
|
2041
|
+
const edgeCount = metrics.edgeCount;
|
|
2042
|
+
const maxPossibleEdges = nodeCount <= 1 ? 0 : nodeCount * (nodeCount - 1);
|
|
2043
|
+
const couplingDensity = maxPossibleEdges === 0 ? 0 : round43(edgeCount / maxPossibleEdges * 100);
|
|
2044
|
+
const entryPointCount = snapshot.analysis.structural.files.filter(
|
|
2045
|
+
(file) => file.fanIn === 0 && file.fanOut > 0
|
|
2046
|
+
).length;
|
|
2047
|
+
return {
|
|
2048
|
+
nodeCount,
|
|
2049
|
+
edgeCount,
|
|
2050
|
+
graphDepth: metrics.graphDepth,
|
|
2051
|
+
maxFanIn: metrics.maxFanIn,
|
|
2052
|
+
maxFanOut: metrics.maxFanOut,
|
|
2053
|
+
couplingDensity,
|
|
2054
|
+
entryPointCount
|
|
2055
|
+
};
|
|
2056
|
+
};
|
|
2057
|
+
var structuralModuleAnatomy = (snapshot) => {
|
|
2058
|
+
const moduleMap = /* @__PURE__ */ new Map();
|
|
2059
|
+
for (const file of snapshot.analysis.structural.files) {
|
|
2060
|
+
const module = toPosixDirname(file.relativePath);
|
|
2061
|
+
const current = moduleMap.get(module) ?? {
|
|
2062
|
+
module,
|
|
2063
|
+
dependencyCount: 0,
|
|
2064
|
+
fanIn: 0,
|
|
2065
|
+
fanOut: 0,
|
|
2066
|
+
depth: 0
|
|
2067
|
+
};
|
|
2068
|
+
current.dependencyCount += file.directDependencies.length;
|
|
2069
|
+
current.fanIn = Math.max(current.fanIn, file.fanIn);
|
|
2070
|
+
current.fanOut = Math.max(current.fanOut, file.fanOut);
|
|
2071
|
+
current.depth = Math.max(current.depth, file.depth);
|
|
2072
|
+
moduleMap.set(module, current);
|
|
2073
|
+
}
|
|
2074
|
+
return [...moduleMap.values()].sort(
|
|
2075
|
+
(a, b) => b.dependencyCount - a.dependencyCount || b.fanIn - a.fanIn || b.depth - a.depth || a.module.localeCompare(b.module)
|
|
2076
|
+
).slice(0, 5);
|
|
2077
|
+
};
|
|
2078
|
+
var average = (values) => values.length === 0 ? null : round43(values.reduce((sum, value) => sum + value, 0) / values.length);
|
|
2079
|
+
var toPercent = (value) => round43(value * 100);
|
|
2080
|
+
var LEGACY_NO_ACTIVE_OWNER_DAYS = 180;
|
|
2081
|
+
var changeOwnershipSummary = (snapshot) => {
|
|
2082
|
+
if (!snapshot.analysis.evolution.available) {
|
|
2083
|
+
return {
|
|
2084
|
+
available: false,
|
|
2085
|
+
reason: snapshot.analysis.evolution.reason
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
const evolution = snapshot.analysis.evolution;
|
|
2089
|
+
const files = evolution.files;
|
|
2090
|
+
const ownershipReadyFiles = files.filter(
|
|
2091
|
+
(file) => file.topAuthorShareByCommits !== null && file.authorDistributionByCommits.length > 0
|
|
2092
|
+
);
|
|
2093
|
+
const sharedOwnershipCount = ownershipReadyFiles.filter(
|
|
2094
|
+
(file) => file.authorDistributionByCommits.length >= 2 && file.topAuthorShareByCommits <= 0.6
|
|
2095
|
+
).length;
|
|
2096
|
+
const concentratedOwnershipCount = ownershipReadyFiles.filter(
|
|
2097
|
+
(file) => file.authorDistributionByCommits.length >= 2 && file.topAuthorShareByCommits > 0.6
|
|
2098
|
+
).length;
|
|
2099
|
+
const singleMaintainerCount = ownershipReadyFiles.filter(
|
|
2100
|
+
(file) => file.authorDistributionByCommits.length <= 1
|
|
2101
|
+
).length;
|
|
2102
|
+
const headCommitTimestamp = evolution.metrics.headCommitTimestamp;
|
|
2103
|
+
const legacyNoActiveOwnerCount = ownershipReadyFiles.filter(
|
|
2104
|
+
(file) => file.commitCount > 0 && file.lastCommitTimestamp !== null && headCommitTimestamp !== null && headCommitTimestamp - file.lastCommitTimestamp >= LEGACY_NO_ACTIVE_OWNER_DAYS * 86400
|
|
2105
|
+
).length;
|
|
2106
|
+
const ownershipDivisor = ownershipReadyFiles.length || 0;
|
|
2107
|
+
const moduleKnowledgeMap = /* @__PURE__ */ new Map();
|
|
2108
|
+
for (const file of files) {
|
|
2109
|
+
const module = toPosixDirname(file.filePath);
|
|
2110
|
+
const current = moduleKnowledgeMap.get(module) ?? {
|
|
2111
|
+
module,
|
|
2112
|
+
totalCommits: 0,
|
|
2113
|
+
recentCommits: 0,
|
|
2114
|
+
authors: /* @__PURE__ */ new Set(),
|
|
2115
|
+
weightedTopAuthorShare: 0,
|
|
2116
|
+
weight: 0
|
|
2117
|
+
};
|
|
2118
|
+
current.totalCommits += file.commitCount;
|
|
2119
|
+
current.recentCommits += file.recentCommitCount;
|
|
2120
|
+
for (const author of file.authorDistributionByCommits) {
|
|
2121
|
+
current.authors.add(author.authorId);
|
|
2122
|
+
}
|
|
2123
|
+
current.weightedTopAuthorShare += file.topAuthorShareByCommits * Math.max(1, file.commitCount);
|
|
2124
|
+
current.weight += Math.max(1, file.commitCount);
|
|
2125
|
+
moduleKnowledgeMap.set(module, current);
|
|
2126
|
+
}
|
|
2127
|
+
const moduleKnowledge = [...moduleKnowledgeMap.values()].map((entry) => {
|
|
2128
|
+
const topAuthorShareByCommits = entry.weight <= 0 ? 0 : round43(entry.weightedTopAuthorShare / entry.weight);
|
|
2129
|
+
const activeAuthors = entry.authors.size;
|
|
2130
|
+
const ownershipLabel = activeAuthors <= 1 || topAuthorShareByCommits >= 0.85 ? "siloed" : activeAuthors <= 2 || topAuthorShareByCommits >= 0.65 ? "sparse" : "distributed";
|
|
2131
|
+
return {
|
|
2132
|
+
module: entry.module,
|
|
2133
|
+
totalCommits: entry.totalCommits,
|
|
2134
|
+
recentCommits: entry.recentCommits,
|
|
2135
|
+
activeAuthors,
|
|
2136
|
+
topAuthorShareByCommits,
|
|
2137
|
+
ownershipLabel
|
|
2138
|
+
};
|
|
2139
|
+
}).sort((a, b) => b.totalCommits - a.totalCommits || a.module.localeCompare(b.module)).slice(0, 8);
|
|
2140
|
+
const coChangePairs = [...evolution.coupling.pairs].sort(
|
|
2141
|
+
(a, b) => b.couplingScore - a.couplingScore || b.coChangeCommits - a.coChangeCommits || a.fileA.localeCompare(b.fileA) || a.fileB.localeCompare(b.fileB)
|
|
2142
|
+
).slice(0, 5).map((pair) => ({
|
|
2143
|
+
fileA: pair.fileA,
|
|
2144
|
+
fileB: pair.fileB,
|
|
2145
|
+
coChangeCommits: pair.coChangeCommits,
|
|
2146
|
+
couplingScore: round43(pair.couplingScore)
|
|
2147
|
+
}));
|
|
2148
|
+
return {
|
|
2149
|
+
available: true,
|
|
2150
|
+
metrics: {
|
|
2151
|
+
totalCommits: evolution.metrics.totalCommits,
|
|
2152
|
+
totalFiles: evolution.metrics.totalFiles,
|
|
2153
|
+
recentWindowDays: evolution.metrics.recentWindowDays,
|
|
2154
|
+
meanBusFactorByCommits: average(
|
|
2155
|
+
files.map((file) => file.busFactorByCommits).filter((value) => value !== null)
|
|
2156
|
+
),
|
|
2157
|
+
averageRecentVolatility: average(files.map((file) => toPercent(file.recentVolatility))),
|
|
2158
|
+
sharedOwnershipPercent: ownershipDivisor === 0 ? null : round43(sharedOwnershipCount / ownershipDivisor * 100),
|
|
2159
|
+
concentratedOwnershipPercent: ownershipDivisor === 0 ? null : round43(concentratedOwnershipCount / ownershipDivisor * 100),
|
|
2160
|
+
singleMaintainerPercent: ownershipDivisor === 0 ? null : round43(singleMaintainerCount / ownershipDivisor * 100),
|
|
2161
|
+
legacyNoActiveOwnerPercent: ownershipDivisor === 0 ? null : round43(legacyNoActiveOwnerCount / ownershipDivisor * 100)
|
|
2162
|
+
},
|
|
2163
|
+
recentActivity: evolution.recentActivity ?? [],
|
|
2164
|
+
coChangePairs,
|
|
2165
|
+
moduleKnowledge
|
|
2166
|
+
};
|
|
2167
|
+
};
|
|
2038
2168
|
var riskyDependencies = (snapshot) => {
|
|
2039
2169
|
if (!snapshot.analysis.external.available) {
|
|
2040
2170
|
return [];
|
|
@@ -2106,6 +2236,8 @@ var createReport = (snapshot, diff) => {
|
|
|
2106
2236
|
(cycle) => [...cycle.nodes].sort((a, b) => a.localeCompare(b)).join(" -> ")
|
|
2107
2237
|
),
|
|
2108
2238
|
cycleDetails: cycleDetails(snapshot),
|
|
2239
|
+
metrics: structuralArchitectureMetrics(snapshot),
|
|
2240
|
+
moduleAnatomy: structuralModuleAnatomy(snapshot),
|
|
2109
2241
|
fanInOutExtremes: {
|
|
2110
2242
|
highestFanIn: topStructuralFiles(snapshot, (file) => file.fanIn),
|
|
2111
2243
|
highestFanOut: topStructuralFiles(snapshot, (file) => file.fanOut),
|
|
@@ -2118,6 +2250,7 @@ var createReport = (snapshot, diff) => {
|
|
|
2118
2250
|
files: [...cluster.files].sort((a, b) => a.localeCompare(b))
|
|
2119
2251
|
}))
|
|
2120
2252
|
},
|
|
2253
|
+
changeOwnership: changeOwnershipSummary(snapshot),
|
|
2121
2254
|
external: !external.available ? {
|
|
2122
2255
|
available: false,
|
|
2123
2256
|
reason: external.reason
|
|
@@ -4624,6 +4757,9 @@ var buildProjectGraphSummary = (input) => {
|
|
|
4624
4757
|
import { execFileSync } from "child_process";
|
|
4625
4758
|
var pairKey = (a, b) => `${a}\0${b}`;
|
|
4626
4759
|
var round44 = (value) => Number(value.toFixed(4));
|
|
4760
|
+
var dayBucketStart = (value) => Math.floor(value / 86400) * 86400;
|
|
4761
|
+
var utcDateStringFromBucket = (value) => new Date(value * 1e3).toISOString().slice(0, 10);
|
|
4762
|
+
var normalizeRatio = (value, max) => max <= 0 ? 0 : Math.max(0, Math.min(1, value / max));
|
|
4627
4763
|
var normalizeName = (value) => value.toLowerCase().replace(/[^a-z0-9\s]/g, " ").replace(/\s+/g, " ").trim();
|
|
4628
4764
|
var extractEmailStem = (authorId) => {
|
|
4629
4765
|
const normalized = authorId.trim().toLowerCase();
|
|
@@ -4836,6 +4972,7 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
|
|
|
4836
4972
|
const authorAliasById = config.authorIdentityMode === "likely_merge" ? buildAuthorAliasMap(commits) : /* @__PURE__ */ new Map();
|
|
4837
4973
|
const fileStats = /* @__PURE__ */ new Map();
|
|
4838
4974
|
const coChangeByPair = /* @__PURE__ */ new Map();
|
|
4975
|
+
const recentActivityByDay = /* @__PURE__ */ new Map();
|
|
4839
4976
|
const headCommitTimestamp = commits.length === 0 ? null : commits[commits.length - 1]?.authoredAtUnix ?? null;
|
|
4840
4977
|
const recentWindowStart = headCommitTimestamp === null ? Number.NEGATIVE_INFINITY : headCommitTimestamp - config.recentWindowDays * 24 * 60 * 60;
|
|
4841
4978
|
let consideredCommits = 0;
|
|
@@ -4847,11 +4984,13 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
|
|
|
4847
4984
|
const current = fileStats.get(fileChange.filePath) ?? {
|
|
4848
4985
|
commitCount: 0,
|
|
4849
4986
|
recentCommitCount: 0,
|
|
4987
|
+
lastCommitTimestamp: null,
|
|
4850
4988
|
churnAdded: 0,
|
|
4851
4989
|
churnDeleted: 0,
|
|
4852
4990
|
authorsByCommits: /* @__PURE__ */ new Map(),
|
|
4853
4991
|
authorsByChurn: /* @__PURE__ */ new Map()
|
|
4854
4992
|
};
|
|
4993
|
+
current.lastCommitTimestamp = current.lastCommitTimestamp === null ? commit.authoredAtUnix : Math.max(current.lastCommitTimestamp, commit.authoredAtUnix);
|
|
4855
4994
|
current.churnAdded += fileChange.additions;
|
|
4856
4995
|
current.churnDeleted += fileChange.deletions;
|
|
4857
4996
|
const effectiveAuthorId = authorAliasById.get(commit.authorId) ?? commit.authorId;
|
|
@@ -4880,6 +5019,25 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
|
|
|
4880
5019
|
);
|
|
4881
5020
|
}
|
|
4882
5021
|
const orderedFiles = [...uniqueFiles].sort((a, b) => a.localeCompare(b));
|
|
5022
|
+
if (commit.authoredAtUnix >= recentWindowStart) {
|
|
5023
|
+
const bucketStartTimestamp = dayBucketStart(commit.authoredAtUnix);
|
|
5024
|
+
const activity = recentActivityByDay.get(bucketStartTimestamp) ?? {
|
|
5025
|
+
commitCount: 0,
|
|
5026
|
+
fileTouchCount: 0,
|
|
5027
|
+
churnTotal: 0,
|
|
5028
|
+
authors: /* @__PURE__ */ new Set()
|
|
5029
|
+
};
|
|
5030
|
+
const effectiveAuthorId = authorAliasById.get(commit.authorId) ?? commit.authorId;
|
|
5031
|
+
const commitChurn = commit.fileChanges.reduce(
|
|
5032
|
+
(sum, fileChange) => sum + fileChange.additions + fileChange.deletions,
|
|
5033
|
+
0
|
|
5034
|
+
);
|
|
5035
|
+
activity.commitCount += 1;
|
|
5036
|
+
activity.fileTouchCount += uniqueFiles.size;
|
|
5037
|
+
activity.churnTotal += commitChurn;
|
|
5038
|
+
activity.authors.add(effectiveAuthorId);
|
|
5039
|
+
recentActivityByDay.set(bucketStartTimestamp, activity);
|
|
5040
|
+
}
|
|
4883
5041
|
if (orderedFiles.length > 1) {
|
|
4884
5042
|
if (orderedFiles.length <= config.maxFilesPerCommitForCoupling) {
|
|
4885
5043
|
consideredCommits += 1;
|
|
@@ -4911,6 +5069,7 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
|
|
|
4911
5069
|
churnAdded: stats.churnAdded,
|
|
4912
5070
|
churnDeleted: stats.churnDeleted,
|
|
4913
5071
|
churnTotal: stats.churnAdded + stats.churnDeleted,
|
|
5072
|
+
lastCommitTimestamp: stats.lastCommitTimestamp,
|
|
4914
5073
|
recentCommitCount: stats.recentCommitCount,
|
|
4915
5074
|
recentVolatility: stats.commitCount === 0 ? 0 : round44(stats.recentCommitCount / stats.commitCount),
|
|
4916
5075
|
topAuthorShareByCommits,
|
|
@@ -4936,12 +5095,42 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
|
|
|
4936
5095
|
config.maxCouplingPairs
|
|
4937
5096
|
);
|
|
4938
5097
|
const { hotspots, threshold } = selectHotspots(files, config);
|
|
5098
|
+
const recentActivityBase = headCommitTimestamp === null ? [] : Array.from({ length: config.recentWindowDays }, (_, index) => {
|
|
5099
|
+
const bucketStartTimestamp = dayBucketStart(headCommitTimestamp) - (config.recentWindowDays - 1 - index) * 86400;
|
|
5100
|
+
const activity = recentActivityByDay.get(bucketStartTimestamp);
|
|
5101
|
+
return {
|
|
5102
|
+
bucketStartUtcDate: utcDateStringFromBucket(bucketStartTimestamp),
|
|
5103
|
+
commitCount: activity?.commitCount ?? 0,
|
|
5104
|
+
fileTouchCount: activity?.fileTouchCount ?? 0,
|
|
5105
|
+
churnTotal: activity?.churnTotal ?? 0,
|
|
5106
|
+
activeAuthorCount: activity?.authors.size ?? 0
|
|
5107
|
+
};
|
|
5108
|
+
});
|
|
5109
|
+
const maxRecentCommitCount = Math.max(1, ...recentActivityBase.map((point) => point.commitCount));
|
|
5110
|
+
const maxRecentFileTouches = Math.max(
|
|
5111
|
+
1,
|
|
5112
|
+
...recentActivityBase.map((point) => point.fileTouchCount)
|
|
5113
|
+
);
|
|
5114
|
+
const maxRecentChurn = Math.max(1, ...recentActivityBase.map((point) => point.churnTotal));
|
|
5115
|
+
const maxRecentChurnLog = Math.log1p(maxRecentChurn);
|
|
5116
|
+
const recentActivity = recentActivityBase.map((point) => {
|
|
5117
|
+
const commitIntensity = normalizeRatio(point.commitCount, maxRecentCommitCount);
|
|
5118
|
+
const fileTouchIntensity = normalizeRatio(point.fileTouchCount, maxRecentFileTouches);
|
|
5119
|
+
const churnIntensity = point.churnTotal <= 0 ? 0 : Math.log1p(point.churnTotal) / maxRecentChurnLog;
|
|
5120
|
+
return {
|
|
5121
|
+
...point,
|
|
5122
|
+
volatilityScore: round44(
|
|
5123
|
+
commitIntensity * 0.35 + fileTouchIntensity * 0.2 + churnIntensity * 0.45
|
|
5124
|
+
)
|
|
5125
|
+
};
|
|
5126
|
+
});
|
|
4939
5127
|
return {
|
|
4940
5128
|
targetPath,
|
|
4941
5129
|
available: true,
|
|
4942
5130
|
files,
|
|
4943
5131
|
hotspots,
|
|
4944
5132
|
coupling,
|
|
5133
|
+
recentActivity,
|
|
4945
5134
|
metrics: {
|
|
4946
5135
|
totalCommits: commits.length,
|
|
4947
5136
|
totalFiles: files.length,
|
|
@@ -5180,7 +5369,7 @@ var clamp01 = (value) => {
|
|
|
5180
5369
|
return value;
|
|
5181
5370
|
};
|
|
5182
5371
|
var round45 = (value) => Number(value.toFixed(4));
|
|
5183
|
-
var
|
|
5372
|
+
var average2 = (values) => {
|
|
5184
5373
|
if (values.length === 0) {
|
|
5185
5374
|
return 0;
|
|
5186
5375
|
}
|
|
@@ -5312,7 +5501,7 @@ var computeRepositoryHealthSummary = (input) => {
|
|
|
5312
5501
|
);
|
|
5313
5502
|
const fanInConcentration = concentration(input.structural.files.map((file) => file.fanIn));
|
|
5314
5503
|
const fanOutConcentration = concentration(input.structural.files.map((file) => file.fanOut));
|
|
5315
|
-
const fanConcentration =
|
|
5504
|
+
const fanConcentration = average2([fanInConcentration, fanOutConcentration]);
|
|
5316
5505
|
const centralityPressure = input.structural.files.map((file) => file.fanIn + file.fanOut);
|
|
5317
5506
|
const centralityConcentration = concentration(centralityPressure);
|
|
5318
5507
|
let structuralHotspotOverlap = 0;
|
|
@@ -5482,7 +5671,7 @@ var computeRepositoryHealthSummary = (input) => {
|
|
|
5482
5671
|
12,
|
|
5483
5672
|
0.3
|
|
5484
5673
|
);
|
|
5485
|
-
const coChangeRaw =
|
|
5674
|
+
const coChangeRaw = average2([
|
|
5486
5675
|
clamp01(denseCoChangePairRatio / 0.2),
|
|
5487
5676
|
couplingScoreConcentration
|
|
5488
5677
|
]);
|
|
@@ -5730,7 +5919,7 @@ var computeRepositoryHealthSummary = (input) => {
|
|
|
5730
5919
|
const modulesDominatedBySingleContributorRatio = trackedModules === 0 ? 0 : clamp01(dominatedModules / trackedModules);
|
|
5731
5920
|
const ownershipSampleSize = trackedFiles;
|
|
5732
5921
|
const ownershipCommitVolume = totalAuthorCommits;
|
|
5733
|
-
const ownershipReliability =
|
|
5922
|
+
const ownershipReliability = average2([
|
|
5734
5923
|
clamp01(ownershipSampleSize / 12),
|
|
5735
5924
|
clamp01(ownershipCommitVolume / 180)
|
|
5736
5925
|
]);
|
|
@@ -6077,7 +6266,7 @@ var DEFAULT_RISK_ENGINE_CONFIG = {
|
|
|
6077
6266
|
};
|
|
6078
6267
|
var toUnitInterval = (value) => Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;
|
|
6079
6268
|
var round46 = (value) => Number(value.toFixed(4));
|
|
6080
|
-
var
|
|
6269
|
+
var average3 = (values) => {
|
|
6081
6270
|
if (values.length === 0) {
|
|
6082
6271
|
return 0;
|
|
6083
6272
|
}
|
|
@@ -6185,7 +6374,7 @@ var computeAggregatorAttenuation = (input) => {
|
|
|
6185
6374
|
const fanOutSignal = toUnitInterval((fanOut - config.minFanOut) / Math.max(1, config.minFanOut));
|
|
6186
6375
|
const lowChurnPerCommitSignal = 1 - toUnitInterval(churnPerCommit / config.maxChurnPerCommit);
|
|
6187
6376
|
const lowChurnPerDependencySignal = 1 - toUnitInterval(churnPerDependency / config.maxChurnPerDependency);
|
|
6188
|
-
const attenuationConfidence =
|
|
6377
|
+
const attenuationConfidence = average3([
|
|
6189
6378
|
fanInSignal,
|
|
6190
6379
|
fanOutSignal,
|
|
6191
6380
|
lowChurnPerCommitSignal,
|
|
@@ -6414,7 +6603,7 @@ var computeDependencyScores = (external, config) => {
|
|
|
6414
6603
|
);
|
|
6415
6604
|
const normalizedValues = dependencyScores.map((score) => score.normalizedScore);
|
|
6416
6605
|
const highDependencyRisk = dependencyScores.length === 0 ? 0 : percentile(normalizedValues, config.externalDimension.topDependencyPercentile);
|
|
6417
|
-
const averageDependencyRisk =
|
|
6606
|
+
const averageDependencyRisk = average3(normalizedValues);
|
|
6418
6607
|
const depthRisk = halfLifeRisk(
|
|
6419
6608
|
external.metrics.dependencyDepth,
|
|
6420
6609
|
config.externalDimension.dependencyDepthHalfLife
|
|
@@ -6485,7 +6674,7 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
|
|
|
6485
6674
|
continue;
|
|
6486
6675
|
}
|
|
6487
6676
|
files.sort((a, b) => a.localeCompare(b));
|
|
6488
|
-
const averageRisk =
|
|
6677
|
+
const averageRisk = average3(
|
|
6489
6678
|
files.map((filePath) => fileScoresByFile.get(filePath)?.normalizedScore ?? 0)
|
|
6490
6679
|
);
|
|
6491
6680
|
const cycleSizeRisk = toUnitInterval((files.length - 1) / 5);
|
|
@@ -6559,10 +6748,10 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
|
|
|
6559
6748
|
const componentPairs = selectedPairs.filter(
|
|
6560
6749
|
(pair) => fileSet.has(pair.fileA) && fileSet.has(pair.fileB)
|
|
6561
6750
|
);
|
|
6562
|
-
const meanFileRisk =
|
|
6751
|
+
const meanFileRisk = average3(
|
|
6563
6752
|
files.map((filePath) => fileScoresByFile.get(filePath)?.normalizedScore ?? 0)
|
|
6564
6753
|
);
|
|
6565
|
-
const meanCoupling =
|
|
6754
|
+
const meanCoupling = average3(componentPairs.map((pair) => pair.couplingScore));
|
|
6566
6755
|
const score = round46(toUnitInterval(meanFileRisk * 0.65 + meanCoupling * 0.35) * 100);
|
|
6567
6756
|
couplingClusterCount += 1;
|
|
6568
6757
|
clusters.push({
|
|
@@ -6838,7 +7027,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
6838
7027
|
moduleFiles.set(moduleName, values);
|
|
6839
7028
|
}
|
|
6840
7029
|
const moduleScores = [...moduleFiles.entries()].map(([module, values]) => {
|
|
6841
|
-
const averageScore =
|
|
7030
|
+
const averageScore = average3(values);
|
|
6842
7031
|
const peakScore = values.reduce((max, value) => Math.max(max, value), 0);
|
|
6843
7032
|
const normalizedScore = toUnitInterval(averageScore * 0.65 + peakScore * 0.35);
|
|
6844
7033
|
return {
|
|
@@ -6850,7 +7039,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
6850
7039
|
}).sort((a, b) => b.score - a.score || a.module.localeCompare(b.module));
|
|
6851
7040
|
if (collector !== void 0) {
|
|
6852
7041
|
for (const [module, values] of moduleFiles.entries()) {
|
|
6853
|
-
const averageScore =
|
|
7042
|
+
const averageScore = average3(values);
|
|
6854
7043
|
const peakScore = values.reduce((max, value) => Math.max(max, value), 0);
|
|
6855
7044
|
const normalizedScore = toUnitInterval(averageScore * 0.65 + peakScore * 0.35);
|
|
6856
7045
|
const totalScore = round46(normalizedScore * 100);
|
|
@@ -7012,16 +7201,16 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
7012
7201
|
);
|
|
7013
7202
|
}
|
|
7014
7203
|
}
|
|
7015
|
-
const structuralDimension =
|
|
7016
|
-
const evolutionDimension =
|
|
7204
|
+
const structuralDimension = average3(fileScores.map((fileScore) => fileScore.factors.structural));
|
|
7205
|
+
const evolutionDimension = average3(fileScores.map((fileScore) => fileScore.factors.evolution));
|
|
7017
7206
|
const externalDimension = dependencyComputation.repositoryExternalPressure;
|
|
7018
7207
|
const topCentralSlice = Math.max(1, Math.ceil(fileRiskContexts.length * 0.1));
|
|
7019
|
-
const criticalInstability =
|
|
7208
|
+
const criticalInstability = average3(
|
|
7020
7209
|
[...fileRiskContexts].sort(
|
|
7021
7210
|
(a, b) => b.structuralCentrality * b.factors.evolution - a.structuralCentrality * a.factors.evolution || a.file.localeCompare(b.file)
|
|
7022
7211
|
).slice(0, topCentralSlice).map((context) => context.structuralCentrality * context.factors.evolution)
|
|
7023
7212
|
);
|
|
7024
|
-
const dependencyAmplification =
|
|
7213
|
+
const dependencyAmplification = average3(
|
|
7025
7214
|
dependencyAmplificationZones.map(
|
|
7026
7215
|
(zone) => toUnitInterval(zone.externalPressure * zone.score / 100)
|
|
7027
7216
|
)
|