Clean up unused code and verbose syntax#867
Open
Gold856 wants to merge 5 commits into
Open
Conversation
4c9eecf to
2f7ecf6
Compare
e6a3d44 to
a62871c
Compare
There was a problem hiding this comment.
Pull request overview
This PR is a code cleanup that removes redundant checks and verbose syntax across the vscode-wpilib extension. It primarily replaces explicit === undefined/!== undefined comparisons with truthiness checks, switches T | undefined field declarations to optional ? syntax, removes some unreachable/dead code paths (e.g., response === undefined checks after await fetch(...)), and removes the unused wpilib.addDependency command (and dead IBinaryMap interface).
Changes:
- Replace
=== undefined/!== undefinedchecks with truthy/falsy checks and?.optional chaining throughout the extension code. - Remove unreachable
response === undefinedbranches afterfetch()and other dead/unused code paths (including unusedaddDependencycommand andIBinaryMaptype). - Refactor
DependencyViewProvidersorting into a sharedsorthelper usingIntl.Collator, simplify several boolean-returning preference getters, and inline a few trivially-used local variables.
Reviewed changes
Copilot reviewed 44 out of 44 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vscode-wpilib/src/wpilibupdates.ts | Simplify undefined checks; drop unreachable response/versions.length===0 branches; use optional property syntax. |
| vscode-wpilib/src/webviews/webviewbase.ts | Use ?.dispose() and shorter optional field syntax. |
| vscode-wpilib/src/webviews/projectcreator.ts | Replace === undefined with !. |
| vscode-wpilib/src/webviews/localeloader.ts | Drop redundant !! and the eslint-disable comment. |
| vscode-wpilib/src/webviews/gradle2025import.ts | Replace === undefined with !. |
| vscode-wpilib/src/vscommands.ts | Collapse multi-line undefined checks; use optional parameter syntax. |
| vscode-wpilib/src/versions.ts | Use ?: for optional else field. |
| vscode-wpilib/src/vendorlibraries.ts | Truthy checks instead of !== undefined. |
| vscode-wpilib/src/utilities.ts | Simplify javaHome check; drop unreachable else. |
| vscode-wpilib/src/toolapi.ts | Simplify result/workspace undefined checks. |
| vscode-wpilib/src/shared/vendorlibrariesbase.ts | Use ?. chaining; drop unreachable response === undefined check. |
| vscode-wpilib/src/shared/vendorexamples.ts | Drop redundant | undefined from optional. |
| vscode-wpilib/src/shared/utilitiesapi.ts | Use ?: optional field. |
| vscode-wpilib/src/shared/templates.ts | Truthy check for hasunittests. |
| vscode-wpilib/src/shared/promisecondition.ts | Use ?: and truthy checks. |
| vscode-wpilib/src/shared/examples.ts | Truthy check for hasunittests. |
| vscode-wpilib/src/riolog/vscodeimpl.ts | Truthy check on webviewPanel.visible. |
| vscode-wpilib/src/riolog/shared/sharedscript.ts | Replace === false/!== undefined with truthy/falsy checks. |
| vscode-wpilib/src/riolog/riologwindow.ts | Truthy checks on webview/console state. |
| vscode-wpilib/src/riolog/promisecond.ts | Use ?: and truthy checks. |
| vscode-wpilib/src/projectinfo.ts | Replace === undefined with !. |
| vscode-wpilib/src/preferencesapi.ts | Inline showWorkspaceFolderPick return. |
| vscode-wpilib/src/preferences.ts | Simplify boolean getters with !!. |
| vscode-wpilib/src/java/simulate.ts | Truthy environment check. |
| vscode-wpilib/src/java/java.ts | Truthy extension check; drop unused localW. |
| vscode-wpilib/src/java/deploydebug.ts | Drop redundant | undefined from optionals; truthy picked checks. |
| vscode-wpilib/src/fetchhelpers.ts | Drop unreachable response === undefined check. |
| vscode-wpilib/src/extension.ts | Remove unused wpilib.addDependency command and dead branches; inline localW. |
| vscode-wpilib/src/executor.ts | Truthy check on shell.options. |
| vscode-wpilib/src/docsapi.ts | Use ?.dispose(); remove blank lines. |
| vscode-wpilib/src/deploydebugapi.ts | Truthy checks on workspace/selection. |
| vscode-wpilib/src/dependencyView.ts | Add sort helper using Intl.Collator; simplify nesting and add await to refresh. |
| vscode-wpilib/src/cppprovider/vscommands.ts | Truthy workspaces checks. |
| vscode-wpilib/src/cppprovider/jsonformats.ts | Remove unused IBinaryMap interface. |
| vscode-wpilib/src/cppprovider/headertreeprovider.ts | Tighten getter return types; truthy checks. |
| vscode-wpilib/src/cppprovider/cppprovider.ts | Truthy workspaces check. |
| vscode-wpilib/src/cppprovider/apiprovider.ts | Drop redundant | undefined; collapse browse-config branches; truthy checks. |
| vscode-wpilib/src/cpp/simulatewindows.ts | Truthy environment / useWindbgX checks. |
| vscode-wpilib/src/cpp/simulateunix.ts | Truthy environment check. |
| vscode-wpilib/src/cpp/deploydebug.ts | Drop redundant | undefined; truthy picked checks. |
| vscode-wpilib/src/cpp/cpp.ts | Truthy check on cpptools extension. |
| vscode-wpilib/src/commandapi.ts | Truthy checks on language/selection. |
| vscode-wpilib/src/builtintools.ts | Truthy wp check. |
| vscode-wpilib/src/buildtestapi.ts | Truthy selection check. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.