File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ function Normalize-Config {
1919
2020 $ext = [System.IO.Path ]::GetExtension($file ).TrimStart(' .' )
2121
22+ if ($ext -eq ' xml' ) {
23+ Normalize- XmlFile $file
24+ return
25+ }
26+
2227 switch ($ext ) {
2328 { $_ -in @ (' yaml' , ' yml' ) } {
2429 # For YAML files, preserve structure and sort within sections
@@ -72,6 +77,27 @@ function Normalize-Config {
7277 }
7378}
7479
80+ # Helper function to normalize XML files: strip leading spaces and sort <rule ref=.../> lines
81+ function Normalize-XmlFile {
82+ param ([string ]$Path )
83+ $lines = Get-Content $Path
84+ $rules = @ ()
85+ $output = @ ()
86+ $endTag = $null
87+
88+ foreach ($line in $lines ) {
89+ $trimmed = $line.TrimStart ()
90+ if ($trimmed -match ' ^<rule ref=' ) {
91+ $rules += $trimmed
92+ } elseif ($trimmed -match ' ^</ruleset>' ) {
93+ $endTag = $trimmed
94+ } else {
95+ $output += $trimmed
96+ }
97+ }
98+ $output + ($rules | Sort-Object ) + $endTag
99+ }
100+
75101function Compare-Files {
76102 param (
77103 [string ]$expectedDir ,
You can’t perform that action at this time.
0 commit comments