Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused code #2318

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions projects/openapi-utilities/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
@@ -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,
9 changes: 0 additions & 9 deletions projects/openapi-utilities/src/legacy-ci-types.ts

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(
@@ -71,9 +21,6 @@ export const getLabel = (
)
.join(', ');

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

export const getOperationsChanged = (
groupedDiffs: GroupedDiffs
): {

This file was deleted.