Branch | Status |
---|---|
master | |
develop |
This is an open source initiative for Apple Swift language support in SonarQube. The structure of the plugin is based on the sonar-objective-c plugin.
In SonarQube under Quality Profiles the used Linter can be specified by selecting either the SwiftLint Profile or the Tailor Profile as Default profile for Swift Projects:
Feature | Supported | MacOS | Unix |
---|---|---|---|
Complexity | YES | Uses Lizard | Uses Lizard |
Design | NO | ||
Documentation | YES | ||
Duplications | YES | ||
Issues | YES | Uses SwiftLint and/or Tailor | Uses Tailor |
Size | YES | ||
Tests | YES | Uses xcodebuild + xcpretty xcpretty | Not Supported |
Code coverage | YES | Uses slather | Not Supported |
Checkout the Releases page.
If you use fastlane, please read our fastlane integration doc.
Otherwise, run the run-sonar-swift.sh
script from your Xcode project root folder
- SonarQube 7 support by Hugal31. See PR 135
- Lower case fastlane by milch. See PR 113
- Ability to locate test files in sub-directories by Hugal31. See PR 123
- SwiftLint 0.21.0 (95 rules now)
- SonarQube 6.5 support
- Fixes properties with space by Branlute. See PR 84
- Finds project version automatically with CFBundleShortVersionString by Branlute. See PR 87
- Fixes coverage with mixed objc swift project by Branlute. See PR 88
- Quotes support for multi-word project names by PetrJandak. See PR 97
- SwiftLint 0.18.1 (add 8 more rules)
- Fix README headers
- Update README URLs to SonarQube
- Updated run-sonar-swift.sh to support -usesonarscanner (for sonar-scanner instead of sonar-runner).
- SwiftLint 0.16.1 (75 rules now).
- Fixed Metric 'test_data' should not be computed by a Sensor with SonarQube 6.2
- fastlane documentation update by mammuth. See PR 62
- run-sonar-swift.sh fix by TheSkwiggs. See PR 64
- Now falls back to sonar-scanner if sonar-runner is not installed (thanks to MaikoHermans. See PR 59)
- Ability to set sonar.swift.appName. Useful when basename is different from targeted scheme, or when slather fails with 'No product binary found' (thanks to MaikoHermans. See PR 58)
- Added a second linter: Tailor. Enables analysis of Swift code on linux. (thanks to tzwickl for the hard work. See PR 51)
- SonarQube 6 support. Important : will work with SonarQube 5.x and above only. Will not work anymore with SonarQube 4.5.x anymore.
- SwiftLint 0.13.1 support (49 rules now).
- Desactivation of unit tests and coverage is now allowed. Use run-sonar-swift.sh -nounittests to do it.
- Analysis does not fail anymore when an unkwown issue is reported by SwiftLint. See issue 35
- fastlane documentation (thanks to viteinfinite). See PR 33
- Fixed fastlane JUnit report support
- SwiftLint 0.11.1 support
- Better return code suppot for run-sonar-swift.sh
- Fixed Lizard Sensor wrong file path
- Added support for .xcodeproj only projects (thanks to delannoyk)
- Fix for Lizard Sensor to find indexed files (thanks to gretzki)
- Got rid of confusion with commercial plugin in the update center
- SwiftLint 0.8 support (new rules added).
- Lizard complexity report support (thanks to akshaysyaduvanshi)
- SwiftLint 0.5.1 support (new rules added).
- Added sonar.swift.simulator key in sonar-project.properties to select destination simulator for running tests
- SwiftLint scans source directories only
- SwiftLint 0.4.0 support (new rules added).
- Initial release.
- a Mac with Xcode 7 or +
- SonarQube and SonarQube Scanner
- xcpretty (see instructions below)
- SwiftLint (HomeBrew installed and
brew install swiftlint
). Version 0.3.0 or above. - Tailor (HomeBrew installed and
brew install tailor
). Version 0.11.1 or above. - slather (
gem install slather
). Version 2.1.0 or above (2.4 since Xcode 8.3). - lizard (PIP installed and
sudo pip install lizard
)
At the time, xcpretty needs to be fixed to work with SonarQube.
To install the fixed version, follow those steps :
git clone https://github.com/Backelite/xcpretty.git
cd xcpretty
git checkout fix/duration_of_failed_tests_workaround
gem build xcpretty.gemspec
sudo gem install --both xcpretty-0.2.2.gem
- Download the plugin binary into the $SONARQUBE_HOME/extensions/plugins directory
- Copy run-sonar-swift.sh somewhere in your PATH
- Restart the SonarQube server.
- Copy sonar-project.properties in your Xcode project root folder (along your .xcodeproj file)
- Edit the
sonar-project.properties
file to match your Xcode iOS/MacOS project
The good news is that you don't have to modify your Xcode project to enable SonarQube!. Ok, there might be one needed modification if you don't have a specific scheme for your test target, but that's all.
- Install the lastest plugin version
- Copy
run-sonar-swift.sh
somewhere in your PATH
If you still have run-sonar-swift.sh file in each of your project (not recommended), you will need to update all those files.
Feel free to contribute to this plugin by issuing pull requests to this repository.
When creating a pull request: always create it for the develop branch.
SonarQube Plugin for Swift is released under the GNU LGPL 3 license.