Skip to content

Commit

Permalink
Updated version to 1.1.0 (per #4; #5 updated bumped it to 1.0.1); man…
Browse files Browse the repository at this point in the history
…ually merged the easier files.
  • Loading branch information
bsclifton committed Sep 20, 2015
1 parent 2faa491 commit a853e16
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.godaddy.sonar</groupId>
<artifactId>sonar-ruby-plugin</artifactId>
<packaging>sonar-plugin</packaging>
<version>1.0.1</version>
<version>1.1.0</version>

<name>Sonar Ruby Plugin</name>
<description>Plugin to report ruby code coverage into sonar</description>
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/godaddy/sonar/ruby/RubyPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
import com.godaddy.sonar.ruby.core.Ruby;
import com.godaddy.sonar.ruby.core.RubySourceCodeColorizer;
import com.godaddy.sonar.ruby.core.profiles.SonarWayProfile;
import com.godaddy.sonar.ruby.metricfu.CaneRulesRepository;
import com.godaddy.sonar.ruby.metricfu.MetricfuComplexitySensor;
import com.godaddy.sonar.ruby.metricfu.MetricfuComplexityYamlParserImpl;
import com.godaddy.sonar.ruby.metricfu.MetricfuDuplicationSensor;
import com.godaddy.sonar.ruby.metricfu.MetricfuIssueSensor;
import com.godaddy.sonar.ruby.metricfu.MetricfuYamlParser;
import com.godaddy.sonar.ruby.metricfu.ReekRulesRepository;
import com.godaddy.sonar.ruby.metricfu.RoodiRulesRepository;
import com.godaddy.sonar.ruby.simplecovrcov.SimpleCovRcovJsonParserImpl;
import com.godaddy.sonar.ruby.simplecovrcov.SimpleCovRcovSensor;

Expand All @@ -29,6 +35,15 @@ public final class RubyPlugin extends SonarPlugin
public static final String METRICFU_REPORT_PATH_PROPERTY = "sonar.metricfu.reportPath";
public static final String METRICFU_COMPLEXITY_METRIC_PROPERTY = "sonar.metricfu.complexityMetric";

public static final String KEY_REPOSITORY_CANE = "cane";
public static final String NAME_REPOSITORY_CANE = "Cane";

public static final String KEY_REPOSITORY_REEK = "reek";
public static final String NAME_REPOSITORY_REEK = "Reek";

public static final String KEY_REPOSITORY_ROODI = "roodi";
public static final String NAME_REPOSITORY_ROODI = "Roodi";

public List<Object> getExtensions()
{
List<Object> extensions = new ArrayList<Object>();
Expand All @@ -39,6 +54,11 @@ public List<Object> getExtensions()
extensions.add(RubySourceCodeColorizer.class);
extensions.add(RubySensor.class);
extensions.add(MetricfuComplexitySensor.class);
extensions.add(MetricfuDuplicationSensor.class);
extensions.add(MetricfuIssueSensor.class);
extensions.add(CaneRulesRepository.class);
extensions.add(ReekRulesRepository.class);
extensions.add(RoodiRulesRepository.class);

// Profiles
extensions.add(SonarWayProfile.class);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/godaddy/sonar/ruby/core/Ruby.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public Ruby()

public String[] getFileSuffixes()
{
return new String[]{"rb"};
return new String[]{".rb"};
}
}
30 changes: 11 additions & 19 deletions src/main/java/com/godaddy/sonar/ruby/core/RubyFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class RubyFile extends Resource
/**
*
*/
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 678217195520058883L;
private String filename;
private String longName;
private String packageKey;
Expand All @@ -36,34 +36,26 @@ public RubyFile(File file, List<InputFile> sourceDirs)
throw new IllegalArgumentException("File cannot be null");
}

String dirName = null;
this.filename = StringUtils.substringBeforeLast(file.getName(), ".");

this.packageKey = RubyPackage.DEFAULT_PACKAGE_NAME;
this.filename = StringUtils.substringBeforeLast(file.getName(), ".");
this.longName = this.filename;
String key = new StringBuilder().append(this.packageKey).append(".").append(this.filename).toString();

if (sourceDirs != null)
{
PathResolver resolver = new PathResolver();
Collection<File> colSrcDirs = toFileCollection(sourceDirs);
RelativePath relativePath = resolver.relativePath(colSrcDirs, file);
if (relativePath != null)
{
dirName = relativePath.dir().toString();

this.filename = StringUtils.substringBeforeLast(relativePath.path(), ".");

if (dirName.indexOf(File.separator) >= 0)
{
this.packageKey = StringUtils.strip(dirName, File.separator);
this.packageKey = StringUtils.replace(this.packageKey, File.separator, ".");
this.packageKey = StringUtils.substringAfterLast(this.packageKey, ".");
}
if (relativePath != null && relativePath.path().indexOf(File.separator) >= 0)
{
this.packageKey = StringUtils.substringBeforeLast(relativePath.path(), File.separator);
this.packageKey = StringUtils.strip(this.packageKey, File.separator);
key = this.packageKey + File.separator + this.filename;
this.longName = key;
}
}

String key = new StringBuilder().append(this.packageKey).append(".").append(this.filename).toString();
this.longName = key;

setKey(key);
}

Expand Down Expand Up @@ -109,7 +101,7 @@ public String getQualifier()
public boolean matchFilePattern(String antPattern)
{
String patternWithoutFileSuffix = StringUtils.substringBeforeLast(antPattern, ".");
WildcardPattern matcher = WildcardPattern.create(patternWithoutFileSuffix, ".");
WildcardPattern matcher = WildcardPattern.create(patternWithoutFileSuffix, File.separator);
String key = getKey();
return matcher.match(key);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/godaddy/sonar/ruby/core/RubyPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@SuppressWarnings("rawtypes")
public class RubyPackage extends Resource
{
private static final long serialVersionUID = -8901912464767594618L;
public static final String DEFAULT_PACKAGE_NAME = "[default]";

public RubyPackage(String key)
Expand Down
25 changes: 24 additions & 1 deletion src/test/resources/test-data/results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,27 @@
:complexity: 3
:lines: 4
:filename: lib/some_path/foo_bar.rb
:hotspots:
:hotspots:
:flay:
:total_score: '167325'
:matches:
- :reason: 1) IDENTICAL code found in :class (mass*9 = 2754)
:matches:
- :name: lib/Scvmm/test/MiqScvmmBrokerServer.rb
:line: '13'
- :name: lib/VMwareWebService/MiqVimClientBase.rb
:line: '104'
- :name: lib/VMwareWebService/MiqVimCoreUpdater.rb
:line: '391'
- :name: lib/VMwareWebService/MiqVimEventMonitor.rb
:line: '181'
- :name: lib/VMwareWebService/MiqVimInventory.rb
:line: '2503'
- :name: lib/WriteVm/test/gen_payload.rb
:line: '45'
- :name: lib/fs/MetakitFS/test/MkSelectFiles.rb
:line: '21'
- :name: lib/fs/test/copyTest.rb
:line: '23'
- :name: lib/fs/test/updateTest.rb
:line: '26'

0 comments on commit a853e16

Please sign in to comment.