Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Mega refactor + start Clang rules + add property configuration to UI #97

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a08dca8
add Sensor for Lizard report. Parser for Lizard report (xml) created …
iav-dev May 28, 2015
8065fe5
lizard sensor saves file complexity and function complexity but those…
iav-dev May 28, 2015
e914883
properties for lizard and lizard report is now generated by run-sonar.sh
May 28, 2015
5b52843
ObjectiveCSquidSensor does not save functions and complexity as it wo…
May 28, 2015
d42fe01
resolve little refactoring error
May 28, 2015
5013d75
tests
iav-dev Jun 3, 2015
7091d16
tests finished
iav-dev Jun 4, 2015
1dfc0c3
saving the file complexity distribution was moved from ObjectiveCSqui…
iav-dev Jun 5, 2015
282ebe6
File/Function Complexity distribution functionality moved from Object…
iav-dev Jun 5, 2015
0871e46
changed one script line that was unintentionally modified
iav-dev Jun 5, 2015
6df19c1
constants from LizardMeasurePersistor deleted
iav-dev Jun 5, 2015
9b39d53
dependency for xml parser and optimize imports in LizardMeasurePersis…
iav-dev Jun 5, 2015
2606f7b
loggs
iav-dev Jun 5, 2015
f8bf77c
tests updated
iav-dev Jun 5, 2015
0f31327
comments
Jun 14, 2015
42ba965
run lizard just if turned on AND installed
iav-dev Jun 18, 2015
8927d6a
Merge branch 'lizard_complexity' of https://github.com/agh92/sonar-ob…
iav-dev Jun 18, 2015
253f268
small changes that do not break the excecution of the sunar runner if…
iav-dev Jun 30, 2015
b832b7b
Update README.md
agh92 Jun 30, 2015
1c6cfa6
Update version in POM to 0.5.0-SNAPSHOT
mjdetullio Nov 3, 2015
fcc835e
Properly handle absolute paths for sonar.objectivec.lizard.report.
mjdetullio Oct 20, 2015
8d6cab0
Implement sensor to import Clang static analyzer multi-plist output.
mjdetullio Oct 22, 2015
4c2afda
Refactor to remove deprecation, add keywords
mjdetullio Oct 23, 2015
f9f6fa5
Package info
mjdetullio Oct 23, 2015
b84c285
Heavy refactoring:
mjdetullio Nov 3, 2015
e44093d
Rename packages
mjdetullio Nov 3, 2015
63513a3
Update developers and license owners in pom.xml and headers
mjdetullio Nov 3, 2015
9bc5130
Fix plugin name
mjdetullio Nov 3, 2015
0316a6a
Initial set of Clang rules. Add Clang profile.
mjdetullio Nov 3, 2015
2733aff
Update Surefire sensor with code from sonar-java
mjdetullio Nov 4, 2015
904c498
POM updates and update source headers
mjdetullio Nov 4, 2015
3c56c74
Get rid of the nasty shell script, update sample properites and README
mjdetullio Nov 4, 2015
9e7cbce
Change language key to avoid conflict with SonarSource's plugin
mjdetullio Nov 4, 2015
05313a9
OCLint SQALE model: Issues should be CONSTANT_ISSUE with offset
mjdetullio Nov 4, 2015
307cb47
Add Bitrise sample project
mjdetullio Feb 22, 2016
9fbd717
Restructure project for ITs
mjdetullio Mar 6, 2016
a8fca66
Bump SonarQube minimum version to 4.5.2 LTS and refactor for deprecation
mjdetullio Mar 6, 2016
1f13057
Lexer improvements for highlighter
mjdetullio Mar 6, 2016
a739365
Update SSLR dependencies and add SSLR Toolkit
mjdetullio Mar 9, 2016
8b4cd85
Extract Squid into its own module
mjdetullio Mar 9, 2016
23b5ec0
Implement file and function complexity issues based on Lizard report.
mjdetullio Mar 15, 2016
ccfb4a9
Add AFNetworking project for ITs.
mjdetullio Mar 15, 2016
de0fc8a
Add Clang core.CallAndMessage checker to rules definition.
mjdetullio Apr 14, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 147 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,188 @@
SonarQube Plugin for Objective C
================================
# SonarQube Objective-C (Community) Plugin

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

- [ ] Complexity
- [x] Complexity
- [ ] Design
- [x] Documentation
- [x] Duplications
- [x] Issues
- [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.x releases for SonarQube 4.3 and 4.4
- Use 0.5.x releases for SonarQube >= 4.5.2 LTS


###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.


### OCLint

[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.

###Prerequisites

- 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
### Complexity

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

###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

**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.
## Installation (once for all your Objective-C projects)

###Analysis
- Run the script ```run-sonar.sh``` in your Xcode project root folder
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)

## Troubleshooting

If the results from a report don't show up, make sure any relative file or
directory paths in the report match the paths of the files as configured
and indexed by SonarQube. Typically files are indexed relative to the base
directory of the project/module being analyzed.

For JUnit reports, most tools only record the classname, so make sure your
```*.m``` file is named the same as the classname it contains. Otherwise, the
plugin won't be able to find the test class.


## 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.
- Cobertura, JUnit, OCLint, and Lizard report properties no longer have defaults
- 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
- decouple report imports from the language so they can also be used with the commercial plugin
- 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
24 changes: 0 additions & 24 deletions build-and-deploy.sh

This file was deleted.

32 changes: 32 additions & 0 deletions its/plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.sonarqubecommunity.objectivec</groupId>
<artifactId>objective-c-its</artifactId>
<version>0.5.0-SNAPSHOT</version>
</parent>

<artifactId>objective-c-its-plugin</artifactId>

<name>SonarQube Objective-C (Community) :: ITs :: Plugin</name>
<packaging>pom</packaging>

<properties>
<maven.test.redirectTestOutputToFile>false</maven.test.redirectTestOutputToFile>
</properties>

<modules>
<module>tests</module>
</modules>

<profiles>
<profile>
<id>it-plugin</id>
<properties>
<skipTests>false</skipTests>
</properties>
</profile>
</profiles>
</project>
7 changes: 7 additions & 0 deletions its/plugin/projects/AFNetworking/.cocoadocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
highlight-color: "#F89915"
highlight-dark-color: "#E23B1B"
darker-color: "#D8A688"
darker-dark-color: "#E93D1C"
background-color: "#E9DFDB"
alt-link-color: "#E23B1B"
warning-color: "#E23B1B"
29 changes: 29 additions & 0 deletions its/plugin/projects/AFNetworking/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
Tests/Pods
Tests/Podfile.lock
Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/
AFNetworking.framework.zip

# Fastlane
/fastlane/report.xml
/fastlane/.env*private*
fastlane/test-output/*

Carthage/Build
Loading