I agree with “clean as you code” as the basic approach.
However, I also want to go just a little bit further and tackle some legacy issues as I go as otherwise the remaining issues will never be tackled if the code never changes.
Ultimately I want my whole project to be at the level new code is.
I am doing this one issue at a time and trying to sneak changes in wherever I can without compromising things.
In fact as a result of tackling this case I found/did several things:
- a whole set of test code had not been imported when it was copy-pasted from another project.
- branch coverage was adversely affected by assertions - I found a way around this see Disable branch coverage for assertions?
- I also added an RAII class for the directory in this case.
- and added some test cases to improve coverage
For me it has been positive experience.
However, I am very keen on static analysis and improving old code. Others may be more easily put off.
But this task was not the 1m fix sonar suggested because of the interactions.
So I am interested in other people’s perspectives on this.