danmar/cppcheck — pull request #403 by akalenuk (2014-08-18 15:13:22+00:00)
Title: Sorting error list rarest first - proposition and demo implementation

Hi!

I want to propose a feature. When you run Cppcheck on some big pile of an old code, you usually get a lot of warnings mostly regarding style or performance. Most of them are seemingly unimportrant, but some are extremely helpful. Things like calling sizeof for sizeof, or logical disjunction which is always true. It is not easy to extract them from tons of other warnings, but they are definitely more significant than most of the other style issues.

Luckily they don't occure very often. So my idea is to sort the messages by the rate of their id occurencies. This way the rarest warnings would come on top of the list where you can spot them easily. I think this might be very helpful in some occasions.

My implementation, proposed in this pull request, introduces new command line argument `--rarest-first`. With this argument the messages are not being written into std::err right away, but instead stored in a map and only when all gathered - sorted and printed. Without this argument given, everything works exactly as before.

I've tested it on both xml and usual output with single and several jobs and it works fine. It doesn't work with the `--errorlist` feature, but I suppose it shouldn't.

What do you think?