SonarQube SonarSwift插件在解析Xcode9生成的Coverage文件时出现异常
SonarQube SonarSwift plugin exception when parsing Coverage file generated by Xcode 9
尝试将覆盖率报告推送到 SonarQube 服务器时,我在使用 SonarQube > SonarSwift 插件时遇到错误。
我使用 Xcode 命令行生成报告:
xcodebuild test -enableCodeCoverage YES -scheme iOS_Template -workspace iOS_Template.xcworkspace -destination 'platform=iOS Simulator,name=iPhone X'
当我 运行 sonar-scanner
扫描代码并上传报告时,我收到以下错误:
INFO: Parse coverage report
(DerivedData/iOS_Template/Build/ProfileData/DDA1A82C-EB41-4E45-8DCF-428D3E879067/Coverage.profdata)
ERROR: Can't parse coverage report file
(DerivedData/iOS_Template/Build/ProfileData/DDA1A82C-EB41-4E45-8DCF-428D3E879067/Coverage.profdata).
No coverage information will be saved.
java.lang.IllegalStateException: Can not parse line: HƢ�F
_T0SS17iOS_TemplateTestsE11isValidatedSbAA10ValidationO10validation_tF�.�������k(_T09Alamofire12TaskDelegateC10urlSessionySo10URLSessionC_So0fB0C4taskySo11InputStreamCSgc011needNewBodyI0t3��6K�2@_T09Alamofire14SessionManagerC5retrySbAA7RequestC383��J��Z8_T09Alamofire7AFErrorO31ResponseValidationFailureReasonO22acceptableContentTypesSaySSGSgf6(��W��N
[...similar set of unknown characters...]
at com.sonar.swift.plugin.B.A(Unknown Source)
at com.sonar.swift.plugin.B.A(Unknown Source)
at java.util.Optional.ifPresent(Optional.java:159)
at com.sonar.swift.plugin.B.A(Unknown Source)
at com.sonar.swift.plugin.B.A(Unknown Source)
at com.sonar.swift.plugin.B.A(Unknown Source)
at com.sonar.swift.plugin.D.A(Unknown Source)
at com.sonar.swift.plugin.D.execute(Unknown Source)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
.....
我检查了 Sonarswift 插件,它看起来没有支持 XCode9+ 的线索(我的 Xcode 版本是 Xcode 9.2),想知道它是否导致异常
看看这个 SonarQube documentation 页面。在将输出发送到 SonarQube 之前,您必须翻译输出:
xcodebuild -scheme <schemeName> -enableCodeCoverage YES -derivedDataPath . clean build test
xcrun llvm-cov show -instr-profile=Build/Intermediates/CodeCoverage/Coverage.profdata <path to instrumented executable> > <coverage report file>
同时检查您的 sonar.swift.coverage.reportPath 设置。该文档还有一个 link 示例项目。
事实证明,通过向 'generate' 添加一个命令来解决 SonarSwift 加载的覆盖率报告文件。
命令是xcrun llvm-cov show -instr-profile
尝试将覆盖率报告推送到 SonarQube 服务器时,我在使用 SonarQube > SonarSwift 插件时遇到错误。 我使用 Xcode 命令行生成报告:
xcodebuild test -enableCodeCoverage YES -scheme iOS_Template -workspace iOS_Template.xcworkspace -destination 'platform=iOS Simulator,name=iPhone X'
当我 运行 sonar-scanner
扫描代码并上传报告时,我收到以下错误:
INFO: Parse coverage report
(DerivedData/iOS_Template/Build/ProfileData/DDA1A82C-EB41-4E45-8DCF-428D3E879067/Coverage.profdata)
ERROR: Can't parse coverage report file
(DerivedData/iOS_Template/Build/ProfileData/DDA1A82C-EB41-4E45-8DCF-428D3E879067/Coverage.profdata).
No coverage information will be saved.
java.lang.IllegalStateException: Can not parse line: HƢ�F
_T0SS17iOS_TemplateTestsE11isValidatedSbAA10ValidationO10validation_tF�.�������k(_T09Alamofire12TaskDelegateC10urlSessionySo10URLSessionC_So0fB0C4taskySo11InputStreamCSgc011needNewBodyI0t3��6K�2@_T09Alamofire14SessionManagerC5retrySbAA7RequestC383��J��Z8_T09Alamofire7AFErrorO31ResponseValidationFailureReasonO22acceptableContentTypesSaySSGSgf6(��W��N
[...similar set of unknown characters...]
at com.sonar.swift.plugin.B.A(Unknown Source)
at com.sonar.swift.plugin.B.A(Unknown Source)
at java.util.Optional.ifPresent(Optional.java:159)
at com.sonar.swift.plugin.B.A(Unknown Source)
at com.sonar.swift.plugin.B.A(Unknown Source)
at com.sonar.swift.plugin.B.A(Unknown Source)
at com.sonar.swift.plugin.D.A(Unknown Source)
at com.sonar.swift.plugin.D.execute(Unknown Source)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
.....
我检查了 Sonarswift 插件,它看起来没有支持 XCode9+ 的线索(我的 Xcode 版本是 Xcode 9.2),想知道它是否导致异常
看看这个 SonarQube documentation 页面。在将输出发送到 SonarQube 之前,您必须翻译输出:
xcodebuild -scheme <schemeName> -enableCodeCoverage YES -derivedDataPath . clean build test
xcrun llvm-cov show -instr-profile=Build/Intermediates/CodeCoverage/Coverage.profdata <path to instrumented executable> > <coverage report file>
同时检查您的 sonar.swift.coverage.reportPath 设置。该文档还有一个 link 示例项目。
事实证明,通过向 'generate' 添加一个命令来解决 SonarSwift 加载的覆盖率报告文件。
命令是xcrun llvm-cov show -instr-profile