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

cmd/cue: could vet emit a warning instead of an error when an import is not used? #1120

Closed
PierreR opened this issue Jul 19, 2021 · 1 comment

Comments

@PierreR
Copy link

PierreR commented Jul 19, 2021

Currently cue vet is failing if something like "strings" is imported but not used with this error message:

imported and not used: "strings"

I believe this is painful in practice as you often comments part of your configuration to debug issues. It forces you to comment back and forth your import statements as well.

Could this be a simple warning instead of an error ?

@PierreR PierreR added the Triage Requires triage/attention label Jul 19, 2021
@PierreR PierreR changed the title Cue vet should emit a warning instead of failing when an import is not used Cue vet could emit a warning instead of an error when an import is not used Jul 19, 2021
@myitcv myitcv changed the title Cue vet could emit a warning instead of an error when an import is not used cmd/cue: could vet emit a warning instead of an error when an import is not used? Jul 20, 2021
@myitcv myitcv added WorkingAsIntended and removed Triage Requires triage/attention labels Jul 20, 2021
@myitcv
Copy link
Member

myitcv commented Jul 20, 2021

@PierreR I think the right fix here is a tooling one, because we having different error modes adds (cognitive) complexity if nothing else.

FWIW, this is exactly the same behaviour as Go; likewise, unused variables are errors, just as let declarations and aliases are in CUE.

The particular problem you refer to with import statements and commented-out code, is largely addressed in Go by the use of goimports-like behaviour. This adds/removes imports as required. See https://pkg.go.dev/golang.org/x/tools/cmd/goimports for more details.

With #142 we will add similar support within CUE. Hence, taking you example, when commenting out code that required an import, if no other code requires that import it will be removed.

So this is working as intended, and given the fix is really #142 I'll close this for now.

@myitcv myitcv closed this as completed Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants