go/internal/lsp/analysis
Francesco Renzi 1a4e02fee4 internal/lsp/analysis/unusedvariable: add analyzer
This analyzer suggests fixes for unused variable errors.
In declarations it will remove the whole statement if the offending
variable is the only one declared in that statement, otherwise it will
just delete the offending variable.
In assignments it will remove the whole statement if the offending
variable is the only one assigned in that statement, otherwise it will
rename the offending variable to `_`. If the assignment RHS contains a
statement that can cause a side effect (a function call or reading from
a channel), the assignment will be removed but RHS will be preserved.

Fixes golang/go#48975

Change-Id: I3850f1b0340cd5ae63249931df3a5403d8617080
Reviewed-on: https://go-review.googlesource.com/c/tools/+/394934
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-07-15 14:27:36 +00:00
..
embeddirective internal/lsp/analysis: fix a doc comment typo 2022-05-11 23:42:05 +00:00
fillreturns internal/analysisinternal: move FindBestMatch to internal/lsp/fuzzy 2022-07-13 21:41:37 +00:00
fillstruct internal/analysisinternal: move FindBestMatch to internal/lsp/fuzzy 2022-07-13 21:41:37 +00:00
infertypeargs internal/typeparams: simplify the IndexExpr API 2022-01-19 20:29:28 +00:00
nonewvars internal/lsp/analysis: add typeparams tests for nonewvars and noresultvalues 2021-10-13 04:56:02 +00:00
noresultvalues internal/lsp/analysis/noresultvalues: update for CL 379116 error message change 2022-01-18 21:28:05 +00:00
simplifycompositelit gopls: fix various staticcheck errors 2020-09-29 17:30:36 +00:00
simplifyrange internal/lsp: make sure that `gofmt -s` analyses don't modify AST 2020-04-06 21:01:14 +00:00
simplifyslice internal/lsp: add parameterized slice test for simplifyslice analysis 2021-10-01 15:56:03 +00:00
stubmethods internal/lsp/analysis/stubmethods: recognize *ast.CallExpr 2022-05-17 17:04:34 +00:00
undeclaredname internal: remove unneeded FileSets 2022-06-06 20:47:10 +00:00
unusedparams internal/lsp: add suggested fix for unusedparams analysis 2022-01-14 17:47:02 +00:00
unusedvariable internal/lsp/analysis/unusedvariable: add analyzer 2022-07-15 14:27:36 +00:00
useany internal/lsp/analysis: add a useany analyzer 2021-09-22 22:01:06 +00:00