From c646c102730481c3f4648eb714dc0a84ce35b13c Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Mon, 6 Jan 2020 17:45:38 +0100 Subject: [PATCH] refactoring to new function --- src/domain/Script.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/domain/Script.ts b/src/domain/Script.ts index 35e65b6d..aefda55b 100644 --- a/src/domain/Script.ts +++ b/src/domain/Script.ts @@ -13,18 +13,11 @@ export class Script extends BaseEntity implements IScript { if (lines.length === 0) { return; } - const checkForDuplicates = (line: string) => { - const trimmed = line.trim(); - if (trimmed.length === 1 && trimmed === ')' || trimmed === '(') { - return false; - } - return true; - }; const duplicateLines = new Array(); const uniqueLines = new Set(); let validatedLineCount = 0; for (const line of lines) { - if (!checkForDuplicates(line)) { + if (!this.isUniqueLine(line)) { continue; } uniqueLines.add(line); @@ -38,6 +31,14 @@ export class Script extends BaseEntity implements IScript { } } + private static isUniqueLine(codeLine: string): boolean { + const trimmed = codeLine.trim(); + if (trimmed === ')' || trimmed === '(') { // "(" and ")" are used often in batch code + return false; + } + return true; + } + constructor(public name: string, public code: string, public documentationUrls: ReadonlyArray) { super(name); if (code == null || code.length === 0) {