From 03112efb44874f7a9bbd55ae7fd8d2ea483ad6fc Mon Sep 17 00:00:00 2001 From: theamodhshetty Date: Fri, 27 Feb 2026 11:56:27 +0530 Subject: [PATCH 1/2] Improve JUnit reporter metadata for CI parsers --- CHANGELOG.md | 5 +++++ .../SwiftLintFramework/Reporters/JUnitReporter.swift | 4 ++-- .../Resources/CannedJunitReporterOutput.xml | 10 +++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3348c4e3b1..eaf248fb51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,11 @@ [ahmadalfy](https://github.com/ahmadalfy) [#6499](https://github.com/realm/SwiftLint/issues/6499) +* Add `name` on JUnit `testsuite` output and include a `line` attribute on + each `failure` element for better CI parser compatibility. + [theamodhshetty](https://github.com/theamodhshetty) + [#6161](https://github.com/realm/SwiftLint/issues/6161) + ### Bug Fixes * Ensure that disable commands work for `redundant_nil_coalescing` rule. diff --git a/Source/SwiftLintFramework/Reporters/JUnitReporter.swift b/Source/SwiftLintFramework/Reporters/JUnitReporter.swift index c40066fb18..0b9348c86e 100644 --- a/Source/SwiftLintFramework/Reporters/JUnitReporter.swift +++ b/Source/SwiftLintFramework/Reporters/JUnitReporter.swift @@ -16,7 +16,7 @@ struct JUnitReporter: Reporter { return """ - \t + \t \(violations.map(testCase(for:)).joined(separator: "\n")) \t @@ -32,7 +32,7 @@ struct JUnitReporter: Reporter { return """ \t\t - \t\t\t\(message) + \t\t\t\(message) \t\t """ } diff --git a/Tests/FileSystemAccessTests/Resources/CannedJunitReporterOutput.xml b/Tests/FileSystemAccessTests/Resources/CannedJunitReporterOutput.xml index 5c75dced0d..8ac78d2c4d 100644 --- a/Tests/FileSystemAccessTests/Resources/CannedJunitReporterOutput.xml +++ b/Tests/FileSystemAccessTests/Resources/CannedJunitReporterOutput.xml @@ -1,17 +1,17 @@ - + - Warning:Line:1 + Warning:Line:1 - Error:Line:1 + Error:Line:1 - Error:Line:1 + Error:Line:1 - Error:Line:0 + Error:Line:0 \ No newline at end of file From d111ba1fdfadfc051ef3a8f1b0379d8a0a74002e Mon Sep 17 00:00:00 2001 From: theamodhshetty Date: Fri, 27 Feb 2026 20:29:15 +0530 Subject: [PATCH 2/2] fix(junit): add root suite name and remove failure line attr --- CHANGELOG.md | 4 ++-- .../SwiftLintFramework/Reporters/JUnitReporter.swift | 4 ++-- .../Resources/CannedJunitReporterOutput.xml | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaf248fb51..fad8c57bea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,8 +25,8 @@ [ahmadalfy](https://github.com/ahmadalfy) [#6499](https://github.com/realm/SwiftLint/issues/6499) -* Add `name` on JUnit `testsuite` output and include a `line` attribute on - each `failure` element for better CI parser compatibility. +* Add `name="SwiftLint"` to JUnit `testsuites` and `testsuite` output for + better CI parser compatibility. [theamodhshetty](https://github.com/theamodhshetty) [#6161](https://github.com/realm/SwiftLint/issues/6161) diff --git a/Source/SwiftLintFramework/Reporters/JUnitReporter.swift b/Source/SwiftLintFramework/Reporters/JUnitReporter.swift index 0b9348c86e..0ac1d8f689 100644 --- a/Source/SwiftLintFramework/Reporters/JUnitReporter.swift +++ b/Source/SwiftLintFramework/Reporters/JUnitReporter.swift @@ -15,7 +15,7 @@ struct JUnitReporter: Reporter { return """ - + \t \(violations.map(testCase(for:)).joined(separator: "\n")) \t @@ -32,7 +32,7 @@ struct JUnitReporter: Reporter { return """ \t\t - \t\t\t\(message) + \t\t\t\(message) \t\t """ } diff --git a/Tests/FileSystemAccessTests/Resources/CannedJunitReporterOutput.xml b/Tests/FileSystemAccessTests/Resources/CannedJunitReporterOutput.xml index 8ac78d2c4d..db64bdf072 100644 --- a/Tests/FileSystemAccessTests/Resources/CannedJunitReporterOutput.xml +++ b/Tests/FileSystemAccessTests/Resources/CannedJunitReporterOutput.xml @@ -1,17 +1,17 @@ - + - Warning:Line:1 + Warning:Line:1 - Error:Line:1 + Error:Line:1 - Error:Line:1 + Error:Line:1 - Error:Line:0 + Error:Line:0 \ No newline at end of file