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

[Bug]: depcheck incorrectly flags dependencies as unused #2132

Closed
yurishkuro opened this issue Jan 23, 2024 · 11 comments · Fixed by #2202
Closed

[Bug]: depcheck incorrectly flags dependencies as unused #2132

yurishkuro opened this issue Jan 23, 2024 · 11 comments · Fixed by #2202

Comments

@yurishkuro
Copy link
Member

yurishkuro commented Jan 23, 2024

What happened?

I want to see if all declared dependencies are actually used. We have yarn depcheck for this, but it incorrectly flags dependencies that are currently in use:

$ yarn depcheck
Unused devDependencies
* @types/rollup-plugin-visualizer
* @vitejs/plugin-legacy
* @vitejs/plugin-react
* rollup-plugin-visualizer
* vite-plugin-imp

Some of these plugins are in fact in use, they are declared in packages/jaeger-ui/vite.config.mts. Somehow we need to tell depcheck to ignore them. We already generate custom configs for depcheck in the scripts/run-depcheck.sh script, it probably needs to be extended somehow.

@prashantrewar
Copy link

hey @yurishkuro, I would like to work on this issue. Could you please guide me on this issue?

@yurishkuro
Copy link
Member Author

start with yarn depcheck and go from there

@MeenuyD
Copy link
Contributor

MeenuyD commented Feb 21, 2024

I am confused i have to change in scripts/run-depcheck.sh this or this packages/jaeger-ui/vite.config.mts

@yurishkuro
Copy link
Member Author

yurishkuro commented Feb 21, 2024

@MeenuyD I don't know what the solution is. I described a problem that we want to solve, which is that depcheck incorrectly flags dependencies which are in fact being used.

@MeenuyD
Copy link
Contributor

MeenuyD commented Feb 21, 2024

Ok

@tico88612
Copy link
Contributor

@yurishkuro, Is the issue resolved? I checked the latest build and my PC, and there was no depcheck issue.

image

@yurishkuro
Copy link
Member Author

$ yarn install --verbose  --frozen-lockfile

$ yarn depcheck
yarn run v1.22.19
$ ./scripts/run-depcheck.sh
Checking packages/jaeger-ui
    Unused devDependencies
    ⛔ @types/rollup-plugin-visualizer
    ⛔ @vitejs/plugin-legacy
    ⛔ @vitejs/plugin-react
    ⛔ rollup-plugin-visualizer
    ⛔ vite-plugin-imp
Checking packages/plexus
    No depcheck issue
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@tico88612
Copy link
Contributor

Which depcheck version do you use?

❯ npm install -g [email protected]


added 17 packages, removed 17 packages, and changed 111 packages in 708ms

15 packages are looking for funding
  run `npm fund` for details
❯ yarn depcheck
yarn run v1.22.19
$ ./scripts/run-depcheck.sh
Checking packages/jaeger-ui
    Unused devDependencies
    ⛔ @types/rollup-plugin-visualizer
    ⛔ @vitejs/plugin-legacy
    ⛔ @vitejs/plugin-react
    ⛔ rollup-plugin-visualizer
    ⛔ vite-plugin-imp
Checking packages/plexus
    No depcheck issue
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
❯ npm install -g [email protected]


added 17 packages, removed 17 packages, and changed 111 packages in 676ms

15 packages are looking for funding
  run `npm fund` for details
❯ yarn depcheck
yarn run v1.22.19
$ ./scripts/run-depcheck.sh
Checking packages/jaeger-ui
    No depcheck issue
Checking packages/plexus
    No depcheck issue
✨  Done in 2.27s.

@yurishkuro
Copy link
Member Author

I didn't realize we're running a globally installed depcheck - that's very bad, we need the builds to be reproducible, this is why we have yarn.lock.

yarn global add depcheck

depcheck itself should be added as a dependency.

@tico88612
Copy link
Contributor

tico88612 commented Mar 8, 2024

Agree. Do we lock depcheck to the latest version (1.4.7)?
Want to add in package.json or github/workflows/lint-build.yml?

@yurishkuro
Copy link
Member Author

If we add to github/workflows/lint-build.yml then dependabot probably won't be able to upgrade it, so it's not ideal. It's better to keep all deps in package.json. Latest version is fine.

yurishkuro pushed a commit that referenced this issue Mar 9, 2024
## Which problem is this PR solving?
- Resolves #2132

## Description of the changes
- Add `depcheck 1.4.7` in `package.json`
- Remove add global `depcheck` in CI test

## How was this change tested?
- manual test

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: tico88612 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants