Closed 3flex closed 3 weeks ago
Attention: Patch coverage is 93.33333%
with 1 lines
in your changes are missing coverage. Please review.
Project coverage is 84.71%. Comparing base (
19b1784
) to head (e721278
).
Files | Patch % | Lines |
---|---|---|
...io/gitlab/arturbosch/detekt/core/KtFileModifier.kt | 80.00% | 0 Missing and 1 partial :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This would also help with #2560. Now we will have the initial state of the file and the after so create a
patch
should be really easy.The
patch
should help to implement autocorrect for the compiler plugin.
I had the same thought.
Breaking change - instead of changing the KtFile contents directly, a rule implementing autocorrect must create a copy of the file text (or the already modified text, in case another rule has applied autocorrect already, so those changes are not overwritten), modify it then save the updated text to
KtFile.modifiedText
.They will also need to take a copy of the original file path, since the copy created by
createPhysicalFile
only allows saving the file name but not the full path.This is the only way to make autocorrect work with a read only KtFile - by reading and storing separate copies of the file's text.
Why do this? Because it allows for some simplification and refactoring of the detekt core and easier handling of file paths (for the majority of rules that don't implement autocorrect).
This has been tested against the new & updated tests in #7204.