cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

fix #13333: better handling when source file is repeated in compile_commands.json

Open ludviggunne opened this issue 9 months ago • 8 comments

ludviggunne avatar Apr 15 '25 17:04 ludviggunne

We should have opt-in/opt-out CLI options so this behavior can be overridden. And it should probably be disabled by default (I feel like there was already a discussion where I was flip-flopping on this).

We should also somehow inform the user when a file is omitted because it is a duplicate (within --check-config?). This is something I need to do in a different scope but haven't gotten to it yet.

firewave avatar Apr 15 '25 17:04 firewave

We should also somehow inform the user when a file is omitted because it is a duplicate (within --check-config?). This is something I need to do in a different scope but haven't gotten to it yet.

Sorry, I overlooked that there is already a message.

And some Python tests for this need to be added.

firewave avatar Apr 15 '25 17:04 firewave

Something for a future improvement.

Some of the settings could be sanitized so they are not different if the order is different. Please do not do this for the defines because they need to be reworked from the bottom up first (simplecpp et al) and that will probably implicitly fix that.

firewave avatar Apr 15 '25 17:04 firewave

Some of the settings could be sanitized so they are not different if the order is different. Please do not do this for the defines because they need to be reworked from the bottom up first (simplecpp et al) and that will probably implicitly fix that.

The hash should be dependent of the order of defines/undefs now.

ludviggunne avatar Apr 16 '25 05:04 ludviggunne

We should have opt-in/opt-out CLI options so this behavior can be overridden. And it should probably be disabled by default (I feel like there was already a discussion where I was flip-flopping on this).

What's a scenario where you'd want it to be disabled?

ludviggunne avatar Apr 16 '25 05:04 ludviggunne

What's a scenario where you'd want it to be disabled?

Where it omits files from the analysis it should not (i.e. bugs). The existing handling of duplicates in other areas has been lacking so there should be a way to disable it. There will be more stuff added to FileSettings in the future.

firewave avatar Apr 16 '25 06:04 firewave

So a flag to disable all de-duplication?

ludviggunne avatar Apr 16 '25 08:04 ludviggunne

So a flag to disable all de-duplication?

Just for this added logic as it many parts which make up the hash.

The existing de-duplication is based on the (real) path being unique so that will only miss de-duplication but not accidentally omit files it should not because it is just a single value to compare.

firewave avatar Apr 16 '25 08:04 firewave