Skip to content

Commit 824f56d

Browse files
committed
use find and remove unneccessary checks
1 parent 28abd40 commit 824f56d

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

extensions/ql-vscode/src/databases/config/db-config-store.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ export class DbConfigStore extends DisposableObject {
114114

115115
const config: DbConfig = cloneDbConfig(this.config);
116116
if (parentList) {
117-
config.databases.remote.repositoryLists.forEach((list) => {
118-
if (list.name === parentList) {
119-
list.repositories.push(repoNwo);
120-
}
121-
});
117+
const parent = config.databases.remote.repositoryLists.find(
118+
(list) => list.name === parentList,
119+
);
120+
if (!parent) {
121+
throw Error(`Cannot find parent list '${parentList}'`);
122+
} else {
123+
parent.repositories.push(repoNwo);
124+
}
122125
} else {
123126
config.databases.remote.repositories.push(repoNwo);
124127
}

extensions/ql-vscode/src/databases/db-manager.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ export class DbManager {
7979
nwo: string,
8080
parentList?: string,
8181
): Promise<void> {
82-
if (nwo === "") {
83-
throw new Error("Repository name cannot be empty");
84-
}
85-
if (this.dbConfigStore.doesRemoteDbExist(nwo)) {
86-
throw new Error(`The repository '${nwo}' already exists`);
87-
}
88-
8982
await this.dbConfigStore.addRemoteRepo(nwo, parentList);
9083
}
9184

0 commit comments

Comments
 (0)