-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
158bf60
commit 58d0d1f
Showing
9 changed files
with
211 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/main/java/com/buransky/plugins/scoverage/language/ScalaFile.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/main/java/com/buransky/plugins/scoverage/measure/ScalaMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.buransky.plugins.scoverage.measure; | ||
|
||
import org.sonar.api.measures.CoreMetrics; | ||
import org.sonar.api.measures.Metric; | ||
import org.sonar.api.measures.Metrics; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public final class ScalaMetrics implements Metrics { | ||
public static final String STATEMENT_COVERAGE_KEY = "scoverage"; | ||
public static final Metric STATEMENT_COVERAGE = new Metric.Builder(STATEMENT_COVERAGE_KEY, | ||
"Statement coverage", Metric.ValueType.PERCENT) | ||
.setDescription("Statement coverage by unit tests") | ||
.setDirection(Metric.DIRECTION_BETTER) | ||
.setQualitative(true) | ||
.setDomain(CoreMetrics.DOMAIN_TESTS) | ||
.setWorstValue(0.0) | ||
.setBestValue(100.0) | ||
.create(); | ||
|
||
@Override | ||
public List<Metric> getMetrics() { | ||
return Arrays.asList(STATEMENT_COVERAGE); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/buransky/plugins/scoverage/resource/ScalaDirectory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.buransky.plugins.scoverage.resource; | ||
|
||
import com.buransky.plugins.scoverage.language.Scala; | ||
import org.sonar.api.resources.Directory; | ||
import org.sonar.api.resources.Language; | ||
import org.sonar.api.resources.Resource; | ||
|
||
public class ScalaDirectory extends Directory { | ||
private final String name; | ||
private final ScalaDirectory parent; | ||
|
||
public ScalaDirectory(String key) { | ||
super(key); | ||
|
||
int i = getKey().lastIndexOf(SEPARATOR); | ||
if (i > 0) { | ||
parent = new ScalaDirectory(key.substring(0, i)); | ||
name = key.substring(i + 1); | ||
} | ||
else { | ||
name = key; | ||
parent = null; | ||
} | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public Language getLanguage() { | ||
return Scala.INSTANCE; | ||
} | ||
|
||
@Override | ||
public Resource getParent() { | ||
return parent; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/com/buransky/plugins/scoverage/resource/ScalaFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.buransky.plugins.scoverage.resource; | ||
|
||
import com.buransky.plugins.scoverage.language.Scala; | ||
import org.sonar.api.resources.File; | ||
import org.sonar.api.resources.Language; | ||
import org.sonar.api.resources.Resource; | ||
|
||
public class ScalaFile extends Resource<ScalaDirectory> { | ||
private final File file; | ||
private ScalaDirectory parent; | ||
|
||
public ScalaFile(String key) { | ||
if (key == null) | ||
throw new IllegalArgumentException("Key cannot be null!"); | ||
|
||
file = new File(key); | ||
setKey(key); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return file.getName(); | ||
} | ||
|
||
@Override | ||
public String getLongName() { | ||
return file.getLongName(); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return file.getDescription(); | ||
} | ||
|
||
@Override | ||
public Language getLanguage() { | ||
return Scala.INSTANCE; | ||
} | ||
|
||
@Override | ||
public String getScope() { | ||
return file.getScope(); | ||
} | ||
|
||
@Override | ||
public String getQualifier() { | ||
return file.getQualifier(); | ||
} | ||
|
||
@Override | ||
public ScalaDirectory getParent() { | ||
if (parent == null) { | ||
parent = new ScalaDirectory(file.getParent().getKey()); | ||
} | ||
return parent; | ||
} | ||
|
||
@Override | ||
public boolean matchFilePattern(String antPattern) { | ||
return file.matchFilePattern(antPattern); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return file.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/buransky/plugins/scoverage/widget/ScoverageWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.buransky.plugins.scoverage.widget; | ||
|
||
import org.sonar.api.web.AbstractRubyTemplate; | ||
import org.sonar.api.web.RubyRailsWidget; | ||
|
||
public class ScoverageWidget extends AbstractRubyTemplate implements RubyRailsWidget { | ||
|
||
public String getId() { | ||
return "scoverage"; | ||
} | ||
|
||
public String getTitle() { | ||
return "Statement coverage"; | ||
} | ||
|
||
@Override | ||
protected String getTemplatePath() { | ||
return "/com/buransky/plugins/scoverage/widget.html.erb"; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/resources/com/buransky/plugins/scoverage/widget.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<% measure=measure('scoverage') | ||
if measure | ||
%> | ||
<div class="dashbox"> | ||
<h3> | ||
Statement coverage : <%= format_measure(measure, :suffix => ' %') %> | ||
<%= dashboard_configuration.selected_period? ? format_variation(measure) : trend_icon(measure) -%> | ||
</h3> | ||
</div> | ||
<% end %> |