Fix unused C++ #include directives across solution

I have used the single file quick fix to remove unused #include directives and wanted to do the same across a whole solution. Right clicking on a individual quick fix let me do a find in solution for this issue, of which I have 2868. However I can't find a way to apply the fix to all the items that were found. I'm assuming I'm missing something obvious but after a lot of searching and reading the docs I can't find anything.

Version 16.3.2

0
4 comments
Avatar
Permanently deleted user

Hello David,

Unfortunately this hasn't been implemented yet. You can vote for https://youtrack.jetbrains.com/issue/RSCPP-18901 to receive an update when this gets implemented. But please also note that performing a bulk removal of unused include directives might break your code, because R++ analyzes redundant includes in a header only in the context of a single .cpp file (so if another .cpp file depends on these includes, it might stop compiling).

Thanks for your feedback!

0
Avatar
Permanently deleted user

OK, I'm a bit surprised, maybe I'm a bit unusual but my main reason for buying a tool like this is to do bulk changes. If I only had a few files I could do things by hand.

Anyway, in general I always assume a bulk change of any sort can break things. I would always do a full build and run all tests after any such change. My view is that as long as the time to fix the breakage, which in the case of accidentally removing a header file which should have been left is trivial, is less than doing all the changes by hand I still win.

It may be useful if you could make it clearer in the documentation that some quick fixes can not be applied in a larger scope. Ideally a list of those that can and those that can't would be ideal.

Anyway thanks for the response.

0
Avatar
Permanently deleted user

We agree, that is one important area of future work for us. For reference, the list of available bulk fixes is at https://www.jetbrains.com/help/resharper/2016.3/Code_Analysis__Fix_in_Scope.html#CPP

0
Avatar
Permanently deleted user

David,

R++ 2017.1 can fix common issues (including unused includes) across files/projects/solution via code cleanup. If you decide to try it, please use the "Cleanup Code" action (e.g. from a context menu in solution explorer) instead of using the option in Alt-Enter menu, since the latter might cause memory issues.

Thanks!

0

Please sign in to leave a comment.