Skip to content

Commit

Permalink
Get rid of the nasty shell script, update sample properites and README
Browse files Browse the repository at this point in the history
  • Loading branch information
mjdetullio committed Nov 4, 2015
1 parent 2e7ca7b commit 5d55c56
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 843 deletions.
169 changes: 127 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
SonarQube Plugin for Objective C
================================
# SonarQube Plugin for Objective-C

This repository hosts the Objective-C plugin for [SonarQube](http://www.sonarqube.org/). This plugin enables to analyze and track the quality of iOS (iPhone, iPad) and MacOS developments.
This repository hosts the Objective-C plugin for
[SonarQube](http://www.sonarqube.org/). This plugin aims to analyze and track
the quality of iOS (iPhone, iPad) and MacOS projects, but it can be used with
other Objective-C projects.

This plugin is not supported by SonarSource. SonarSource offers a [commercial SonarSource Objective-C plugin](http://www.sonarsource.com/products/plugins/languages/objective-c/) as well. Both plugins do not offer the same functionalities/support.
This plugin is not supported by SonarSource. SonarSource offers a
[commercial SonarSource Objective-C plugin](http://www.sonarsource.com/products/plugins/languages/objective-c/)
as well. The plugins do not offer the same features/support.

The development of this plugin has always been done thanks to the community. If you wish to contribute, check the [Contributing](https://github.com/octo-technology/sonar-objective-c/wiki/Contributing) wiki page.
The development of this plugin has always been done thanks to the community.
If you wish to contribute, check the
[Contributing](https://github.com/octo-technology/sonar-objective-c/wiki/Contributing)
wiki page.

Find below an example of an iOS SonarQube dashboard:
<p align="center">
<img src="sample/screen%20shot%20SonarQube%20dashboard.png" alt="Example iOS SonarQube dashboard" width="80%"/>
</p>

###Features
## Features

- [x] Complexity
- [ ] Design
Expand All @@ -22,69 +29,147 @@ Find below an example of an iOS SonarQube dashboard:
- [x] Size
- [x] Tests

For more details, see the list of [SonarQube metrics](https://github.com/octo-technology/sonar-objective-c/wiki/Features) implemented or pending.
For more details, see the list of
[SonarQube metrics](https://github.com/octo-technology/sonar-objective-c/wiki/Features)
implemented or pending.

###Compatibility

## Compatibility

- Use 0.3.x releases for SonarQube < 4.3
- Use 0.4.x releases for SonarQube >= 4.3 (4.x and 5.x)
- Use 0.4.0 or later releases for SonarQube >= 4.3 (4.x and 5.x)


###Download
## Download

The latest version is the 0.4.0 and it's available [here](http://bit.ly/18A7OkE).
The latest SonarQube 3.x release is the 0.3.1, and it's available [here](http://bit.ly/1fSwd5I).

You can also download the latest build of the plugin from [Cloudbees](https://rfelden.ci.cloudbees.com/job/sonar-objective-c/lastSuccessfulBuild/artifact/target/).
You can also download the latest build of the plugin from
[Cloudbees](https://rfelden.ci.cloudbees.com/job/sonar-objective-c/lastSuccessfulBuild/artifact/target/).

In the worst case, the Maven repository with all snapshots and releases is available here: http://repository-rfelden.forge.cloudbees.com/
In the worst case, the Maven repository with all snapshots and releases is
available here: http://repository-rfelden.forge.cloudbees.com/


## Prerequisites

- A Mac with Xcode
- Optional: [Homebrew](http://brew.sh) for easier prerequisite installation
- [SonarQube](http://docs.codehaus.org/display/SONAR/Setup+and+Upgrade)
- [SonarQube Runner](http://docs.codehaus.org/display/SONAR/Installing+and+Configuring+SonarQube+Runner) (```brew install sonar-runner```)

### JUnit

Any of the following will produce JUnit XML reports for your project:

- [xctool](https://github.com/facebook/xctool) (```brew install xctool```)
- This is actually a substitute for xcodebuild, so it will compile your app and run tests as part of the process
- Make sure the version of xctool you use is compatible with the version of Xcode you will be building with
- [xcpretty](https://github.com/supermarin/xcpretty) (```gem install xcpretty```)
- This will parse xcodebuild's output and prettify it, with the option of generating a JUnit XML report and/or JSON compilation database
- [ocunit2junit](https://github.com/ciryon/OCUnit2JUnit) (```gem install ocunit2junit```)
- This will parse xcodebuild's output and generate a JUnit XML report


### Coverage

Run your tests with code coverage enabled, then run one of the following tools
to produce a Cobertura XML report which can be imported by this plugin.

- With Xcode prior to version 7, use [gcovr](http://gcovr.com) to parse ```*.gcda``` and ```*.gcno``` files
- With Xcode 7 or greater, use [slather](https://github.com/venmo/slather) to parse the ```Coverage.profdata``` file
- Note: at time of writing, support for the ```*.profdata``` format has not been released, but can be installed by running ```gem install specific_install && gem specific_install -l https://github.com/viteinfinite/slather.git -b 61f00988e6ad65f817ba81b08533cf78615fff16```
- Note: at time of writing, xctool is not capable of producing coverage data when using Xcode 7+


### Clang

[Clang Static Analyzer](http://clang-analyzer.llvm.org/) can produce Plist
reports which can be imported by this plugin.

There are different ways to produce the reports, such as using Clang's
[scan-build](http://clang-analyzer.llvm.org/scan-build.html), however it's
probably easiest to use xcodebuild's ```analyze``` action. Xcodebuild will
invoke the analyzer with all the proper arguments and use any additional
analyzer configuration from your settings under ```*.xcodeproj```. By default,
it will produce the Plist reports this plugin needs.


###Prerequisites
### OCLint

- a Mac with Xcode...
- [SonarQube](http://docs.codehaus.org/display/SONAR/Setup+and+Upgrade) and [SonarQube Runner](http://docs.codehaus.org/display/SONAR/Installing+and+Configuring+SonarQube+Runner) installed ([HomeBrew](http://brew.sh) installed and ```brew install sonar-runner```)
- [xctool](https://github.com/facebook/xctool) ([HomeBrew](http://brew.sh) installed and ```brew install xctool```). If you are using Xcode 6, make sure to update xctool (```brew upgrade xctool```) to a version > 0.2.2.
- [OCLint](http://docs.oclint.org/en/dev/intro/installation.html) installed. Version 0.8.1 recommended ([HomeBrew](http://brew.sh) installed and ```brew install https://gist.githubusercontent.com/TonyAnhTran/e1522b93853c5a456b74/raw/157549c7a77261e906fb88bc5606afd8bd727a73/oclint.rb```).
- [gcovr](http://gcovr.com) installed
- [lizard](https://github.com/terryyin/lizard) installed
[OCLint](http://docs.oclint.org/en/dev/intro/installation.html) version 0.8.1 recommended
(```brew install https://gist.githubusercontent.com/TonyAnhTran/e1522b93853c5a456b74/raw/157549c7a77261e906fb88bc5606afd8bd727a73/oclint.rb```).
Use it to produce a PMD-formatted XML report that can be imported by this
plugin.

###Installation (once for all your Objective-C projects)
- Install [the plugin](http://bit.ly/18A7OkE) through the Update Center (of SonarQube) or download it into the $SONARQUBE_HOME/extensions/plugins directory
- Copy [run-sonar.sh](https://rawgithub.com/octo-technology/sonar-objective-c/master/src/main/shell/run-sonar.sh) somewhere in your PATH
- Restart the SonarQube server.

###Configuration (once per project)
- Copy [sonar-project.properties](https://rawgithub.com/octo-technology/sonar-objective-c/master/sample/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
### Complexity

**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.
Use [Lizard](https://github.com/terryyin/lizard) (```pip install lizard```)
to produce an XML report that can be imported by this plugin.

###Analysis
- Run the script ```run-sonar.sh``` in your Xcode project root folder

## Installation (once for all your Objective-C projects)

1. Install [the plugin](http://bit.ly/18A7OkE) through the Update Center (of SonarQube) or download it into the $SONARQUBE_HOME/extensions/plugins directory
2. Restart the SonarQube server.


## Configuration (once per project)

Create a ```sonar-project.properties``` file defining some basic project
configuration and the location of the reports you want to import.

**The good news is that you don't have to modify your Xcode project to enable
SonarQube!**. Ok, there might be needed modification if you don't have a
specific scheme for your test target or if coverage is not enabled, but that's all.


## Analysis

- Run your build script to produce the various reports
- Run ```sonar-runner```
- Enjoy or file an issue!

###Update (once per plugin update)

## Update

- Install the [latest plugin](http://bit.ly/18A7OkE) version
- Copy [run-sonar.sh](https://rawgithub.com/octo-technology/sonar-objective-c/master/src/main/shell/run-sonar.sh) somewhere in your PATH
- Check for documented migration steps

### Migration to v0.5.x

- Analysis property names have changed. Check the sample.
- Coverage report property no longer supports pattern matching. Only one coverage XML file is supported.
- ```sonar.language``` key changed from ```objc``` to ```objectivec```
- As a side effect you may have to reconfigure your Quality Profiles

If you still have *run-sonar.sh* file in each of your project (not recommended), you will need to update all those files.

###Credits
* **Cyril Picat**
* **Gilles Grousset**
* **Denis Bregeon**
* **François Helg**
* **Romain Felden**
* **Mete Balci**
## Contributors

###History
- Cyril Picat
- Gilles Grousset
- Denis Bregeon
- François Helg
- Romain Felden
- Mete Balci
- Andrés Gil Herrera
- Matthew DeTullio


## History

- v0.5.0 (2015/11): added support for Clang, made properties configurable in SonarQube UI, major refactoring
- v0.4.1 (2015/05): added support for Lizard to implement complexity metrics.
- v0.4.0 (2015/01): support for SonarQube >= 4.3 (4.x & 5.x)
- v0.3.1 (2013/10): fix release
- v0.3 (2013/10): added support for OCUnit tests and test coverage
- v0.2 (2013/10): added OCLint checks as SonarQube violations
- v0.0.1 (2012/09): v0 with basic metrics such as nb lines of code, nb lines of comment, nb of files, duplications

###License

SonarQube Plugin for Objective C is released under the GNU LGPL 3 license:
## License

SonarQube Plugin for Objective-C is released under the GNU LGPL 3 license:
http://www.gnu.org/licenses/lgpl.txt
89 changes: 46 additions & 43 deletions sample/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,60 +1,63 @@
##########################
# Required configuration #
##########################

sonar.projectKey=my-project
# Required
sonar.projectKey=com.example:my-project
# Required
sonar.projectName=My project
# Required
sonar.projectVersion=1.0
sonar.language=objc

# Project description

# Optional
sonar.projectDescription=Fake description

# Path to source directories

# Required
# Path to source directories
sonar.sources=srcDir1,srcDir2
# Path to test directories (comment if no test)

# Optional
sonar.inclusions=subDir1/**,subDir2/**
# Optional
sonar.exclusions=**/generatedDir/**,**/thirdpartyDir/**

# Optional
# Path to test directories
sonar.tests=testSrcDir


# Xcode project configuration (.xcodeproj or .xcworkspace)
# -> If you have a project: configure only sonar.objectivec.project
# -> If you have a workspace: configure sonar.objectivec.workspace and sonar.objectivec.project
# and use the later to specify which project(s) to include in the analysis (comma separated list)
sonar.objectivec.project=myApplication.xcodeproj
# sonar.objectivec.workspace=myApplication.xcworkspace

# Scheme to build your application
sonar.objectivec.appScheme=myApplication
# Scheme to build and run your tests (comment following line of you don't have any tests)
sonar.objectivec.testScheme=myApplicationTests

##########################
# Optional configuration #
##########################
# Optional
sonar.test.inclusions=subDir3/**
# Optional
sonar.test.exclusions=

# Recommended
# Add language property to limit to single-language analysis
sonar.language=objectivec

# Define suffixes for multi-language analysis
# There will likely be problems if you have any other C/C++/Obj-C plugin(s) installed due to each language using .h files
sonar.objectivec.file.suffixes=.h,.m

# Encoding of the source code
sonar.sourceEncoding=UTF-8

# JUnit report generated by run-sonar.sh is stored in sonar-reports/TEST-report.xml
# Change it only if you generate the file on your own
# The XML files have to be prefixed by TEST- otherwise they are not processed
# sonar.junit.reportsPath=sonar-reports/
# Optional
# Folder with JUnit XML reports matching format of "TEST*.xml"
# Generate this with xctool, xcpretty, or ocunit2junit
sonar.objectivec.junit.reportsPath=sonar-reports/junit

# Cobertura report generated by run-sonar.sh is stored in sonar-reports/coverage.xml
# Change it only if you generate the file on your own
# sonar.objectivec.coverage.reportPattern=sonar-reports/coverage*.xml
# Optional
# Path to Cobertura XML report
# Generate this with gcovr (Xcode < 7) or slather (Xcode >= 7)
sonar.objectivec.cobertura.reportPath=sonar-reports/cobertura.xml

# OCLint report generated by run-sonar.sh is stored in sonar-reports/oclint.xml
# Change it only if you generate the file on your own
# sonar.objectivec.oclint.report=sonar-reports/oclint.xml
# Optional
# Path to OCLint PMD formatted XML report
sonar.objectivec.oclint.reportPath=sonar-reports/oclint.xml

# Lizard report generated by run-sonar.sh is stored in sonar-reports/lizard-report.xml
# Change it only if you generate the file on your own
# sonar.objectivec.lizard.report=sonar-reports/lizard-report.xml
# Optional
# Folder with Clang Plist reports matching format of "*.plist"
sonar.objectivec.clang.reportsPath=sonar-reports/clang

# Paths to exclude from coverage report (tests, 3rd party libraries etc.)
# sonar.objectivec.excludedPathsFromCoverage=pattern1,pattern2
sonar.objectivec.excludedPathsFromCoverage=.*Tests.*
# Optional
# Path to Lizard XML report
sonar.objectivec.lizard.reportPath=sonar-reports/lizard.xml

# Project SCM settings
# sonar.scm.enabled=true
Expand Down
Loading

0 comments on commit 5d55c56

Please sign in to comment.