Always update the baseline if it exists#4445
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4445 +/- ##
=========================================
Coverage 84.34% 84.34%
- Complexity 3299 3300 +1
=========================================
Files 473 473
Lines 10532 10534 +2
Branches 1885 1885
=========================================
+ Hits 8883 8885 +2
Misses 671 671
Partials 978 978
Continue to review full report at Codecov.
|
|
@BraisGabin shall we also explain the new behavior in the FAQ section on the homepage? |
|
I don't think so. There wasn't any explanation about when the baseline was created or not. And what this PR does have more sense than the previous behavior. |
| if (baseline.isNotEmpty() || exists) { | ||
| baselineFile.parent?.let { Files.createDirectories(it) } | ||
| BaselineFormat().write(baseline, baselineFile) | ||
| } |
There was a problem hiding this comment.
If the content stays the same, always writing to the file will cause the Detekt Gradle task to always not up-to-date.
Do you think it's worth it to not update the file when the content does not change?
There was a problem hiding this comment.
The content is always the same so it doesn't affect gradle and the up-to-date. But I'm going to do the check so we avoid an unnecessary write to disk.
There was a problem hiding this comment.
Done, I think that the code now is even better.
There was a problem hiding this comment.
Ah nice. I had thought the file last access timestamp is considered in the input cache key calculation.
|
Is this a notable change? I feel it as a bug-fix. |
|
I think it is - There could be additional tooling that reads those baseline.xml and generates a customized report (My previous team does that) |
If you have a module with some issues in the baseline and you fix all of them, when you update the baseline detekt does nothing. This PR fixes that. If there is a baseline file, we always update it.
This PR also fixes a really annoying flaky test related with baseline.
Fix #3736