Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce unused exports #164939

Closed
joyceerhl opened this issue Oct 28, 2022 · 3 comments · Fixed by #169054
Closed

Reduce unused exports #164939

joyceerhl opened this issue Oct 28, 2022 · 3 comments · Fixed by #169054
Assignees
Labels
debt Code quality issues insiders-released Patch has been released in VS Code Insiders
Milestone

Comments

@joyceerhl
Copy link
Contributor

joyceerhl commented Oct 28, 2022

@rebornix and I were wondering if there is any dead code in the VS Code codebase, and one idea was to detect unused exports across the codebase, since unused variables are flagged by the compiler but unused exports are not.

I ran ts-unused-exports on our sources and generated the following list. I've already done a pass to remove some false positives but apologies if several remain. From a quick sanity check, several of these are indeed not used outside of the file they are declared in and do not need to be exported. Please feel free to remove your assignment if you find that this isn't valuable.

Git blame Function File
@meganrogge ITerminalProfileType src/vs/platform/terminal/common/terminal.ts
@meganrogge TaskDefinitionRegistryImpl src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.ts
@meganrogge ITerminalDecorationData src/vs/workbench/contrib/terminal/browser/terminalDecorationsProvider.ts
@jrieken IndexTree src/vs/base/browser/ui/tree/indexTree.ts
@mjbvz IDataTransferFile src/vs/base/common/dataTransfer.ts
@jrieken IKeyIterator src/vs/base/common/ternarySearchTree.ts
@alexdima main src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
@mjbvz createFileDataTransferItemFromFile src/vs/editor/browser/dnd.ts
@sandy081 IEditorContributionCtor src/vs/editor/browser/editorExtensions.ts
@sandy081 IDiffEditorContributionCtor src/vs/editor/browser/editorExtensions.ts
@jrieken ProxyCommand src/vs/editor/browser/editorExtensions.ts
@mjbvz ResolveCodeActionKeybinding src/vs/editor/contrib/codeAction/browser/codeActionKeybindingResolver.ts
@mjbvz TriggeredCodeAction src/vs/editor/contrib/codeAction/browser/codeActionModel.ts
@jrieken TriggerModifier src/vs/editor/contrib/gotoSymbol/browser/link/clickLinkGesture.ts
@jrieken IEditorHoverParticipantCtor src/vs/editor/contrib/hover/browser/hoverTypes.ts
@jrieken SuggestTriggerContext src/vs/editor/contrib/suggest/browser/suggestModel.ts
@mjbvz ICommandsMap src/vs/platform/actions/common/actions.ts
@mjbvz ICommandsMap src/vs/platform/commands/common/commands.ts
@mjbvz IDragAndDropContribution src/vs/platform/dnd/browser/dnd.ts
@mjbvz IWebviewEditor src/vs/platform/extensions/common/extensions.ts
@sandy081 ICodeActionContributionAction src/vs/platform/extensions/common/extensions.ts
@sandy081 ICodeActionContribution src/vs/platform/extensions/common/extensions.ts
@TylerLeonhardt Pick src/vs/platform/quickinput/browser/pickerQuickAccess.ts
@jrieken ExtHostStatusBarEntry src/vs/workbench/api/common/extHostStatusBar.ts
@mjbvz reviveOptions src/vs/workbench/api/common/extHostWebview.ts
@mjbvz CodeActionExtensionPointFields src/vs/workbench/contrib/codeActions/common/codeActionsExtensionPoint.ts
@mjbvz DocumentationExtensionPointFields src/vs/workbench/contrib/codeActions/common/documentationExtensionPoint.ts
@mjbvz RefactoringDocumentationExtensionPoint src/vs/workbench/contrib/codeActions/common/documentationExtensionPoint.ts
@mjbvz CustomEditorInputInitInfo src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
@mjbvz INotebookPreloadContribution src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.ts
@hediet DirtyDiffController src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts
@hediet DirtyDiffModel src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts
@rebornix experimental src/vs/workbench/contrib/themes/test/electron-browser/colorRegistry.releaseTest.ts
@mjbvz getActiveWebviewEditor src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.ts
@mjbvz WebviewResolver src/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService.ts
@mjbvz IWebviewViewResolver src/vs/workbench/contrib/webviewView/browser/webviewViewService.ts
@alexdima TokenTypesContribution src/vs/workbench/services/textMate/common/TMGrammars.ts
@rebornix PointerEventHandler src/vs/editor/browser/controller/pointerHandler.ts
@rebornix DecorationSubTypeOptionsProvider src/vs/editor/browser/services/abstractCodeEditorService.ts
@rebornix DecorationTypeOptionsProvider src/vs/editor/browser/services/abstractCodeEditorService.ts
@rebornix AverageBufferSize src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts
@rebornix createUintArray src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts
@rebornix LineStarts src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts
@rebornix NodePosition src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts
@rebornix BufferCursor src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts
@rebornix IReverseSingleEditOperation src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer.ts
@rebornix PieceTreeTextBufferFactory src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder.ts
@rebornix calculateSize src/vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase.ts
@rebornix calculateLF src/vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase.ts
@rebornix resetSentinel src/vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase.ts
@rebornix leftRotate src/vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase.ts
@rebornix rightRotate src/vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase.ts
@rebornix recomputeTreeMetadata src/vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase.ts
@rebornix FindWidgetViewZone src/vs/editor/contrib/find/browser/findWidget.ts
@rebornix ISimpleButtonOpts src/vs/editor/contrib/find/browser/findWidget.ts
@rebornix getRandomInt src/vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils.ts
@rebornix getRandomEOLSequence src/vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils.ts
@rebornix getRandomString src/vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils.ts
@rebornix generateRandomChunkWithLF src/vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils.ts
@rebornix INotebookEntry src/vs/platform/extensions/common/extensions.ts
@rebornix ExtHostDocumentLine src/vs/workbench/api/common/extHostDocumentData.ts
@rebornix createKernelId src/vs/workbench/api/common/extHostNotebookKernels.ts
@rebornix INotebookCommentThreadChangedEvent src/vs/workbench/contrib/comments/browser/commentService.ts
@rebornix ICommentController src/vs/workbench/contrib/comments/browser/commentService.ts
@rebornix COMMENTEDITOR_DECORATION_KEY src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts
@rebornix isMouseUpEventMatchMouseDown src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts
@rebornix CommentsAsyncDataSource src/vs/workbench/contrib/comments/browser/commentsTreeViewer.ts
@rebornix ResourceWithCommentsRenderer src/vs/workbench/contrib/comments/browser/commentsTreeViewer.ts
@rebornix CommentNodeRenderer src/vs/workbench/contrib/comments/browser/commentsTreeViewer.ts
@rebornix InteractiveEditorViewState src/vs/workbench/contrib/interactive/browser/interactiveEditor.ts
@rebornix InteractiveEditorOptions src/vs/workbench/contrib/interactive/browser/interactiveEditor.ts
@rebornix ISerializedCell src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.ts
@rebornix IPYNB_VIEW_TYPE src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
@rebornix IRenderPlainHtmlOutput src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
@rebornix IRenderOutputViaExtension src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
@rebornix NotebookViewCellsSplice src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
@rebornix cellStatusIconRunning src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix notebookOutputContainerBorderColor src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix notebookOutputContainerColor src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix CELL_TOOLBAR_SEPERATOR src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix focusedCellBackground src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix selectedCellBackground src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix cellHoverBackground src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix selectedCellBorder src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix inactiveSelectedCellBorder src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix focusedCellBorder src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix inactiveFocusedCellBorder src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix cellStatusBarItemHover src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix listScrollbarSliderBackground src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix listScrollbarSliderHoverBackground src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix listScrollbarSliderActiveBackground src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix cellSymbolHighlight src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@rebornix INotebookFindFiltersChangeEvent src/vs/workbench/contrib/notebook/browser/contrib/find/findFilters.ts
@rebornix findFilterButton src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.ts
@rebornix OutputElement src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.ts
@rebornix NotebookCellLayoutChangedEvent src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.ts
@rebornix NotebookDiffViewEvent src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.ts
@rebornix CellDiffCommonRenderTemplate src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.ts
@rebornix NotebookMouseController src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.ts
@rebornix isNotebookKeymapExtension src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.ts
@rebornix NotebookOutputRendererInfoStore src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.ts
@rebornix WorkerManager src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.ts
@rebornix IWorkerClient src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.ts
@rebornix NotebookEditorModelManager src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.ts
@rebornix NotebookWorkerClient src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.ts
@rebornix CellOutputElement src/vs/workbench/contrib/notebook/browser/view/cellParts/cellOutput.ts
@rebornix IResizeObserver src/vs/workbench/contrib/notebook/browser/view/cellParts/cellWidgets.ts
@rebornix BrowserResizeObserver src/vs/workbench/contrib/notebook/browser/view/cellParts/cellWidgets.ts
@rebornix getResizesObserver src/vs/workbench/contrib/notebook/browser/view/cellParts/cellWidgets.ts
@rebornix getCodeCellExecutionContextKeyService src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellRunToolbar.ts
@rebornix ICachedInset src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
@rebornix IResolvedBackLayerWebview src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
@rebornix IViewCellEditingDelegate src/vs/workbench/contrib/notebook/browser/viewModel/cellEdit.ts
@rebornix JoinCellEdit src/vs/workbench/contrib/notebook/browser/viewModel/cellEdit.ts
@rebornix NotebookViewModelOptions src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts
@rebornix createCellViewModel src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts
@rebornix NOTEBOOK_BREAKPOINT_MARGIN_ACTIVE src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts
@rebornix ProxyKernelState src/vs/workbench/contrib/notebook/common/notebookKernelService.ts
@rebornix INotebookProxyKernelChangeEvent src/vs/workbench/contrib/notebook/common/notebookKernelService.ts
@rebornix EditorTopPaddingChangeEvent src/vs/workbench/contrib/notebook/common/notebookOptions.ts
@rebornix NotebookLayoutConfiguration src/vs/workbench/contrib/notebook/common/notebookOptions.ts
@rebornix PerfName src/vs/workbench/contrib/notebook/common/notebookPerformance.ts
@rebornix NotebookOperationManager src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
@rebornix NotebookEventEmitter src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
@rebornix CellSequence src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.ts
@rebornix ID_NOTEBOOK_EDITOR_WORKER_SERVICE src/vs/workbench/contrib/notebook/common/services/notebookWorkerService.ts
@rebornix createProviderComparer src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts
@rebornix OpenEditorContext src/vs/workbench/services/editor/common/editorGroupsService.ts
@rebornix KeyboardLayoutContribution src/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.darwin.ts
@rebornix KeyboardLayoutContribution src/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.linux.ts
@rebornix KeyboardLayoutContribution src/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.win.ts
@roblourens suiteRepeat src/vs/base/test/common/utils.ts
@roblourens IDropdownWithPrimaryActionViewItemOptions src/vs/platform/actions/browser/dropdownWithPrimaryActionViewItem.ts
@roblourens SelectionKeyboardEvent src/vs/platform/list/browser/listService.ts
@roblourens runInExternalTerminal src/vs/workbench/api/node/extHostDebugService.ts
@roblourens extensionResultIsMatch src/vs/workbench/api/test/node/extHostSearch.test.ts
@roblourens ISuggestEnabledInputStyleOverrides src/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.ts
@roblourens IAdapterManagerDelegate src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts
@roblourens CONTEXT_BREAKPOINT_ACCESS_TYPE src/vs/workbench/contrib/debug/common/debug.ts
@roblourens cellInsertionIndicator src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
@roblourens NotebookFindWidget src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.ts
@roblourens ICssClassDelegate src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars.ts
@roblourens ICellExecutionEntry src/vs/workbench/contrib/notebook/common/notebookExecutionStateService.ts
@roblourens IIndexedSetting src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts
@roblourens ISettingsTargetsWidgetOptions src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts
@roblourens ISettingChangeEvent src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourens SettingGroupRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourens SettingNewExtensionsRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourens SettingComplexRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourens SettingExcludeRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourens SettingEnumRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourens SettingNumberRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourens SettingBoolRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourens ONLINE_SERVICES_SETTING_TAG src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts
@roblourens isExcludeSetting src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts
@roblourens TOCRenderer src/vs/workbench/contrib/preferences/browser/tocTree.ts
@roblourens SingleLineInputHeight src/vs/workbench/contrib/search/browser/searchWidget.ts
@roblourens IDataLinkClickEvent src/vs/workbench/contrib/webview/browser/webview.ts
@roblourens IKeybindingsEditorSearchOptions src/vs/workbench/services/preferences/browser/keybindingsEditorInput.ts
@roblourens IInternalFileMatch src/vs/workbench/services/search/common/fileSearchManager.ts
@roblourens IDirectoryEntry src/vs/workbench/services/search/common/fileSearchManager.ts
@roblourens IDirectoryTree src/vs/workbench/services/search/common/fileSearchManager.ts
@roblourens IOneSearchPathPattern src/vs/workbench/services/search/common/queryBuilder.ts
@roblourens ISearchPathPattern src/vs/workbench/services/search/common/queryBuilder.ts
@roblourens ICommonQueryBuilderOptions src/vs/workbench/services/search/common/queryBuilder.ts
@roblourens rgErrorMsgForDisplay src/vs/workbench/services/search/node/fileSearch.ts
@roblourens IFileProgressCallback src/vs/workbench/services/search/node/rawSearchService.ts
@roblourens IRgGlobResult src/vs/workbench/services/search/node/ripgrepFileSearch.ts
@roblourens foldersToRgExcludeGlobs src/vs/workbench/services/search/node/ripgrepFileSearch.ts
@roblourens foldersToIncludeGlobs src/vs/workbench/services/search/node/ripgrepFileSearch.ts
@roblourens rgErrorMsgForDisplay src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts
@roblourens buildRegexParseError src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts
@roblourens spreadGlobComponents src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts
@roblourens IRgSubmatch src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts
@roblourens IRgBytesOrText src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts
@rzhao271 IHoverAction src/vs/base/browser/ui/iconLabel/iconLabelHover.ts
@rzhao271 IEmmetActionOptions src/vs/workbench/contrib/emmet/browser/emmetActions.ts
@rzhao271 SettingArrayRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@rzhao271 SettingObjectRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@rzhao271 SettingBoolObjectRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@rzhao271 SettingTextRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@rzhao271 SettingMultilineTextRenderer src/vs/workbench/contrib/preferences/browser/settingsTree.ts
@rzhao271 panelOpensMaximizedSettingToString src/vs/workbench/services/layout/browser/layoutService.ts
@mjbvz
Copy link
Collaborator

mjbvz commented Oct 28, 2022

Thanks @joyceerhl!

For a quick review, so far all of mine were have been for types that were not being directly used outside of the defining file. They were however being referenced indirectly in the file, such as as parameter to public functions or as return types

Probably still good to remove them in case a future refactoring renders them unused

@roblourens
Copy link
Member

cc @andreamah for search and @rzhao271 for settings editor

roblourens added a commit that referenced this issue Nov 1, 2022
roblourens added a commit that referenced this issue Nov 1, 2022
rebornix added a commit that referenced this issue Nov 1, 2022
@rebornix
Copy link
Member

rebornix commented Nov 1, 2022

@joyceerhl thanks for thorough analysis. It's useful in quite a few scenarios but some are false positive, here is what I found

It works really well with:

  • Dead code (removing a export then help us remove multiple classes)
  • Avoid exposing Class when Interface is sufficient

But it's unnecessary and sometimes potentially harmful when:

  • Union types (export type A = B | C, it's arguable if B or C should be exported).
  • A set of helper functions, most functions in this set are exposed and used by outer modules, but some are only used in current module. Removing the export might lead to duplicates (when someone can't find the private helper function).
  • Object literals. The types can be omitted when using object literals since TS LSP is smart, but I don't feel comfortable of removing the export as callers might want to use the type in the future.

Like we discussed offline, it might require each owner to make their own judgement

@rebornix rebornix removed their assignment Nov 1, 2022
@mjbvz mjbvz removed their assignment Nov 2, 2022
rzhao271 added a commit that referenced this issue Nov 3, 2022
@roblourens roblourens removed their assignment Nov 5, 2022
@rzhao271 rzhao271 added this to the December 2022 milestone Dec 5, 2022
@rzhao271 rzhao271 added the debt Code quality issues label Dec 5, 2022
@rzhao271 rzhao271 removed their assignment Dec 5, 2022
andreamah added a commit that referenced this issue Dec 13, 2022
andreamah added a commit that referenced this issue Dec 13, 2022
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Dec 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues insiders-released Patch has been released in VS Code Insiders
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants