2

After 3 years on VS, I decided to try Visual Code with clangd for a bit. I work for a big company with huge legacy code and technical debt so I often have to work with some old code and not so modern C++ and more often than not I must read a lot of code rather than write some.

Visual code's code analysis finds hundreds of "Problems" aka warnings fill my entire page which reduces code visibility. Minimap is unusable as 80% is highlighted in yellow.

Is there a way to filter the code analysis so that it only checks and shows warning for the code I just wrote ?

I tried tweaking the user settings of the Code Analysis / clang tidy

Krustibat
  • 81
  • 5
  • look at the problems and fix the problems that are relevant, most of them are, maybe you fix some bugs in the meantime – rioV8 Aug 30 '23 at 11:21

2 Answers2

1

I'm not aware of a way to do this currently, but this has been raised in the clangd issue tracker here:

https://github.com/clangd/clangd/issues/822

Based on this comment, the conclusion seems to be that such filtering is probably best implemented on the client side, i.e. in VSCode or a VSCode plugin rather than in clangd or clang-tidy.

HighCommander4
  • 50,428
  • 24
  • 122
  • 194
0

I think I managed to solve it in vscode press F1 then type : clangd: Open project configuration file it should create an empty file for you and then past this inside

Diagnostics:
  UnusedIncludes: Strict
  ClangTidy:
    Remove: '*'

finally just restart the server to take the changes into account from F1 -> clangd: restart server

All this only shows the problem I just wrote.

Krustibat
  • 81
  • 5
  • Note that this will disable all diagnostics in a particular category (those produced by the clang-tidy static analysis tool). If you write new code for which clang-tidy would issue diagnostics, this also suppresses those. – HighCommander4 Sep 01 '23 at 19:56