I have a project that is written in Swift and makes use of SwiftUI. For many of those SwiftUI views, we have Previews which use the SwiftUI Preview Macros.
This has worked just fine with SonarQube until today. As of this morning, SonarScans are failing on the last line of any file that has a SwiftUI #Preview
macro in it. with an error like the following
ERROR: String is not parsed (file Client/Sources/MySwiftUIView.swift, line 127)
Has anyone else noticed this and is it a result of any updates or configuration changes?
+ echo 'Generating JUnit report'
Generating JUnit report
+ xchtmlreport -j /var/folders/7l/rszmbrmd6tv4pg52z6ql_5rc0000gn/T/XCUITestOutput667838978/Test-All.xcresult
Report successfully created at /var/folders/7l/rszmbrmd6tv4pg52z6ql_5rc0000gn/T/XCUITestOutput667838978/index.html
JUnit report successfully created at /var/folders/7l/rszmbrmd6tv4pg52z6ql_5rc0000gn/T/XCUITestOutput667838978/report.junit
+ echo 'Converting code coverage log to Sonar format'
Converting code coverage log to Sonar format
+ ./xccov-to-sonarqube-generic.sh /var/folders/7l/rszmbrmd6tv4pg52z6ql_5rc0000gn/T/XCUITestOutput667838978/Test-All.xcresult
+ echo 'Appending Sonar Properties'
Appending Sonar Properties
+ echo ''
+ echo sonar.host.url=[REDACTED]([REDACTED])
+ echo sonar.login=[REDACTED]
+ echo sonar.coverageReportPaths=./cov.xml
+ echo sonar.junit.reportPaths=./report.junit
+ echo sonar.cfamily.compile-commands=compile_commands.json
+ echo 'sonar.exclusions=**/Generated/*,**/Derived/Sources/*,**/Project.swift,**/Box2D/**/*,**/Mock/**/*,**/Ampli.swift,**/MockDataClient.swift'
+ [[ false = \t\r\u\e ]]
+ echo sonar.branch.name=hotfix/sonar-build-fixes
+ max_iteration=2
+ set +e
++ seq 1 2
+ for i in '$(seq 1 $max_iteration)'
+ sonar-scanner
INFO: Scanner configuration file: /opt/homebrew/Cellar/sonar-scanner/5.0.1.3006/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: /Users/vagrant/git/sonar-project.properties
INFO: SonarScanner 5.0.1.3006
INFO: Java 21.0.2 Homebrew (64-bit)
INFO: Mac OS X 14.1.2 aarch64
INFO: User cache: /Users/vagrant/.sonar/cache
INFO: Analyzing on SonarQube server 9.9.0.65466
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=350ms
INFO: Server id: 51804F84-AYdM6nLjPzIPvAlP20k9
INFO: User cache: /Users/vagrant/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=94ms
INFO: Load/download plugins (done) | time=7706ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: Process project properties (done) | time=6ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: iOS
INFO: Base dir: /Users/vagrant/git
INFO: Working dir: /Users/vagrant/git/.scannerwork
INFO: Load project settings for component key: 'iOS'
INFO: Load project settings for component key: 'ios' (done) | time=86ms
INFO: Load project branches
INFO: Load project branches (done) | time=84ms
INFO: Load branch configuration
INFO: Found manual configuration of branch/PR analysis. Skipping automatic configuration.
INFO: Load branch configuration (done) | time=1ms
INFO: Auto-configuring with CI 'Bitrise'
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=125ms
INFO: Load active rules
INFO: Load active rules (done) | time=4490ms
INFO: Load analysis cache
INFO: Load analysis cache (404) | time=73ms
INFO: Branch name: hotfix/sonar-build-fixes
INFO: Load project repositories
INFO: Load project repositories (done) | time=106ms
INFO: Indexing files...
INFO: Project configuration:
INFO: Excluded sources: **/Generated/*, **/Derived/Sources/*, **/Project.swift, **/Box2D/**/*, **/Mock/**/*, **/Ampli.swift, **/MockDataClient.swift
INFO: Excluded sources for coverage: **/Generated/*, **/Derived/Sources/*, **/Project.swift
INFO: 1427 files indexed
INFO: 97 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for c: Sonar way
INFO: Quality profile for json: Sonar way
INFO: Quality profile for objc: Sonar way
INFO: Quality profile for swift: Sonar way
INFO: ------------- Run sensors on module iOS
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=84ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=98ms
INFO: Sensor IaC Kubernetes Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Kubernetes Sensor [iac] (done) | time=28ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Sensor C# Analysis Log [csharp] (done) | time=7ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=5ms
INFO: Sensor TextAndSecretsSensor [text]
INFO: 1406 source files to be analyzed
INFO: 1406/1406 source files have been analyzed
INFO: Sensor TextAndSecretsSensor [text] (done) | time=1854ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=6ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: Sensor Swift Code Quality and Security [swift]
INFO: 904 source files to be analyzed
ERROR: String is not parsed (file Client/Sources/OneOfOurSwiftUIFilesWithPreview.swift, line 52)
I am currently working on seeing if I can adjust the exclusions to avoid this issue.
Again, This was not a problem until last night.