brimdata / zui

Zui is a powerful desktop application for exploring and working with data. The official front-end to the Zed lake.
https://www.brimdata.io/download/
Other
1.78k stars 129 forks source link

Dependency scrub #2719

Open philrz opened 1 year ago

philrz commented 1 year ago

As pointed out by @jameskerr in #2718:

It's not a good practice to rely on a node module that you don't have listed as dependency.

Since we bumped into #2717 by accident, it got me to wondering if there was an automated tool that could help us sniff out other instances of this problem waiting to bite us. I did a quick search and the first thing I found was the popular depcheck tool. Running it at Zui commit 243c348 that's before the fix in #2718 gets merged, indeed we see that reselect was flagged in here, so it probably does the trick.

$ npx depcheck
Unused dependencies
* @babel/core
* @codemirror/commands
* @codemirror/comment
* @js-joda/core
* acorn
* ajv
* electron-dl
* event-source-polyfill
* prismjs
* react-input-autosize
* zed
Unused devDependencies
* @swc/jest
* @testing-library/dom
* @types/mocha
* @types/prismjs
* @types/sprintf-js
* abort-controller
* babel-core
* babel-eslint
* babel-plugin-module-resolver
* brimcap
* cpx
* electron-builder-notarize
* electron-notarize
* lint-staged
* livereload
* prettier-eslint
* rimraf
* sprintf-js
* whatwg-fetch
* win-7zip
Missing dependencies
* src: ./src/zui-kit/core/value-view/types.ts
* @tanstack/table-core: ./src/zui-kit/core/table-view/table-view-api.ts
* packages: ./src/plugins/log-loader/index.ts
* redux: ./src/js/state/types.ts
* redux-thunk: ./src/js/state/types.ts
* reselect: ./src/js/state/utils.ts    <------------------------------------------- Flagged!
* history: ./src/js/state/migrations/202103051447_convertHistoryToUrls.ts
* immer: ./src/js/state/Tabs/reducer.ts
* settings: ./src/css/main.scss
* shared: ./src/css/main.scss
* forms: ./src/css/main.scss
* global: ./src/css/main.scss
* buttons: ./src/css/main.scss
* icons: ./src/css/main.scss
* tags: ./src/css/main.scss
* text-content: ./src/css/main.scss
* prism: ./src/css/main.scss
* layout: ./src/css/main.scss
* modal: ./src/css/main.scss
* conn-versation: ./src/css/main.scss
* chart: ./src/css/main.scss
* filter-node: ./src/css/main.scss
* filter-tree: ./src/css/main.scss
* arrows: ./src/css/main.scss
* log-viewer: ./src/css/main.scss
* log-detail: ./src/css/main.scss
* control-bar: ./src/css/main.scss
* pins: ./src/css/main.scss
* search-page: ./src/css/main.scss
* settings-modal: ./src/css/main.scss
* pool-modal: ./src/css/main.scss
* pane: ./src/css/main.scss
* history-pane: ./src/css/main.scss
* download-progress: ./src/css/main.scss
* error-boundary: ./src/css/main.scss
* tooltip: ./src/css/main.scss
* log-cell: ./src/css/main.scss
* search-results: ./src/css/main.scss
* column-chooser: ./src/css/main.scss
* histogram-tooltip: ./src/css/main.scss
* chart-elements: ./src/css/main.scss
* whois-modal: ./src/css/main.scss
* portal: ./src/css/main.scss
* message-box: ./src/css/main.scss
* notice-banner: ./src/css/main.scss
* circle-chevron: ./src/css/main.scss
* pane-toggle-buttons: ./src/css/main.scss
* animations: ./src/css/main.scss
* loading-message: ./src/css/main.scss
* loading-burst: ./src/css/main.scss
* curl-modal: ./src/css/main.scss
* inline-table: ./src/css/main.scss
* hash-correlation: ./src/css/main.scss
* inline-table-loading: ./src/css/main.scss
* table: ./src/css/main.scss
* span-duration: ./src/css/main.scss
* expand-button: ./src/css/main.scss
* pop-menu: ./src/css/main.scss
* button-row: ./src/css/main.scss
* debug-modal: ./src/css/main.scss
* click-feedback: ./src/css/main.scss
* header-cell: ./src/css/main.scss
* time-span-pickers: ./src/css/main.scss
* input-suggestions: ./src/css/main.scss
* tab: ./src/css/main.scss
* column-description: ./src/css/main.scss
* brand: ./src/css/main.scss
* empty-search-page: ./src/css/main.scss
* mac-spinner: ./src/css/main.scss
* saved-pools-list: ./src/css/main.scss
* progress-indicator: ./src/css/main.scss
* packet-post-progress: ./src/css/main.scss
* about-window: ./src/css/main.scss
* tab-search-loading: ./src/css/main.scss
* toolbar-button: ./src/css/main.scss
* ingest-warnings-modal: ./src/css/main.scss
* log-detail-window: ./src/css/main.scss
* sidebar: ./src/css/main.scss
* history-buttons: ./src/css/main.scss
* info-notice: ./src/css/main.scss
* x-button: ./src/css/main.scss
* html-context-menu: ./src/css/main.scss
* toaster: ./src/css/main.scss
* scroll-shadow: ./src/css/main.scss
* zed-table: ./src/css/main.scss
* list-item: ./src/css/main.scss
* columns-tree: ./src/css/main.scss
* zeek-plugin: ./src/css/main.scss
* results-pane: ./src/css/main.scss
* zed-view: ./src/css/main.scss
* mixins: ./src/css/forms/_main.scss
* text-input: ./src/css/forms/_main.scss
* select-input: ./src/css/forms/_main.scss
* file-input: ./src/css/forms/_main.scss
* @codemirror/view: ./src/app/query-home/search-area/editor/theme.ts
* @codemirror/matchbrackets: ./src/app/query-home/search-area/editor/use-extensions.ts
* import-js: ./bin/utils/imports.js

That said, I don't have the confidence to just start attacking the code base and making changes based on this output. If we do manage to use it to clean things up, no doubt it'd be good to lock it in as a tool that's run frequently as part of CI so we catch such problems in advance going forward.

philrz commented 1 year ago

Update: @nwt used depcheck recently to scrub some of the dependencies in #2737 and it helped but he also found it was not 100% reliable, so we may not soon realize the dream of having automation do all the heavy lifting here.