Skip to content

Commit c85338d

Browse files
committed
refactor: move pluralize into its own module
1 parent 3cd025f commit c85338d

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

extensions/ql-vscode/src/history-item-label-provider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { LocalQueryInfo } from './query-results';
55
import { buildRepoLabel, getRawQueryName, QueryHistoryInfo } from './query-history-info';
66
import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-item';
77
import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-history-item';
8-
import { assertNever, pluralize } from './pure/helpers-pure';
8+
import { assertNever } from './pure/helpers-pure';
9+
import { pluralize } from './pure/word';
910

1011
interface InterpolateReplacements {
1112
t: string; // Start time

extensions/ql-vscode/src/pure/helpers-pure.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,3 @@ export function getErrorStack(e: any) {
5555
export function asError(e: any): Error {
5656
return e instanceof Error ? e : new Error(String(e));
5757
}
58-
59-
/**
60-
* Pluralizes a word.
61-
* Example: Returns "N repository" if N is one, "N repositories" otherwise.
62-
*/
63-
export function pluralize(numItems: number | undefined, singular: string, plural: string): string {
64-
return numItems !== undefined ? `${numItems} ${numItems === 1 ? singular : plural}` : '';
65-
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Pluralizes a word.
3+
* Example: Returns "N repository" if N is one, "N repositories" otherwise.
4+
*/
5+
6+
export function pluralize(numItems: number | undefined, singular: string, plural: string): string {
7+
return numItems !== undefined ? `${numItems} ${numItems === 1 ? singular : plural}` : '';
8+
}

extensions/ql-vscode/src/query-history-info.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-item';
22
import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-history-item';
33
import { LocalQueryInfo } from './query-results';
4-
import { assertNever, pluralize } from './pure/helpers-pure';
4+
import { assertNever } from './pure/helpers-pure';
5+
import { pluralize } from './pure/word';
56
import { hasRepoScanCompleted } from './remote-queries/shared/variant-analysis';
67

78
export type QueryHistoryInfo = LocalQueryInfo | RemoteQueryHistoryItem | VariantAnalysisHistoryItem;

extensions/ql-vscode/src/remote-queries/export-results.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { generateMarkdown } from './remote-queries-markdown-generation';
1313
import { RemoteQuery } from './remote-query';
1414
import { AnalysisResults, sumAnalysesResults } from './shared/analysis-result';
1515
import { RemoteQueryHistoryItem } from './remote-query-history-item';
16-
import { pluralize } from '../pure/helpers-pure';
16+
import { pluralize } from '../pure/word';
1717

1818
/**
1919
* Exports the results of the given or currently-selected remote query.

extensions/ql-vscode/src/remote-queries/run-remote-query.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import { OctokitResponse, RequestError } from '@octokit/types/dist-types';
2222
import { RemoteQuery } from './remote-query';
2323
import { RemoteQuerySubmissionResult } from './remote-query-submission-result';
2424
import { QueryMetadata } from '../pure/interface-types';
25-
import { getErrorMessage, REPO_REGEX, pluralize } from '../pure/helpers-pure';
25+
import { getErrorMessage, REPO_REGEX } from '../pure/helpers-pure';
26+
import { pluralize } from '../pure/word';
2627
import * as ghApiClient from './gh-api/gh-api-client';
2728
import { getRepositorySelection, isValidSelection, RepositorySelection } from './repository-selection';
2829
import { parseVariantAnalysisQueryLanguage, VariantAnalysisSubmission } from './shared/variant-analysis';

0 commit comments

Comments
 (0)