mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 22:11:12 +00:00
refactor(javascript): tally export shape changes in one pass (#15924)
This commit is contained in:
1 parent
b25f05e886
commit
01d98ffe14
1 file changed
+11
-17
@@ -48,7 +48,7 @@ export const compareJavaScriptExportShapes = (
|
||||
input.left.evidenceId,
|
||||
input.right.evidenceId,
|
||||
);
|
||||
const allChanges = sortChanges(
|
||||
const changes = sortChanges(
|
||||
buildJavaScriptExportShapeChanges({
|
||||
leftSelection: left,
|
||||
rightSelection: right,
|
||||
@@ -58,7 +58,7 @@ export const compareJavaScriptExportShapes = (
|
||||
evidenceLinks,
|
||||
}),
|
||||
);
|
||||
const changes = allChanges;
|
||||
const summary = summarize(changes);
|
||||
const omittedChanges = 0;
|
||||
const propertyInventories = buildJavaScriptExportShapeInventories({
|
||||
pairing,
|
||||
@@ -72,7 +72,7 @@ export const compareJavaScriptExportShapes = (
|
||||
leftRetained,
|
||||
rightRetained,
|
||||
pairing,
|
||||
allChanges,
|
||||
summary,
|
||||
omittedChanges,
|
||||
});
|
||||
const limitations = comparisonLimitations(left, right, coverage.status);
|
||||
@@ -80,7 +80,7 @@ export const compareJavaScriptExportShapes = (
|
||||
left: left.selection,
|
||||
right: right.selection,
|
||||
property_inventories: propertyInventories,
|
||||
summary: summarize(allChanges),
|
||||
summary,
|
||||
changes,
|
||||
coverage,
|
||||
evidence_links: evidenceLinks,
|
||||
@@ -125,7 +125,7 @@ interface CoverageInput {
|
||||
readonly leftRetained: RetainedJavaScriptExportShapes;
|
||||
readonly rightRetained: RetainedJavaScriptExportShapes;
|
||||
readonly pairing: JavaScriptExportShapePairing;
|
||||
readonly allChanges: readonly JavaScriptExportShapeComparisonChange[];
|
||||
readonly summary: JavaScriptExportShapeComparisonResult["summary"];
|
||||
readonly omittedChanges: number;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ const comparisonPartial = (context: CoverageInput): boolean =>
|
||||
hasPartialJavaScriptExportPropertyCoverage(context.rightRetained.shapes) ||
|
||||
context.pairing.unpairedLeft.length > 0 ||
|
||||
context.pairing.unpairedRight.length > 0 ||
|
||||
context.allChanges.some(({ status }) => status === "unknown");
|
||||
context.summary.unknown > 0;
|
||||
|
||||
const selectionPartial = (selection: SelectedJavaScriptExport): boolean => {
|
||||
const source = sourceCoverage(selection);
|
||||
@@ -300,17 +300,11 @@ const comparisonLimitations = (
|
||||
|
||||
const summarize = (
|
||||
changes: readonly JavaScriptExportShapeComparisonChange[],
|
||||
): JavaScriptExportShapeComparisonResult["summary"] => ({
|
||||
added: countStatus(changes, "added"),
|
||||
removed: countStatus(changes, "removed"),
|
||||
changed: countStatus(changes, "changed"),
|
||||
unknown: countStatus(changes, "unknown"),
|
||||
});
|
||||
|
||||
const countStatus = (
|
||||
changes: readonly JavaScriptExportShapeComparisonChange[],
|
||||
status: JavaScriptExportShapeComparisonChange["status"],
|
||||
): number => changes.filter((change) => change.status === status).length;
|
||||
): JavaScriptExportShapeComparisonResult["summary"] => {
|
||||
const summary = { added: 0, removed: 0, changed: 0, unknown: 0 };
|
||||
for (const { status } of changes) summary[status] += 1;
|
||||
return summary;
|
||||
};
|
||||
|
||||
const evidencePair = (left: string, right: string): [string, string] => [
|
||||
left,
|
||||
|
||||
Reference in new issue
Block a user