Skip to content

Commit 905eaac

Browse files
author
Gilles Grousset
committed
Initial commit
0 parents  commit 905eaac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3797
-0
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.classpath
2+
.project
3+
.settings/
4+
target/
5+
6+
# Exclude OS X folder attributes
7+
.DS_Store
8+
9+
# IntelliJ files
10+
*.ipr
11+
*.iml
12+
*.iws
13+
.idea
14+

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: java
2+
jdk:
3+
- oraclejdk8
4+
- oraclejdk7
5+
- openjdk7
6+
- openjdk6

README.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<p align="left">
2+
<img src="http://www.backelite.com/bkimages/extension/backelite/design/backelite/templates/img/header_logo.png/3840/2160/PNG" width="100"/>
3+
</p>
4+
5+
| Branch | Status |
6+
|----------|:------------------------------------------------------------------------------------------------------------------------------------------:|
7+
| master | [![Build Status](https://travis-ci.org/Backelite/sonar-swift.svg?branch=master)](https://travis-ci.org/Backelite/sonar-swift) |
8+
| develop| [![Build Status](https://travis-ci.org/Backelite/sonar-swift.svg?branch=develop)](https://travis-ci.org/Backelite/sonar-swift) |
9+
10+
SonarQube Plugin for Swift
11+
================================
12+
13+
This is an open source initiative for Apple Swift language support in SonarQube.
14+
15+
SCREENSHOT
16+
17+
TBD
18+
19+
20+
21+
22+
###Features
23+
24+
- [ ] Complexity
25+
- [ ] Design
26+
- [x] Documentation
27+
- [x] Duplications
28+
- [x] Issues (SwiftLint)
29+
- [x] Size
30+
- [x] Tests
31+
32+
33+
###Download
34+
35+
TBD
36+
37+
###Prerequisites
38+
39+
- a Mac with Xcode 7 or +
40+
- [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```)
41+
- [xctool](https://github.com/facebook/xctool) ([HomeBrew](http://brew.sh) installed and ```brew install xctool```). Version 0.2.6 or above.
42+
- [SwiftLint] (https://github.com/realm/SwiftLint) ([HomeBrew](http://brew.sh) installed and ```brew install swiftlint```). Version 0.3.0 or above.
43+
- [slather](https://github.com/venmo/slather) ```gem install slather```
44+
45+
###Installation (once for all your Swift projects)
46+
- Download the plugin binary into the $SONARQUBE_HOME/extensions/plugins directory
47+
- Copy [run-sonar.sh](https://rawgithub.com/Backelite/sonar-swift/master/src/main/shell/run-sonar-swift.sh) somewhere in your PATH
48+
- Restart the SonarQube server.
49+
50+
###Configuration (once per project)
51+
- Copy [sonar-project.properties](https://rawgithub.com/Backelite/sonar-objective-c/master/sample/sonar-project.properties) in your Xcode project root folder (along your .xcodeproj file)
52+
- Edit the ```sonar-project.properties``` file to match your Xcode iOS/MacOS project
53+
54+
**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.
55+
56+
###Analysis
57+
- Run the script ```run-sonar-swift.sh``` in your Xcode project root folder
58+
- Enjoy or file an issue!
59+
60+
###Update (once per plugin update)
61+
- Install the lastest plugin version
62+
- Copy ```run-sonar-swift.sh``` somewhere in your PATH
63+
64+
If you still have *run-sonar-swift.sh* file in each of your project (not recommended), you will need to update all those files.
65+
66+
###Contributing
67+
68+
Feel free to contribute to this plugin by issuing pull requests to this repository.
69+
70+
###License
71+
72+
SonarQube Plugin for Swift is released under the [GNU LGPL 3 license](http://www.gnu.org/licenses/lgpl.txt).

build-and-deploy.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
# Build and install snapshot plugin in Sonar
3+
4+
# Build first and check status
5+
mvn clean license:format install
6+
if [ "$?" != 0 ]; then
7+
echo "ERROR - Java build failed!" 1>&2
8+
exit $?
9+
fi
10+
11+
# Run shell tests
12+
#shelltest src/test/shell --execdir --diff
13+
#if [ "$?" != 0 ]; then
14+
# echo "ERROR - Shell tests failed!" 1>&2
15+
# exit $?
16+
#fi
17+
18+
# Deploy new verion of plugin in Sonar dir
19+
cp target/*.jar $SONARQUBE_HOME/extensions/plugins
20+
21+
# Stop/start Sonar
22+
$SONARQUBE_HOME/bin/macosx-universal-64/sonar.sh stop
23+
$SONARQUBE_HOME/bin/macosx-universal-64/sonar.sh start
24+

pom.xml

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<repositories>
8+
<repository>
9+
<id>sonar</id>
10+
<url>http://repository.sonarsource.org/content/repositories/sonar</url>
11+
</repository>
12+
</repositories>
13+
14+
<pluginRepositories>
15+
<pluginRepository>
16+
<id>sonar</id>
17+
<url>http://repository.sonarsource.org/content/repositories/sonar</url>
18+
</pluginRepository>
19+
</pluginRepositories>
20+
21+
<parent>
22+
<groupId>org.codehaus.sonar-plugins</groupId>
23+
<artifactId>parent</artifactId>
24+
<version>18</version>
25+
</parent>
26+
27+
<groupId>com.backelite.sonarqube</groupId>
28+
<artifactId>sonar-swift-plugin</artifactId>
29+
<version>0.1-SNAPSHOT</version>
30+
31+
<packaging>sonar-plugin</packaging>
32+
33+
<name>Swift SonarQube Plugin</name>
34+
<description>Enables analysis of Swift projects into SonarQube.</description>
35+
<url>https://github.com/Backelite/sonar-swift</url>
36+
37+
38+
<inceptionYear>2015</inceptionYear>
39+
<organization>
40+
<name>Backelite</name>
41+
</organization>
42+
<licenses>
43+
<license>
44+
<name>GNU LGPL 3</name>
45+
<url>http://www.gnu.org/licenses/lgpl.txt</url>
46+
<distribution>repo</distribution>
47+
</license>
48+
</licenses>
49+
50+
<developers>
51+
<developer>
52+
<id>zippy1978</id>
53+
<name>Gilles Grousset</name>
54+
<organization>Backelite</organization>
55+
</developer>
56+
</developers>
57+
58+
<scm>
59+
<connection>scm:git:[email protected]:Backelite/sonar-swift.git</connection>
60+
<developerConnection>scm:git:[email protected]:Backelite/sonar-swift.git</developerConnection>
61+
<url>https://github.com/Backelite/sonar-swift</url>
62+
</scm>
63+
64+
<properties>
65+
<license.owner>Backelite</license.owner>
66+
<license.title>SonarQube Swift Plugin</license.title>
67+
68+
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
69+
70+
<sonar.version>4.3</sonar.version>
71+
<sslr.version>1.20</sslr.version>
72+
73+
<!-- Configuration for sonar-packaging-maven-plugin -->
74+
<sonar.pluginClass>org.sonar.plugins.swift.SwiftPlugin</sonar.pluginClass>
75+
<sonar.pluginName>Swift</sonar.pluginName>
76+
77+
</properties>
78+
79+
<dependencies>
80+
<dependency>
81+
<groupId>org.codehaus.sonar</groupId>
82+
<artifactId>sonar-plugin-api</artifactId>
83+
<version>${sonar.version}</version>
84+
</dependency>
85+
<dependency>
86+
<groupId>org.codehaus.sonar</groupId>
87+
<artifactId>sonar-testing-harness</artifactId>
88+
<version>${sonar.version}</version>
89+
</dependency>
90+
<dependency>
91+
<groupId>org.codehaus.sonar</groupId>
92+
<artifactId>sonar-deprecated</artifactId>
93+
<version>${sonar.version}</version>
94+
</dependency>
95+
96+
<dependency>
97+
<groupId>org.codehaus.sonar.sslr</groupId>
98+
<artifactId>sslr-core</artifactId>
99+
<version>${sslr.version}</version>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.codehaus.sonar.sslr</groupId>
103+
<artifactId>sslr-xpath</artifactId>
104+
<version>${sslr.version}</version>
105+
</dependency>
106+
<dependency>
107+
<groupId>org.codehaus.sonar.sslr</groupId>
108+
<artifactId>sslr-toolkit</artifactId>
109+
<version>${sslr.version}</version>
110+
</dependency>
111+
<dependency>
112+
<groupId>org.codehaus.sonar.sslr</groupId>
113+
<artifactId>sslr-testing-harness</artifactId>
114+
<version>${sslr.version}</version>
115+
</dependency>
116+
<dependency>
117+
<groupId>org.codehaus.sonar.sslr-squid-bridge</groupId>
118+
<artifactId>sslr-squid-bridge</artifactId>
119+
<version>2.4</version>
120+
</dependency>
121+
<dependency>
122+
<groupId>ant</groupId>
123+
<artifactId>ant</artifactId>
124+
<version>1.6</version>
125+
</dependency>
126+
127+
<dependency>
128+
<groupId>com.googlecode.json-simple</groupId>
129+
<artifactId>json-simple</artifactId>
130+
<version>1.1.1</version>
131+
</dependency>
132+
133+
<dependency>
134+
<groupId>junit</groupId>
135+
<artifactId>junit</artifactId>
136+
<version>4.10</version>
137+
</dependency>
138+
<dependency>
139+
<groupId>org.mockito</groupId>
140+
<artifactId>mockito-all</artifactId>
141+
<version>1.9.0</version>
142+
</dependency>
143+
<dependency>
144+
<groupId>org.hamcrest</groupId>
145+
<artifactId>hamcrest-all</artifactId>
146+
<version>1.1</version>
147+
</dependency>
148+
<dependency>
149+
<groupId>org.easytesting</groupId>
150+
<artifactId>fest-assert</artifactId>
151+
<version>1.4</version>
152+
</dependency>
153+
<dependency>
154+
<groupId>ch.qos.logback</groupId>
155+
<artifactId>logback-classic</artifactId>
156+
<version>0.9.30</version>
157+
</dependency>
158+
<dependency>
159+
<groupId>org.codehaus.sonar.plugins</groupId>
160+
<artifactId>sonar-surefire-plugin</artifactId>
161+
<version>2.7</version>
162+
</dependency>
163+
164+
</dependencies>
165+
166+
167+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* SonarQube Swift Plugin
3+
* Copyright (C) 2015 Backelite
4+
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
19+
*/
20+
package org.sonar.plugins.swift;
21+
22+
import com.google.common.collect.ImmutableList;
23+
import org.sonar.api.Properties;
24+
import org.sonar.api.Property;
25+
import org.sonar.api.SonarPlugin;
26+
import org.sonar.plugins.swift.colorizer.SwiftCodeColorizerFormat;
27+
import org.sonar.plugins.swift.coverage.SwiftCoberturaSensor;
28+
import org.sonar.plugins.swift.cpd.SwiftCpdMapping;
29+
import org.sonar.plugins.swift.lang.core.Swift;
30+
import org.sonar.plugins.swift.lang.core.SwiftSourceImporter;
31+
import org.sonar.plugins.swift.violations.SwiftProfile;
32+
import org.sonar.plugins.swift.tests.SwiftSurefireSensor;
33+
import org.sonar.plugins.swift.violations.swiftlint.SwiftLintProfile;
34+
import org.sonar.plugins.swift.violations.swiftlint.SwiftLintProfileImporter;
35+
import org.sonar.plugins.swift.violations.swiftlint.SwiftLintRuleRepository;
36+
import org.sonar.plugins.swift.violations.swiftlint.SwiftLintSensor;
37+
38+
import java.util.List;
39+
40+
@Properties({
41+
@Property(key = SwiftCoberturaSensor.REPORT_PATTERN_KEY, defaultValue = SwiftCoberturaSensor.DEFAULT_REPORT_PATTERN, name = "Path to unit test coverage report(s)", description = "Relative to projects' root. Ant patterns are accepted", global = false, project = true),
42+
@Property(key = SwiftLintSensor.REPORT_PATH_KEY, defaultValue = SwiftLintSensor.DEFAULT_REPORT_PATH, name = "Path to SwiftLint report", description = "Relative to projects' root.", global = false, project = true)
43+
})
44+
public class SwiftPlugin extends SonarPlugin {
45+
46+
// Global Swift constants
47+
public static final String FALSE = "false";
48+
49+
public static final String FILE_SUFFIXES_KEY = "sonar.swift.file.suffixes";
50+
public static final String FILE_SUFFIXES_DEFVALUE = "swift";
51+
52+
public static final String PROPERTY_PREFIX = "sonar.swift";
53+
54+
public static final String TEST_FRAMEWORK_KEY = PROPERTY_PREFIX + ".testframework";
55+
public static final String TEST_FRAMEWORK_DEFAULT = "ghunit";
56+
57+
@Override
58+
public List getExtensions() {
59+
return ImmutableList.of(
60+
Swift.class,
61+
SwiftSourceImporter.class,
62+
SwiftCodeColorizerFormat.class,
63+
SwiftCpdMapping.class,
64+
65+
SwiftSquidSensor.class,
66+
SwiftSurefireSensor.class,
67+
SwiftCoberturaSensor.class,
68+
69+
SwiftProfile.class,
70+
71+
SwiftLintSensor.class,
72+
SwiftLintRuleRepository.class,
73+
SwiftLintProfile.class,
74+
SwiftLintProfileImporter.class
75+
);
76+
}
77+
}

0 commit comments

Comments
 (0)