cameron-martin / bazel-lsp

A language server implementation for Bazel
Apache License 2.0
41 stars 2 forks source link

Unused function reported as "Unused assignment" #42

Open hauserx opened 3 months ago

hauserx commented 3 months ago

Possibly that's issue with implementation in starlark-rust, but filling for now here before investigating further:

image

Example message in python checker: local variable 'x' is assigned to but never used

cameron-martin commented 3 months ago

Yeah it looks like starlark-rust treats defs as assignments. I suppose they kind of are, but it doesn't make for a very good error message.

hauserx commented 3 months ago

For variables also unused assignment may not be the best message:

image

I think it should be "Unused variable" for vars - https://github.com/bazelbuild/starlark/blob/master/spec.md#assignments

For functions it could be "Unused variable" (as Following spec https://github.com/bazelbuild/starlark/blob/master/spec.md#function-definitions ), but probably "Unused function" should be acceptable as def always declare a function.

hauserx commented 3 months ago

Adding yet another message that possibly can be improved (Used ignored variable). In this case variable _a is not defined at all, so message that using some ignore value is confusing.

image