Skip to content

Commit aa21032

Browse files
author
ForgeFlow v2
committed
refactor(strings): Convert string concatenation to template literals
Replace inefficient `+` operator concatenation with template literals for: - Improved code readability - Better performance (single string construction instead of multiple) - Consistent style with modern JavaScript practices Files modified: - DevtoolsUtils.ts: 4 logger calls - McpContext.ts: 1 logger call - explorer.ts: 8 logger calls Addresses 8+ quality suggestions for string handling inefficiencies.
1 parent b94e2d8 commit aa21032

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/DevtoolsUtils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ export function mapIssueToMessageObject(issue: DevTools.AggregatedIssue) {
8686
const markdownDescription = issue.getDescription();
8787
const filename = markdownDescription?.file;
8888
if (!markdownDescription) {
89-
logger(`no description found for issue:` + issue.code);
89+
logger(`no description found for issue: ${issue.code}`);
9090
return null;
9191
}
9292
const rawMarkdown = filename
9393
? ISSUE_UTILS.getIssueDescription(filename)
9494
: null;
9595
if (!rawMarkdown) {
96-
logger(`no markdown ${filename} found for issue:` + issue.code);
96+
logger(`no markdown ${filename} found for issue: ${issue.code}`);
9797
return null;
9898
}
9999
let processedMarkdown: string;
@@ -109,11 +109,11 @@ export function mapIssueToMessageObject(issue: DevTools.AggregatedIssue) {
109109
title =
110110
DevTools.MarkdownIssueDescription.findTitleFromMarkdownAst(markdownAst);
111111
} catch {
112-
logger('error parsing markdown for issue ' + issue.code());
112+
logger(`error parsing markdown for issue ${issue.code()}`);
113113
return null;
114114
}
115115
if (!title) {
116-
logger('cannot read issue title from ' + filename);
116+
logger(`cannot read issue title from ${filename}`);
117117
return null;
118118
}
119119
return {
@@ -273,7 +273,7 @@ const SKIP_ALL_PAUSES = {
273273
modelAdded(model: DevTools.DebuggerModel): void {
274274
void model.agent.invoke_setSkipAllPauses({skip: true}).catch((error) => {
275275
// Log but don't rethrow - skipping pauses is optional and failures are non-critical
276-
logger('Failed to set skip all pauses on debugger model: ' + String(error));
276+
logger(`Failed to set skip all pauses on debugger model: ${String(error)}`);
277277
});
278278
},
279279

src/McpContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class McpContext implements Context {
187187
return request.id === cdpRequestId;
188188
});
189189
if (!request) {
190-
this.logger('no network request for ' + cdpRequestId);
190+
this.logger(`no network request for ${cdpRequestId}`);
191191
return;
192192
}
193193
return this.#networkCollector.getIdForResource(request);

src/utils/explorer.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ export class AutonomousExplorer {
138138
...config,
139139
};
140140

141-
logger('[EXPLORER] Starting exploration from ' + startUrl);
142-
logger('[EXPLORER] Config: maxDepth=' + fullConfig.maxDepth + ', maxPages=' + fullConfig.maxPages);
141+
logger(`[EXPLORER] Starting exploration from ${startUrl}`);
142+
logger(`[EXPLORER] Config: maxDepth=${fullConfig.maxDepth}, maxPages=${fullConfig.maxPages}`);
143143

144144
const startTime = Date.now();
145145

@@ -162,27 +162,27 @@ export class AutonomousExplorer {
162162

163163
// Skip if max depth exceeded
164164
if (depth > fullConfig.maxDepth) {
165-
logger('[EXPLORER] Max depth reached for ' + url);
165+
logger(`[EXPLORER] Max depth reached for ${url}`);
166166
continue;
167167
}
168168

169169
// Skip if URL matches ignore patterns
170170
if (this.shouldIgnoreUrl(url, fullConfig.ignorePatterns)) {
171-
logger('[EXPLORER] Ignoring ' + url + ' (matches ignore pattern)');
171+
logger(`[EXPLORER] Ignoring ${url} (matches ignore pattern)`);
172172
continue;
173173
}
174174

175175
// Skip external links if not following
176176
if (!fullConfig.followExternal) {
177177
const urlDomain = new URL(url).hostname;
178178
if (urlDomain !== startDomain) {
179-
logger('[EXPLORER] Skipping external link: ' + url);
179+
logger(`[EXPLORER] Skipping external link: ${url}`);
180180
continue;
181181
}
182182
}
183183

184184
// Visit page
185-
logger('[EXPLORER] Visiting [' + (this.visited.size + 1) + '/' + fullConfig.maxPages + '] ' + url + ' (depth ' + depth + ')');
185+
logger(`[EXPLORER] Visiting [${this.visited.size + 1}/${fullConfig.maxPages}] ${url} (depth ${depth})`);
186186

187187
try {
188188
const pageInfo = await this.visitPage(page, url, depth, fullConfig);
@@ -207,7 +207,7 @@ export class AutonomousExplorer {
207207
}
208208
}
209209
} catch (error) {
210-
logger('[EXPLORER] Failed to visit ' + url + ': ' + String(error));
210+
logger(`[EXPLORER] Failed to visit ${url}: ${String(error)}`);
211211
// Enforce error array size limit
212212
if (this.allErrors.length < this.maxErrorsSize) {
213213
this.allErrors.push({
@@ -231,7 +231,7 @@ export class AutonomousExplorer {
231231
allForms.push(...pageInfo.forms);
232232
}
233233

234-
logger('[EXPLORER] Exploration complete: ' + this.visited.size + ' pages in ' + explorationTime + 'ms');
234+
logger(`[EXPLORER] Exploration complete: ${this.visited.size} pages in ${explorationTime}ms`);
235235

236236
return {
237237
sitemap: this.sitemap,
@@ -458,7 +458,7 @@ export class AutonomousExplorer {
458458
const regex = new RegExp(pattern);
459459
return regex.test(url);
460460
} catch (error) {
461-
logger('[EXPLORER] Invalid ignore pattern: ' + pattern);
461+
logger(`[EXPLORER] Invalid ignore pattern: ${pattern}`);
462462
return false;
463463
}
464464
});

0 commit comments

Comments
 (0)