-
Notifications
You must be signed in to change notification settings - Fork 274
Description
Describe the bug
SonarScanner errors out due an exception in sonar-swift plugin when source path has a space.
To Reproduce
Steps to reproduce the behavior:
Analyze an Xcode project with a space in its path. An example code structure:
- MyProject.xcodeproj
- My Project
- Project Sources
- AppDelegate.swift
- Project Sources
Expected behavior
The analysis should complete and results should be published to Sonarqube.
SonarQube environment:
- OS: MacOS
- sonar-swift: v0.4.4
- SonarQube: 7.6.0.21501
- Lizard: 1.16.3
Additional context
Following is the exception:
ERROR: Error during SonarQube Scanner execution
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1967)
at com.backelite.sonarqube.swift.complexity.LizardReportParser$SwiftFunction.<init>(LizardReportParser.java:181)
at com.backelite.sonarqube.swift.complexity.LizardReportParser.parseMeasure(LizardReportParser.java:120)
at com.backelite.sonarqube.swift.complexity.LizardReportParser.parseFile(LizardReportParser.java:88)
Probable root-cause is the following code, which assumes that there would not be a path in space:
https://github.com/Backelite/sonar-swift/blob/42831ead6a8e838fe5db28b0430c77209b72603f/sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity/LizardReportParser.java#L178-L181
When the path includes space the name
would include a string similar to :
applicationDidEnterBackground(...) at ./My Project/Project Sources/AppDelegate.swift:27
So at Line 181, val2
would likely have the value ./My
instead of complete path and thus it would not find the :
it is seeking.