So I think the feature I really want is to flag something as “Won’t fix against this baseline”. When the project is then re-baselined, these issues would become “unresolved” issues. They are issues, but we haven’t got time to deal with them in this release, but in future we might deal with them. Currently we get so much “noise” as 100’s of new issues are flagged up, it becomes impossible to manage.
So scenarios where I would use this:
1. We fix a critical issue in some old code, but that then introduces a lower level issue which we aren’t concerned about at the moment. For example,
Statement s = new Statement(“Some SQL”);
s.execute();
this code flags up a critical issue that we aren’t closing resources. So we want to deal with that.
So it gets changed to:
try (Statement s = new Statement(“Some SQL”)) {
s.execute();
}
So the resource is now being auto closed and the issue has gone. But this change can then introduce a violation “Refactor this code to not nest more than 3 if/for/while/switch/try statements.”. This we aren’t worried about and I don’t want it flagged up on dashboard.
2. Someone refactors some old code, as they need to refactor old common functionality. E.g.
Before
myMethod1() {
doSomething();
print(“a”);
print(“b”);
print(“c”);
}
After, the refactoring
myMethod1() {
doSomething();
doPrinting();
}
doPrinting() {
print(“a”);
print(“b”);
print(“c”);
}
Any violations in the doPrinting() are flagged up as new, whereas they really are old.
3. Source was refactored, and a whole file removed. Later it was realised the file was still needed so was added back in. I’m assuming (haven’t tried it) – all rules against this file would be flagged as new.
4. A situation I had where byte code was not available during the analysis. Rules get closed down, and then get marked as new again.
5. Another real world case… removing “serializable” from a base class to try to fix cases of “Make "XXX" transient or serializable”. Then realising the base class has to be serializable, so adding it back in. All the “Make "XXX" transient or serializable” rules re-appear as new violations. They aren’t, they are just old violations re-appearing.