cppcheck-vs-addin icon indicating copy to clipboard operation
cppcheck-vs-addin copied to clipboard

Check files after save should show results from current file only

Open bhadreshdesai opened this issue 8 years ago • 8 comments
trafficstars

It will be a good enhancement to show cppcheck results from the currently saved file only when Check files after save option is selected. This will also increase save performance on large projects. This can be done by ignoring includes when analysisOnSavedFile is true in getCPPCheckArgs

bhadreshdesai avatar Mar 31 '17 09:03 bhadreshdesai

Checking C++ code without parsing includes is generally useless, in my opinion. Yes, it will be faster, but you'll be checking invalid code with unknown symbols for classes included from elsewhere. Only compilable code should be checked.

VioletGiraffe avatar Mar 31 '17 10:03 VioletGiraffe

I provided one possible solution. Other alternative is to filter the results for current file only. One or both options can be offered to the user in settings. When running the check on a project/solution I agree we must have all the includes. But when saving a file I want it to be very quick and show errors from the current files only.

bhadreshdesai avatar Mar 31 '17 10:03 bhadreshdesai

Yes, that's a good point. And I want it to be very quick, too, but it's just not possible to combine good speed with the quality of checks (at least not with cppcheck).

VioletGiraffe avatar Mar 31 '17 10:03 VioletGiraffe

I have fixed this locally and is working as expected for me. If you want I can send you my code. I checked the documentation for cppcheck and most of the checks will work without inclusion of headers. For e.g. Uninitialized variables, UnusedVar checks etc. This is a good compromise for me where I have 500+ projects in my solution and save was taking a bit longer. Also it was returning lots of errors from files that I am not changing. Thanks.

bhadreshdesai avatar Mar 31 '17 18:03 bhadreshdesai

  1. Excluding messages from other files is great, if you can commit it separately - please go ahead.
  2. Not using include paths is something I would like to see as an option, not an always-on feature. Can you do that?

VioletGiraffe avatar Mar 31 '17 19:03 VioletGiraffe

I will work on 2. to start with. Will create an option where user can select if they would like to exclude the include path. This is my first OSS contribution to I will need help with the contribution process.

bhadreshdesai avatar Apr 04 '17 07:04 bhadreshdesai

Is this option available today? show cppcheck results from the currently saved file only when Check files after save option is selected

Thanks

Nir-Az avatar Aug 09 '20 15:08 Nir-Az

@Nir-Az, this isn't implemented but it can be done in principle.

VioletGiraffe avatar Aug 09 '20 19:08 VioletGiraffe