Skip to content

Commit

Permalink
remove unused code (#2318)
Browse files Browse the repository at this point in the history
  • Loading branch information
niclim authored Sep 21, 2023
1 parent f77533d commit 21b2265
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 193 deletions.
4 changes: 0 additions & 4 deletions projects/openapi-utilities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
} from './openapi3/implementations/openapi3/sourcemap-reader';

export { defaultEmptySpec } from './openapi3/constants';
export * from './legacy-ci-types';
export * from './openapi3/implementations/openapi3/types';

export { SPEC_TAG_REGEXP, sanitizeGitTag } from './specs/tags';
Expand All @@ -75,11 +74,8 @@ export {
groupChangesAndRules,
} from './utilities/group-changes';
export { traverseSpec } from './utilities/traverse-spec';
export { generateChangelogData } from './utilities/generate-changelog-data';
export { compareChangesByPath } from './utilities/compare-changes-by-path';
export {
getOperationsModifsLabel,
countOperationsModifications,
getLabel,
getOperationsChanged,
getOperationsChangedLabel,
Expand Down
9 changes: 0 additions & 9 deletions projects/openapi-utilities/src/legacy-ci-types.ts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,62 +1,12 @@
import { getEndpointDiffs, typeofV3Diffs } from '../openapi3/group-diff';
import { isChangeVariant } from '../openapi3/sdk/isType';
import { OpenApiKind, IChange, ChangeType } from '../openapi3/sdk/types';
import { ChangeType } from '../openapi3/sdk/types';
import { GroupedDiffs } from '../openapi3/group-diff';

const getChangeOperationId = (change: IChange) => {
const path = (change.location.conceptualLocation as any).path;
const method = (change.location.conceptualLocation as any).method;
if (!path || !method) return null;
return `${path}.${method}`;
};

export const countOperationsModifications = (changes: IChange[]) => {
const operationsChanges = changes.filter((c) =>
isChangeVariant(c, OpenApiKind.Operation)
);

const operationsAdded = operationsChanges.filter(
(c) => c.changeType === ChangeType.Added
);
const operationsRemoved = operationsChanges.filter(
(c) => c.changeType === ChangeType.Removed
);
const operationsChanged = operationsChanges.filter(
(c) => c.changeType === ChangeType.Changed
);

const operationsByChange = {
[ChangeType.Added]: new Set(
operationsAdded.map(getChangeOperationId).filter((id) => !!id)
),
[ChangeType.Changed]: new Set(
operationsChanged.map(getChangeOperationId).filter((id) => !!id)
),
[ChangeType.Removed]: new Set(
operationsRemoved.map(getChangeOperationId).filter((id) => !!id)
),
};

const operationWasAddedOrRemoved = (operationId: string) =>
operationsByChange.added.has(operationId) ||
operationsByChange.removed.has(operationId);

for (const change of changes) {
const operationId = getChangeOperationId(change);
if (!operationId || operationWasAddedOrRemoved(operationId)) continue;
operationsByChange.changed.add(operationId);
}

return {
[ChangeType.Added]: operationsByChange[ChangeType.Added].size,
[ChangeType.Changed]: operationsByChange[ChangeType.Changed].size,
[ChangeType.Removed]: operationsByChange[ChangeType.Removed].size,
};
};

export const getLabel = (
operationsModifsCount: ReturnType<typeof countOperationsModifications>
) =>
export const getLabel = (operationsModifsCount: {
[ChangeType.Added]: number;
[ChangeType.Changed]: number;
[ChangeType.Removed]: number;
}) =>
Object.keys(operationsModifsCount)
.filter((k) => (operationsModifsCount as any)[k])
.map(
Expand All @@ -71,9 +21,6 @@ export const getLabel = (
)
.join(', ');

export const getOperationsModifsLabel = (changes: IChange[]) =>
getLabel(countOperationsModifications(changes));

export const getOperationsChanged = (
groupedDiffs: GroupedDiffs
): {
Expand Down

This file was deleted.

0 comments on commit 21b2265

Please sign in to comment.