@@ -56,6 +56,41 @@ public override IEnumerable<IIssue> ReadIssues(
5656 return result ;
5757 }
5858
59+ /// <summary>
60+ /// Normalizes XML content by removing XML formatting indentation while preserving intentional structure.
61+ /// </summary>
62+ /// <param name="content">The XML content to normalize.</param>
63+ /// <returns>The normalized content.</returns>
64+ private static string NormalizeXmlContent ( string content )
65+ {
66+ if ( string . IsNullOrEmpty ( content ) )
67+ {
68+ return string . Empty ;
69+ }
70+
71+ // Split by lines, trim each line to remove XML indentation, then rejoin
72+ var lines = content . Split ( [ '\r ' , '\n ' ] , StringSplitOptions . None ) ;
73+ var normalizedLines = new List < string > ( ) ;
74+
75+ foreach ( var line in lines )
76+ {
77+ // Trim leading and trailing whitespace (including tabs) from each line
78+ var trimmedLine = line . Trim ( ) ;
79+ normalizedLines . Add ( trimmedLine ) ;
80+ }
81+
82+ // Join lines back together and clean up multiple consecutive empty lines
83+ var result = string . Join ( "\n " , normalizedLines ) ;
84+
85+ // Remove leading and trailing empty lines
86+ result = result . Trim ( '\n ' ) ;
87+
88+ // Normalize multiple consecutive newlines to double newlines maximum
89+ result = Regex . Replace ( result , @"\n{3,}" , "\n \n " ) ;
90+
91+ return result ;
92+ }
93+
5994 /// <summary>
6095 /// Recursively processes a testsuite element and its nested testsuites and testcases.
6196 /// </summary>
@@ -78,7 +113,7 @@ private void ProcessTestSuite(XElement testSuite, List<IIssue> result, IReposito
78113 // Process failures
79114 foreach ( var failure in testCase . Elements ( "failure" ) )
80115 {
81- var issue = this . ProcessCppLintFailure ( failure , className , testName , IssuePriority . Error , repositorySettings ) ;
116+ var issue = this . ProcessCppLintFailure ( failure , testName , IssuePriority . Error , repositorySettings ) ;
82117 if ( issue != null )
83118 {
84119 result . Add ( issue ) ;
@@ -88,7 +123,7 @@ private void ProcessTestSuite(XElement testSuite, List<IIssue> result, IReposito
88123 // Process errors
89124 foreach ( var error in testCase . Elements ( "error" ) )
90125 {
91- var issue = this . ProcessCppLintFailure ( error , className , testName , IssuePriority . Error , repositorySettings ) ;
126+ var issue = this . ProcessCppLintFailure ( error , testName , IssuePriority . Error , repositorySettings ) ;
92127 if ( issue != null )
93128 {
94129 result . Add ( issue ) ;
@@ -103,51 +138,15 @@ private void ProcessTestSuite(XElement testSuite, List<IIssue> result, IReposito
103138 }
104139 }
105140
106- /// <summary>
107- /// Normalizes XML content by removing XML formatting indentation while preserving intentional structure.
108- /// </summary>
109- /// <param name="content">The XML content to normalize.</param>
110- /// <returns>The normalized content.</returns>
111- private static string NormalizeXmlContent ( string content )
112- {
113- if ( string . IsNullOrEmpty ( content ) )
114- {
115- return string . Empty ;
116- }
117-
118- // Split by lines, trim each line to remove XML indentation, then rejoin
119- var lines = content . Split ( new [ ] { '\r ' , '\n ' } , StringSplitOptions . None ) ;
120- var normalizedLines = new List < string > ( ) ;
121-
122- foreach ( var line in lines )
123- {
124- // Trim leading and trailing whitespace (including tabs) from each line
125- var trimmedLine = line . Trim ( ) ;
126- normalizedLines . Add ( trimmedLine ) ;
127- }
128-
129- // Join lines back together and clean up multiple consecutive empty lines
130- var result = string . Join ( "\n " , normalizedLines ) ;
131-
132- // Remove leading and trailing empty lines
133- result = result . Trim ( '\n ' ) ;
134-
135- // Normalize multiple consecutive newlines to double newlines maximum
136- result = Regex . Replace ( result , @"\n{3,}" , "\n \n " ) ;
137-
138- return result ;
139- }
140-
141141 /// <summary>
142142 /// Processes a cpplint test failure or error element and creates an issue.
143143 /// </summary>
144144 /// <param name="failureElement">The failure or error XML element.</param>
145- /// <param name="className">The test class name.</param>
146145 /// <param name="testName">The test name.</param>
147146 /// <param name="priority">The issue priority.</param>
148147 /// <param name="repositorySettings">Repository settings.</param>
149148 /// <returns>The created issue or null if the failure should be ignored.</returns>
150- private IIssue ProcessCppLintFailure ( XElement failureElement , string className , string testName , IssuePriority priority , IRepositorySettings repositorySettings )
149+ private IIssue ProcessCppLintFailure ( XElement failureElement , string testName , IssuePriority priority , IRepositorySettings repositorySettings )
151150 {
152151 var message = failureElement . Attribute ( "message" ) ? . Value ?? string . Empty ;
153152 var type = failureElement . Attribute ( "type" ) ? . Value ?? string . Empty ;
@@ -188,12 +187,13 @@ private IIssue ProcessCppLintFailure(XElement failureElement, string className,
188187 RegexOptions . Multiline ) ;
189188 if ( lineMatch . Success && int . TryParse ( lineMatch . Groups [ 1 ] . Value , out var lineNum ) )
190189 {
191- var pathValidation = ValidateFilePath ( testName , repositorySettings ) ;
192- if ( pathValidation . Valid )
190+ var ( valid , filePath ) = ValidateFilePath ( testName , repositorySettings ) ;
191+ if ( valid )
193192 {
194- issueBuilder = issueBuilder . InFile ( pathValidation . FilePath , lineNum , null ) ;
193+ issueBuilder = issueBuilder . InFile ( filePath , lineNum , null ) ;
195194 }
196195 }
196+
197197 // Also check for simple line number pattern without the category/subcategory format
198198 else
199199 {
@@ -207,10 +207,10 @@ private IIssue ProcessCppLintFailure(XElement failureElement, string className,
207207 // Only treat as file if the test name doesn't contain hyphens (which are common in rule names)
208208 if ( ! testName . Contains ( '-' ) && ! testName . Contains ( '_' ) )
209209 {
210- var pathValidation = ValidateFilePath ( testName , repositorySettings ) ;
211- if ( pathValidation . Valid )
210+ var ( valid , filePath ) = ValidateFilePath ( testName , repositorySettings ) ;
211+ if ( valid )
212212 {
213- issueBuilder = issueBuilder . InFile ( pathValidation . FilePath , simpleLineNum , null ) ;
213+ issueBuilder = issueBuilder . InFile ( filePath , simpleLineNum , null ) ;
214214 }
215215 }
216216 }
0 commit comments