Skip to content

Commit

Permalink
Merge branch 'zippy1978-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilpicat committed Jan 27, 2015
2 parents 2cf34b8 + b9b1bc4 commit 20b0b8e
Show file tree
Hide file tree
Showing 10 changed files with 1,411 additions and 48 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: java
jdk:
- oraclejdk8
- oraclejdk7
- openjdk7
- openjdk6
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,25 @@ In the worst case, the Maven repository with all snapshots and releases is avail

###Installation (once for all your Objective-C projects)
- Install [the plugin](http://bit.ly/1fSwd5I) 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
- Copy [run-sonar.sh](https://rawgithub.com/octo-technology/sonar-objective-c/master/src/main/shell/run-sonar.sh) in your Xcode project root folder and make it executable

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

###Analysis
- Run the script ```run-sonar.sh``` in your Xcode project root folder
- Enjoy or file an issue!

###Update (once per plugin update)
- Install the [latest plugin](http://bit.ly/1fSwd5I) version
- Copy [run-sonar.sh](https://rawgithub.com/octo-technology/sonar-objective-c/master/src/main/shell/run-sonar.sh) somewhere in your PATH

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**
* **Denis Bregeon**
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/sonar/plugins/objectivec/core/ObjectiveC.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import java.util.List;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.AbstractLanguage;
import org.sonar.plugins.objectivec.ObjectiveCPlugin;

Expand All @@ -32,15 +32,16 @@ public class ObjectiveC extends AbstractLanguage {

public static final String KEY = "objc";

private Configuration configuration;
private Settings settings;

public ObjectiveC(Settings settings) {

public ObjectiveC(Configuration configuration) {
super(KEY, "Objective-C");
this.configuration = configuration;
this.settings = settings;
}

public String[] getFileSuffixes() {
String[] suffixes = filterEmptyStrings(configuration.getStringArray(ObjectiveCPlugin.FILE_SUFFIXES_KEY));
String[] suffixes = filterEmptyStrings(settings.getStringArray(ObjectiveCPlugin.FILE_SUFFIXES_KEY));
if (suffixes == null || suffixes.length == 0) {
suffixes = StringUtils.split(ObjectiveCPlugin.FILE_SUFFIXES_DEFVALUE, ",");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.config.Settings;
import org.sonar.api.measures.CoverageMeasuresBuilder;
import org.sonar.api.resources.Project;
Expand All @@ -42,17 +43,20 @@ public final class CoberturaSensor implements Sensor {
private final ReportFilesFinder reportFilesFinder;
private final CoberturaParser parser = new CoberturaParser();

public CoberturaSensor() {
this(null);
}
private final Settings conf;
private final FileSystem fileSystem;

public CoberturaSensor(final FileSystem fileSystem, final Settings config) {

public CoberturaSensor(final Settings config) {
reportFilesFinder = new ReportFilesFinder(config, REPORT_PATTERN_KEY,
DEFAULT_REPORT_PATTERN);
this.conf = config;
this.fileSystem = fileSystem;

reportFilesFinder = new ReportFilesFinder(config, REPORT_PATTERN_KEY, DEFAULT_REPORT_PATTERN);
}

public boolean shouldExecuteOnProject(final Project project) {
return ObjectiveC.KEY.equals(project.getLanguageKey());

return project.isRoot() && fileSystem.languages().contains(ObjectiveC.KEY);
}

public void analyse(final Project project, final SensorContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package org.sonar.plugins.objectivec.tests;

import com.sun.swing.internal.plaf.metal.resources.metal_sv;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.batch.SensorContext;
Expand Down Expand Up @@ -142,13 +143,23 @@ private void saveTestsDetails(SensorContext context, TestSuiteReport fileReport)

private void saveClassMeasure(SensorContext context, TestSuiteReport fileReport, Metric metric, double value) {
if ( !Double.isNaN(value)) {
context.saveMeasure(getUnitTestResource(fileReport.getClassKey()), metric, value);

String basename = fileReport.getClassKey().replace('.', '/');

// .m file
context.saveMeasure(getUnitTestResource(basename + ".m"), metric, value);

// Try .m file with + in name
try {
context.saveMeasure(getUnitTestResource(basename.replace('_', '+') + ".m"), metric, value);
} catch (Exception e) {
// Nothing : File was probably already registered successfully
}
}
}

public Resource getUnitTestResource(String classKey) {
public Resource getUnitTestResource(String filename) {

String filename = classKey.replace('.', '/') + ".m";
org.sonar.api.resources.File sonarFile = new org.sonar.api.resources.File(filename);
sonarFile.setQualifier(Qualifiers.UNIT_TEST_FILE);
return sonarFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,30 @@
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;
import org.sonar.api.rules.Violation;
import org.sonar.plugins.objectivec.ObjectiveCPlugin;
import org.sonar.plugins.objectivec.core.ObjectiveC;
import org.sonar.plugins.objectivec.violations.OCLintParser;

public final class OCLintSensor implements Sensor {
public static final String REPORT_PATH_KEY = ObjectiveCPlugin.PROPERTY_PREFIX
+ ".oclint.report";
public static final String DEFAULT_REPORT_PATH = "sonar-reports/oclint.xml";
private final Settings conf;

public OCLintSensor() {
this(null);
}
private final Settings conf;
private final FileSystem fileSystem;

public OCLintSensor(final Settings config) {
conf = config;
public OCLintSensor(final FileSystem moduleFileSystem, final Settings config) {
this.conf = config;
this.fileSystem = moduleFileSystem;
}

public boolean shouldExecuteOnProject(final Project project) {
return ObjectiveC.KEY.equals(project.getLanguageKey());

return project.isRoot() && fileSystem.languages().contains(ObjectiveC.KEY);

}

public void analyse(final Project project, final SensorContext context) {
Expand Down
Loading

0 comments on commit 20b0b8e

Please sign in to comment.