ccls
ccls copied to clipboard
How to suppress error report for unused function or variable?
Here are some things you should try before filing a bug report:
- For client issues related to emacs-ccls or vscode-ccls, report in their own repository.
- For build problems, check https://github.com/MaskRay/ccls/wiki/Build
- Check https://github.com/MaskRay/ccls/wiki/Debugging
- Check the FAQ to see if your issue is mentioned.
If none of those help, remove this section and fill out the four sections in the template below.
Observed behavior
Describe what happened. Any aids you can include (that you think could be relevant) are a tremendous help.
-
compile_commands.json
or.ccls
(wiki/Project-Setup) - Reduce to A minimal set of
.c
.cc
.h
.hh
files that can still demonstrate the issue. - Consider a screencast gif.
Expected behavior
Describe what you expected to happen.
Steps to reproduce
- Select these example steps,
- Delete them,
- And replace them with precise steps to reproduce your issue.
System information
- ccls version (
git describe --tags --long
): - clang version:
- OS:
- Editor:
- Language client (and version):
If you use vim, you can filter them from vim like this:
function filter_diagnostics_pyright(diagnostic)
-- Allow kwargs to be unused, sometimes you want many functions to take the
-- same arguments but you don't use all the arguments in all the functions,
-- so kwargs is used to suck up all the extras
if diagnostic.message == '"args" is not accessed' or
diagnostic.message == '"kwargs" is not accessed' then
return false
end
-- Allow variables starting with an underscore
if string.match(diagnostic.message, '"_.+" is not accessed') then
return false
end
return true
end
function filter_diagnostics(diagnostic)
if diagnostic.source == "Pyright" then
return filter_diagnostics_pyright(diagnostic)
end
if diagnostic.source == "latex-build" then
return filter_diagnostics_texlab(diagnostic)
end
return true
end
function custom_on_publish_diagnostics(a, params, client_id, c, config)
params.diagnostics = vim.tbl_filter(filter_diagnostics, params.diagnostics)
vim.lsp.diagnostic.on_publish_diagnostics(a, params, client_id, c, config)
end
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
custom_on_publish_diagnostics, {})
This is for Python, but you get the idea.