Skip to content

Clean up dead code and other low-hanging tech debt#5515

Open
andyleejordan wants to merge 2 commits into
mainfrom
andyleejordan/fix-tech-debt
Open

Clean up dead code and other low-hanging tech debt#5515
andyleejordan wants to merge 2 commits into
mainfrom
andyleejordan/fix-tech-debt

Conversation

@andyleejordan

Copy link
Copy Markdown
Member

PR Summary

A few low-risk cleanups found while combing through the extension:

  • Remove unused getTimestampString() (src/utils.ts) — dead since 2017 (1b424000), when "Add timestamps and log levels to all extension-side log messages" moved timestamping into the Logger and deleted its three call sites. It also had a latent bug: no zero-padding, so it rendered times like [9:5:3].
  • Remove unused getWindowsSystemPowerShellPath() (src/platform.ts) — dead since Discover new PowerShell installations, fix startup issue with Windows PowerShell #2238 (2019), which introduced PowerShellExeFinder and deleted the System32PowerShellPath / SysnativePowerShellPath / SysWow64PowerShellPath constants that called it. The same path is now built inline in findWinPS(), with proper bitness handling in getSystem32Path().
  • Use ILogger instead of console.log in writePidIfInDevMode (src/session.ts), per our convention. While here, await the adjacent fs.delete so the "Deleted PID file" message is actually true — previously it was a floating promise and the log ran before the delete resolved.
  • Update the PSScriptAnalyzer rule docs link to learn.microsoft.com from docs.microsoft.com (src/features/CodeActions.ts); the old URL just 301s there anyway.

I left the Command Explorer's dead code alone since #5508 already rewrites that file. compile, lint, and format all pass; the touched code has no test coverage so risk is low.

Drafted by Copilot (Claude Opus 4.8).

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • [NA] PR has tests
  • This PR is ready to merge and is not work in progress

A few low-risk cleanups found while combing through the extension:

- Remove the unused `getTimestampString()` from `src/utils.ts`. It's been
  dead since 2017 (`1b424000`), when "Add timestamps and log levels to all
  extension-side log messages" moved timestamping into the `Logger` and
  deleted its three call sites. It also had a latent bug: no zero-padding,
  so it rendered times like `[9:5:3]`.
- Remove the unused `getWindowsSystemPowerShellPath()` from
  `src/platform.ts`. It's been dead since #2238 (2019), which introduced
  `PowerShellExeFinder` and deleted the `System32PowerShellPath` /
  `SysnativePowerShellPath` / `SysWow64PowerShellPath` constants that
  called it. The same path is now built inline in `findWinPS()`, with
  proper bitness handling in `getSystem32Path()`.
- Replace `console.log` with `this.logger.writeDebug` in
  `writePidIfInDevMode` (`src/session.ts`), per our `ILogger` convention.
  While here, `await` the `fs.delete` it sits next to so the "Deleted PID
  file" message is actually true — previously it was a floating promise and
  the log ran before the delete resolved.
- Point the PSScriptAnalyzer rule docs link at `learn.microsoft.com`
  instead of `docs.microsoft.com` (`src/features/CodeActions.ts`); the old
  URL just 301s there anyway.

I left the Command Explorer's dead code alone since #5508 already rewrites
that file. Compile, lint, and format all pass; the touched code has no test
coverage so risk is low.

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 12, 2026 19:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR performs small “tech debt” cleanups in the VS Code PowerShell extension by removing long-dead helpers, aligning logging with ILogger, and updating an external documentation link.

Changes:

  • Removed unused legacy helpers: getTimestampString() (src/utils.ts) and getWindowsSystemPowerShellPath() (src/platform.ts).
  • Updated writePidIfInDevMode cleanup logging to use ILogger and attempted to make PID-file deletion logging reflect completion (src/session.ts).
  • Updated the PSScriptAnalyzer rules documentation base URL to learn.microsoft.com (src/features/CodeActions.ts).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/utils.ts Removes unused timestamp helper.
src/session.ts Replaces console.log with ILogger and adjusts PID-file deletion behavior on process exit.
src/platform.ts Removes unused Windows PowerShell path helper.
src/features/CodeActions.ts Updates PSScriptAnalyzer documentation link base URL.

Comment thread src/session.ts
The `onExited` listener in `writePidIfInDevMode` is `async`, but VS Code
`Event` listeners are fire-and-forget: the returned promise is never
awaited. As Copilot noted on #5515, that means a rejection from
`fs.delete(...)` would surface as an unhandled promise rejection, and the
debug log would be skipped on failure.

I kept the `async`/`await` form for readability and wrapped the body in
`try`/`catch` so nothing escapes: a fully-caught async body resolves
normally, and any failure is now logged via `this.logger.writeError`
instead of going unhandled. The original `main` version floated the
delete promise and logged success unconditionally, swallowing errors.

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@andyleejordan andyleejordan enabled auto-merge (squash) June 12, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants