Skip to content

Commit

Permalink
Merge pull request #1 from g4share/sonarv4.5.1
Browse files Browse the repository at this point in the history
start moving to sonar v 4.5.1
  • Loading branch information
xfreebird committed Dec 9, 2014
2 parents 3800155 + a0e3e4e commit e09d053
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 42 deletions.
19 changes: 12 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>org.codehaus.sonar-plugin.objectivec</groupId>
<artifactId>sonar-objective-c-plugin</artifactId>
<version>0.3.3-endava</version>
<version>4.5.1-endava.0</version>

<packaging>sonar-plugin</packaging>

Expand Down Expand Up @@ -77,8 +77,8 @@

<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>

<sonar.version>3.7.4</sonar.version>
<sslr.version>1.16</sslr.version>
<sonar.version>4.5.1</sonar.version>
<sslr.version>1.20</sslr.version>

<!-- Configuration for sonar-packaging-maven-plugin -->
<sonar.pluginClass>org.sonar.plugins.objectivec.ObjectiveCPlugin</sonar.pluginClass>
Expand All @@ -97,7 +97,12 @@
<artifactId>sonar-testing-harness</artifactId>
<version>${sonar.version}</version>
</dependency>

<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-deprecated</artifactId>
<version>${sonar.version}</version>
</dependency>

<dependency>
<groupId>org.codehaus.sonar.sslr</groupId>
<artifactId>sslr-core</artifactId>
Expand All @@ -119,9 +124,9 @@
<version>${sslr.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.sonar.sslr-squid-bridge</groupId>
<groupId>org.codehaus.sonar.sslr-squid-bridge</groupId>
<artifactId>sslr-squid-bridge</artifactId>
<version>2.2</version>
<version>2.4</version>
</dependency>
<dependency>
<groupId>ant</groupId>
Expand Down Expand Up @@ -152,7 +157,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.15</version>
<version>0.9.30</version>
</dependency>
<dependency>
<groupId>org.codehaus.sonar.plugins</groupId>
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/org/sonar/objectivec/ObjectiveCAstScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
import org.sonar.objectivec.api.ObjectiveCGrammar;
import org.sonar.objectivec.api.ObjectiveCMetric;
import org.sonar.objectivec.parser.ObjectiveCParser;
import org.sonar.squid.api.SourceCode;
import org.sonar.squid.api.SourceFile;
import org.sonar.squid.api.SourceProject;
import org.sonar.squid.indexer.QueryByType;
import org.sonar.squidbridge.AstScanner;
import org.sonar.squidbridge.CommentAnalyser;
import org.sonar.squidbridge.SquidAstVisitor;
import org.sonar.squidbridge.SquidAstVisitorContextImpl;
import org.sonar.squidbridge.api.SourceCode;
import org.sonar.squidbridge.api.SourceFile;
import org.sonar.squidbridge.api.SourceProject;
import org.sonar.squidbridge.indexer.QueryByType;
import org.sonar.squidbridge.metrics.CommentsVisitor;
import org.sonar.squidbridge.metrics.LinesOfCodeVisitor;
import org.sonar.squidbridge.metrics.LinesVisitor;

import com.sonar.sslr.api.CommentAnalyser;
import com.sonar.sslr.impl.Parser;
import com.sonar.sslr.squid.AstScanner;
import com.sonar.sslr.squid.SquidAstVisitor;
import com.sonar.sslr.squid.SquidAstVisitorContextImpl;
import com.sonar.sslr.squid.metrics.CommentsVisitor;
import com.sonar.sslr.squid.metrics.LinesOfCodeVisitor;
import com.sonar.sslr.squid.metrics.LinesVisitor;

public class ObjectiveCAstScanner {

Expand Down Expand Up @@ -89,16 +89,16 @@ public String getContents(String comment) {
});

/* Files */
builder.setFilesMetric(ObjectiveCMetric.FILES);
builder.setFilesMetric(ObjectiveCMetric.FILES);

/* Metrics */
builder.withSquidAstVisitor(new LinesVisitor<ObjectiveCGrammar>(ObjectiveCMetric.LINES));
builder.withSquidAstVisitor(new LinesOfCodeVisitor<ObjectiveCGrammar>(ObjectiveCMetric.LINES_OF_CODE));
builder.withSquidAstVisitor(CommentsVisitor.<ObjectiveCGrammar> builder().withCommentMetric(ObjectiveCMetric.COMMENT_LINES)
.withBlankCommentMetric(ObjectiveCMetric.COMMENT_BLANK_LINES)
.withNoSonar(true)
.withIgnoreHeaderComment(conf.getIgnoreHeaderComments())
.build());
builder.withSquidAstVisitor(new LinesVisitor<ObjectiveCGrammar>(ObjectiveCMetric.LINES));
builder.withSquidAstVisitor(new LinesOfCodeVisitor<ObjectiveCGrammar>(ObjectiveCMetric.LINES_OF_CODE));
builder.withSquidAstVisitor(CommentsVisitor.<ObjectiveCGrammar> builder().withCommentMetric(ObjectiveCMetric.COMMENT_LINES)
//todo:there is no method .withBlankCommentMetric(ObjectiveCMetric.COMMENT_BLANK_LINES)
.withNoSonar(true)
.withIgnoreHeaderComment(conf.getIgnoreHeaderComments())
.build());

return builder.build();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/sonar/objectivec/api/ObjectiveCMetric.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
package org.sonar.objectivec.api;

import org.sonar.squid.measures.CalculatedMetricFormula;
import org.sonar.squid.measures.MetricDef;
import org.sonar.squidbridge.measures.CalculatedMetricFormula;
import org.sonar.squidbridge.measures.MetricDef;

public enum ObjectiveCMetric implements MetricDef {
FILES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
import org.sonar.plugins.objectivec.cpd.ObjectiveCCpdMapping;

import com.google.common.collect.ImmutableList;
import org.sonar.plugins.objectivec.tests.SurefireSensor;

import org.sonar.plugins.objectivec.violations.OCLintProfile;
import org.sonar.plugins.objectivec.violations.OCLintProfileImporter;
import org.sonar.plugins.objectivec.violations.OCLintRuleRepository;
import org.sonar.plugins.objectivec.violations.OCLintSensor;
import org.sonar.plugins.surefire.SurefireSensor;

@Properties({
@Property(key = CoberturaSensor.REPORT_PATTERN_KEY, defaultValue = CoberturaSensor.DEFAULT_REPORT_PATTERN, name = "Path to unit test coverage report(s)", description = "Relative to projects' root. Ant patterns are accepted", global = false, project = true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@
import org.sonar.objectivec.api.ObjectiveCMetric;
import org.sonar.objectivec.checks.CheckList;
import org.sonar.plugins.objectivec.core.ObjectiveC;
import org.sonar.squid.api.CheckMessage;
import org.sonar.squid.api.SourceCode;
import org.sonar.squid.api.SourceFile;
import org.sonar.squid.api.SourceFunction;
import org.sonar.squid.indexer.QueryByParent;
import org.sonar.squid.indexer.QueryByType;

import com.sonar.sslr.squid.AstScanner;
import com.sonar.sslr.squid.checks.SquidCheck;
import org.sonar.squidbridge.AstScanner;
import org.sonar.squidbridge.api.CheckMessage;
import org.sonar.squidbridge.api.SourceCode;
import org.sonar.squidbridge.api.SourceFile;
import org.sonar.squidbridge.api.SourceFunction;
import org.sonar.squidbridge.checks.SquidCheck;
import org.sonar.squidbridge.indexer.QueryByParent;
import org.sonar.squidbridge.indexer.QueryByType;
import org.sonar.squidbridge.measures.Metric;


public class ObjectiveCSquidSensor implements Sensor {

Expand Down
15 changes: 14 additions & 1 deletion src/main/java/org/sonar/plugins/objectivec/core/ObjectiveC.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
*/
package org.sonar.plugins.objectivec.core;

import java.util.List;

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

import com.google.common.collect.Lists;

public class ObjectiveC extends AbstractLanguage {

public static final String KEY = "objc";
Expand All @@ -36,11 +40,20 @@ public ObjectiveC(Configuration configuration) {
}

public String[] getFileSuffixes() {
String[] suffixes = configuration.getStringArray(ObjectiveCPlugin.FILE_SUFFIXES_KEY);
String[] suffixes = filterEmptyStrings(configuration.getStringArray(ObjectiveCPlugin.FILE_SUFFIXES_KEY));
if (suffixes == null || suffixes.length == 0) {
suffixes = StringUtils.split(ObjectiveCPlugin.FILE_SUFFIXES_DEFVALUE, ",");
}
return suffixes;
}

private String[] filterEmptyStrings(String[] stringArray) {
List<String> nonEmptyStrings = Lists.newArrayList();
for (String string : stringArray) {
if (StringUtils.isNotBlank(string.trim())) {
nonEmptyStrings.add(string.trim());
}
}
return nonEmptyStrings.toArray(new String[nonEmptyStrings.size()]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.sonar.plugins.objectivec.ObjectiveCPlugin;
import org.sonar.plugins.objectivec.core.ObjectiveC;


public final class CoberturaSensor implements Sensor {

public static final String REPORT_PATTERN_KEY = ObjectiveCPlugin.PROPERTY_PREFIX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,17 @@ protected void collect(Project project, SensorContext context, File reportsDir)
SUREFIRE_PARSER.collect(project, context, reportsDir);
}

private static final AbstractSurefireParser SUREFIRE_PARSER = new AbstractSurefireParser() {
private static final AbstractSurefireParser SUREFIRE_PARSER = null;

/*new AbstractSurefireParser() {
@Override
protected Resource<?> getUnitTestResource(String classKey) {
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;
}
};
};*/

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import org.junit.Test;
import org.sonar.objectivec.api.ObjectiveCMetric;
import org.sonar.squid.api.SourceFile;
import org.sonar.squidbridge.api.SourceFile;

public class ObjectiveCAstScannerTest {

Expand Down

0 comments on commit e09d053

Please sign in to comment.