ccls icon indicating copy to clipboard operation
ccls copied to clipboard

How to suppress error report for unused function or variable?

Open harvey-wei opened this issue 3 years ago • 1 comments

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

  1. Select these example steps,
  2. Delete them,
  3. 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):

harvey-wei avatar Feb 16 '22 12:02 harvey-wei

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.

MarcelRobitaille avatar Nov 03 '23 20:11 MarcelRobitaille