-
-
Notifications
You must be signed in to change notification settings - Fork 755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reformatting baseline XML causes baselines to fail #3316
Comments
Thanks for experimenting and reporting this bug to this repo. |
I reproduced this issue in my end. It happens when you format this: <ID>something</ID> to this <ID>
something
</ID> But, are they really the same xml? We use In android, for example, this changes aren't important but that seems an Android choice. They decided to add a trim after reading the xml value. We could add that trim too but I don't think that we should. |
@BraisGabin okay, that's a different story (if true). Why is Android Studio then adding line breaks? Does it consider the max line length whilst reformatting the code? |
I just checked and both IntelliJ and AS reformat long lines of xmls... maybe we should configure something in our parser so it's a bit smarter? |
You would need to place a |
No really. This is an issue too: <ID>fun foo</ID> and <ID>
fun
foo
</ID> And this is kind of format is done by IntelliJ and AS too. |
Okay, that's weird too. I'm not sure, whether handling this edge case should be done inside the core baseline parser. The mentioned case could happen for function signatures in the baseline xml file. Let's consider the following code. This could easily be reformatted. <ID>ComplexMethod:DetektExtension.kt$DetektExtension$fun convertToArguments(): MutableList<String></ID> To my knowledge this is the first report about having such an issue with the baseline xml in detekt. |
Yes. It's really weird. For that reason I was thinking if the formater could have a "flag" or something so we don't need to implement the "unformat" code. |
Just to make sure that I could correctly follow. With formatter you mean the IDEA one, right? |
My bad! I didn't use the correct word there. I mean: "For that reason I was thinking if |
Thanks for the update. This clears out some confusion. |
I'll try it and create pr if it works. If not, I'll update here with the new information. |
This issue is stale because it has been open 90 days with no activity. Please comment or this will be closed in 7 days. |
What's the status here? Should we add a "help wanted" to this? |
Yes. I did nothing about this at the end. |
yeah this is irritating |
I implemented #4335. I know that it doesn't fix the core issue here but it's better than actual behaviour. It doesn't fix the core issue because I'm not sure that this is a detekt's issue. <ID>fun foo</ID> and <ID>
fun
foo
</ID> are sematically different. or at least that's what I understand reading the xml specification. If someone can show me something in the specification of xml that says the opposite we could try to fix it. But I think that this is not an issue in detekt. It is an issue in IntelliJ breaking the xml sematics. So I would vote to close this issue as soon as #4335 is merged. I think that |
Clearly this is annoying. But this is an Android Studio's issue. They are changing the meanning of the xml. They are breaking the standard. We tried to fix this once but, for detekt, an space before I'm going to close this as "wont-fix" because it's AS fault. But I think that for detekt 2.0 we should stop ussing |
@mtrakal I would suggest opening an issue on AS issue tracker as well |
Expected Behavior
XML should be mostly whitespace-agnostic. If the IDE reformats the XML file to pretty-print it, the baselines should still function.
Observed Behavior
Every baseline which gets pretty-printed onto multiple lines fails to function.
Steps to Reproduce
Generate a baseline for a huge project with ./gradlew detektBaseline
Allow the IDE or its git commit screen to reformat code.
Attempt to run ./gradlew detekt
The Gradle build fails with code smells wherever reformatting occurred.
Context
I was attempting to integrate Detekt into our Android Studio project and couldn't figure out why the detekt baseline kept breaking after I checked in code. It was that the Git Commit dialog inside Android Studio had Reformat Code checked. I was pulling my hair out as it worked each time before checking in.
Your Environment
The text was updated successfully, but these errors were encountered: