Repository navigation
[AI Improvement] [Task] Remove dead EmulatorLog.waitForLog/toPrettyString and unused ImportExportEmulators type from src/emulator/types.ts - #11501
Conversation
There was a problem hiding this comment.
Code Review
This pull request simplifies src/emulator/types.ts by removing unused imports, types, and methods, including EventEmitter, ImportExportEmulators, EmulatorLog.waitForLog, and EmulatorLog.toPrettyString. It also refactors EmulatorLog.toString to always return a minified JSON string. The feedback suggests further simplifying the class by inlining the JSON serialization logic directly into toString and removing the now-redundant private toStringCore method.
| toString(): string { | ||
| return this.toStringCore(false); | ||
| } | ||
|
|
||
| toPrettyString(): string { | ||
| return this.toStringCore(true); | ||
| return this.toStringCore(); | ||
| } |
There was a problem hiding this comment.
Since toPrettyString has been removed, toStringCore is now only called once by toString. We can simplify the class and reduce indirection by inlining the JSON serialization logic directly into toString and removing the private toStringCore method entirely.
| toString(): string { | |
| return this.toStringCore(false); | |
| } | |
| toPrettyString(): string { | |
| return this.toStringCore(true); | |
| return this.toStringCore(); | |
| } | |
| toString(): string { | |
| return JSON.stringify({ | |
| timestamp: this.timestamp, | |
| level: this.level, | |
| text: this.text, | |
| data: this.data, | |
| type: this.type, | |
| }); | |
| } |
There was a problem hiding this comment.
Inlined JSON.stringify(...) directly into EmulatorLog.toString() in commit f554a5c.
| private toStringCore(): string { | ||
| return JSON.stringify({ | ||
| timestamp: this.timestamp, | ||
| level: this.level, | ||
| text: this.text, | ||
| data: this.data, | ||
| type: this.type, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Removed the private toStringCore() helper in commit f554a5c.
shettyvarun268
left a comment
There was a problem hiding this comment.
Approved with a +1 to both gemini bot comments
|
@shettyvarun268 +1'd both gemini-code-assist suggestions above, so let's apply them: inline the |
|
Addressed the review feedback in commit f554a5c:
Verified locally with |
Description
Resolves Buganizer b/585186590
Removes unused declarations and dead code from
src/emulator/types.ts:ImportExportEmulatorstype alias while retainingIMPORT_EXPORT_EMULATORS.EmulatorLog.waitForLogand theEventEmitterimport from"events"that was only used bywaitForLog.EmulatorLog.toPrettyString().EmulatorLog.toString()/EmulatorLog.toStringCore()to drop the now-unusedprettyparameter and extraundefined, 0arguments toJSON.stringify, producing identical compact JSON output.No
CHANGELOG.mdentry is included as this is internal dead-code removal with no user-facing changes.Scenarios Tested
git grep -n -w -e waitForLog -e toPrettyString -e ImportExportEmulators(0 matches)node_modules/.bin/prettier --check src/emulator/types.ts(passed)npm run build(passed)npm run test:compile(passed)npx tsc --noEmit -p scripts/emulator-tests/tsconfig.dev.json(passed)npm run lint:quiet(passed)npx mocha 'src/emulator/**/*.spec.ts' --forbid-only(633 passing, 1 pending)npm run mocha -- --forbid-only(5978 passing, 11 pending)Sample Commands
N/A