Conversation
|
Our controller XMLs are a wild mixture of tabs, spaces, weird formatting issues, etc. This makes sure that our XML files are always formatted properly. |
daschuer
left a comment
There was a problem hiding this comment.
Does this format whole files?
I think due to our mixture of styles this will produce unreadable commits, this is even worse than the style inconsistency between different mappings, because a change is hidden into a big diff.
I think we should close this PR ... or disable this.
.. or can we enable it only for new files, or can we add all existing files to an ignore list or something?
Yes. The main issue with our XML files is broken indentation, which can't be fixed with a diff-based approach.
To be honest, I hardly look at diffs of XML files anymore, because they are not really readable anyway, partly do to the nature of the XML syntax and partly due to mixing tabs and spaces within the same file. What do we use XMLs for:
The latter two are not affected by this PR because they use a different file extension some are autogenerated anyway. The two former ones are either long lists of MIDI assignments or skin markup, so I think it's not that bad if some commits produce bigger diffs IMHO. I think this is a small price to pay for eventually vastly more readable XMLs (and we also get the XML syntax check for free). |
|
The bad thing here is that you change a single line and the whole file is reformated producing a SINGLE commit hiding the real change So we must not enforce it via a pre-commit hook. I see two alternatives.
I will not spend my time to review 2, because there is no benefit. All XML code is already valid. We can keep this hook disabled and ask mapping contributors to run it in demand if a reviewer is willing to review it. But it is unlikely and not necessary as you stated above. We may also apply it on new files. |
409d251 to
b5fc50b
Compare
|
I set this hook to manual, so it won't run automatically but we can still ask contributors to run it manually. I think this is ready to merge now. Regarding 2): I'd be in favor of running it on all XML files in this repo in a single commit and then enable this hook afterwards.
In that case there is no need to review this commit because it only contains reformattings. The benefit is better readability through proper indentation and less headaches when editing these files. When editing the controller files for #3108, I had to disable all kinds of stuff in my editor, because some files use DOS line endings (or even a mixture of both UNIX and DOS line endings) and just touching the file already caused huge diffs. Same goes for missing newlines at EOF and stuff like that. |
|
Unfortunately the error message looks not that nice if there is an xml issue: can we catch that without crashing? |
|
The hook fails to format the style block. The result is: |
|
The same happens for comments: |
|
Did you consider to use two space indent? This would make the style consistent with QT's UI files. |
|
yes, please let's stick to 2-space indent. Just one isn't enough to navigate skin templates IMO. |
This is currently using 4 spaces, but I can reduce it to 2 if you prefer. |
|
We have 2 spaces in all skin files I worked on so far and this is very confortable to work with (except Shade where indentation is ... "variable" ;). |
|
I think I worked around the issues, please retest. |
|
There is still one an issue with Variables: |
|
The rest works already nice. Thank you. |
|
How do I activate the new hook? |
I rewrote that part to always remove whitespace around
|
diff --git a/res/skins/LateNight/mixer.xml b/res/skins/LateNight/mixer.xml
@@ -1,6 +1,8 @@
+<?xml version="1.0" ?>
<Template>
- <SetVariable name="BtnType"><Variable name="TopRegion_BtnType"/></SetVariable>
-
+ <SetVariable name="BtnType">
+ <Variable name="TopRegion_BtnType"/>
+ </SetVariable>
<WidgetGroup>
<SizePolicy>max,me</SizePolicy>
<Layout>horizontal</Layout>
@@ -9,35 +11,32 @@
<BindProperty>visible</BindProperty>
</Connection>
<Children>
-
<WidgetGroup>
<ObjectName>MixerContainer</ObjectName>
<SizePolicy>min,me</SizePolicy>
<Layout>horizontal</Layout>
<Children>
-
<Template src="skin:/mixer/mixer_decks.xml"/>
-
<Template src="skin:/mixer/mixer_master_headphone.xml"/>
-
</Children>
- </WidgetGroup><!-- MixerContainer -->
-
+ </WidgetGroup>
+ <!-- MixerContainer -->
</Children>
- </WidgetGroup><!-- show_mixer -->
-
+ </WidgetGroup>
+ <!-- show_mixer -->
<WidgetGroup>
<SizePolicy>max,me</SizePolicy>
<Layout>horizontal</Layout>
<Connection>
<ConfigKey persist="true">[Master],show_mixer</ConfigKey>
- <Transform><Not/></Transform>
+ <Transform>
+ <Not/>
+ </Transform>
<BindProperty>visible</BindProperty>
</Connection>
<Children>
-
<WidgetGroup>
- <ObjectName></ObjectName>
+ <ObjectName/>
<SizePolicy>min,me</SizePolicy>
<Layout>vertical</Layout>
<Connection>
@@ -45,14 +44,12 @@
<BindProperty>visible</BindProperty>
</Connection>
<Children>
-
<WidgetGroup>
<!-- width set in qss -->
<ObjectName>CompactDecksCenterSpacer</ObjectName>
</WidgetGroup>
-
<WidgetGroup>
- <ObjectName></ObjectName>
+ <ObjectName/>
<SizePolicy>min,me</SizePolicy>
<Layout>vertical</Layout>
<Connection>
@@ -63,10 +60,9 @@
<Template src="skin:/mixer/vumeters_compact.xml"/>
</Children>
</WidgetGroup>
-
</Children>
- </WidgetGroup><!-- !show_mixer -->
-
+ </WidgetGroup>
+ <!-- !show_mixer -->
</Children>
</WidgetGroup>
</Template>Besides the format repair this hook unfortunately also alters some intended formats useful for navigation
Considering this hook will mostly be run manually to fix remarkably malformed files, it may be hard to pick only desired fixes with |
I'll have a look.
I actually think that's okay. Just put it in the line above the closing tag.
For
This is done automatically as per the XML standard. I can't remove all closed nodes (otherwise it would also remove |
I just wish to keep the
👍 |
|
I dropped the custom script since preserving blank lines was not possible and I didn't fine a way to work around that. Instead, this now uses the Downside: the CSS formatting in the stylesheet might not be indented correctly, but I think we should treat that as legacy anyway and move that stuff into the QSS files if possible. Please test again. |
|
This PR is marked as stale because it has been open 90 days with no activity. |
4557c08 to
3aefad5
Compare
|
@ronso0 Any comments? Is something like this desired? |
|
ping |
|
sry, this was not on the top of my list and it requires some time to evaluate. I'll check this tonight or tomorrow, okay? |
Don't worry, if you have stuff to do for release it's fine to prioritize that. Just wanted to make sure this isn't forgotten ;-) |
|
🔖 Saved ; ) |
|
Btw, I also experimented with a CSS formatter hook for the *.qss files, but unfortunately csscomb is buggy and installing a custom version from Git does not work. So that is on hold for now. |
|
This PR is marked as stale because it has been open 90 days with no activity. |
|
@Holzhaus are you still interesting in completing this? Personally, I'm keen to enforce some linting, even if we loose some current style (e.g the compact form is IMO not a big deal, as long as it remains consistent). Other point for experience with introducing this kind of linting enforcement on already existing code base is the amount of noise it generates as soon as somebody make a small change, as it will trigger the hook. Usually, my recommendation is to ask contributor to make two commits (e.g one How would you feel about running a |
I prefere that. I had recently to deal with many conflicts because of the introduced CMake reformating. The conflict resolution are normally not well tested. Here we are touching many more files and we have 55 PRs open changing them. So please let's not put this hassle on us here as well. |
|
Yeah, that a good point. Is this ready for merge once the conflict is resolved then? |
|
Marking as draft for now, but feel free to make ready once you've had time to solve the conflict! |
No description provided.