Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coverage metrics from VectorCAST #153

Merged
merged 44 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bc397c6
VectorCAST Updates
TimSVector May 3, 2024
52752c9
Updates for VectorCAST extended code coverage
TimSVector May 7, 2024
925d06b
README updates
TimSVector May 7, 2024
d66e031
clean up
TimSVector May 7, 2024
58927a6
Updates for POM.xml
TimSVector May 17, 2024
7ed3f4f
Updates for coding standards
TimSVector May 20, 2024
efd0813
Updates for coding standards
TimSVector May 20, 2024
9132317
update to fix error
TimSVector May 20, 2024
8a250a5
Updates for GodClass and CyclomaticComplexity
TimSVector May 20, 2024
001c60e
Updates per maintainer
TimSVector May 30, 2024
c073db7
Update for compilation error
TimSVector May 30, 2024
6a1bdf3
Refactoring CoverageSourcePrinter
TimSVector May 30, 2024
86fb993
Updates for coding standards
TimSVector May 31, 2024
125fa2b
fixing serialVersionUID issue
TimSVector May 31, 2024
5d7b6da
updates for coding standards
TimSVector May 31, 2024
9ec24f6
fixing comment errors
TimSVector May 31, 2024
f88da58
JavaDoc update
TimSVector May 31, 2024
80de144
javadoc updates
TimSVector May 31, 2024
59ad32a
Updates to fix method/function coverage
TimSVector Jun 10, 2024
85b5eee
Updates for coding standards
TimSVector Jun 10, 2024
e593276
Trial update for using VectorCAST Source Painter
TimSVector Jun 11, 2024
f3aefe7
Update for testing
TimSVector Jun 11, 2024
1c43685
Merge remote-tracking branch 'origin/main' into vc_coverage
uhafner Jun 18, 2024
a7b144f
Push to removed Method coverage from unwanted coverage modes
TimSVector Jun 18, 2024
d83d934
Merge branch 'vc_coverage' of https://github.com/TimSVector/coverage-…
TimSVector Jun 18, 2024
7550cb9
Updated for PMD warning
TimSVector Jun 18, 2024
1ae6671
Fix test: method coverage is not in the table model anymore.
uhafner Jun 19, 2024
a33e467
Fix test: new exception message.
uhafner Jun 19, 2024
04180a7
Updates for testing vectorcast metrics with VectorCastCoverageChecksP…
TimSVector Jun 20, 2024
c2b21dc
Merge branch 'vc_coverage' of https://github.com/TimSVector/coverage-…
TimSVector Jun 20, 2024
aff8bf9
Update for PMD and CheckStyle warnings
TimSVector Jun 20, 2024
53a4a52
Remove unused method coverage
uhafner Jun 21, 2024
105ab43
Remove whitespace
uhafner Jun 21, 2024
09156c6
Remove unused method coverage
uhafner Jun 21, 2024
fb96482
Remove unused import
uhafner Jun 21, 2024
6b75d33
Added Test for VectorCastCoveragePluginITest and VectorCastCoverageRe…
TimSVector Jun 21, 2024
541321e
Merge branch 'vc_coverage' of https://github.com/TimSVector/coverage-…
TimSVector Jun 21, 2024
24ce46c
Update for PMD and CheckStyle warnings
TimSVector Jun 21, 2024
1dce1f6
Removed placeholder test results file - no longer needed
TimSVector Jun 21, 2024
c4bcf82
Make the visible metrics overridable.
uhafner Jun 21, 2024
32464ee
Delete extra test class.
uhafner Jun 21, 2024
fbaa1df
Bump version of coverage model to 0.46.0.
uhafner Jun 26, 2024
ff05588
Move all integration tests into single test class.
uhafner Jun 26, 2024
7e3260b
Remove qualified call.
uhafner Jun 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The Jenkins Coverage Plug-in collects reports of code coverage or mutation cover
- [JaCoCo](https://www.jacoco.org/jacoco): Code Coverage
- [Cobertura](https://cobertura.github.io/cobertura/): Code Coverage
- [OpenCover](https://github.com/OpenCover/opencover): Code Coverage
- [VectorCAST](https://www.vector.com/int/en/products/products-a-z/software/vectorcast): Code Coverage including MC/DC, Function, Function Call coverages
- [PIT](https://pitest.org/): Mutation Coverage
- [JUnit](https://ant.apache.org/manual/Tasks/junitreport.html): Test Results
- [NUnit](https://nunit.org/): Test Results
Expand Down Expand Up @@ -107,6 +108,7 @@ The Coverage Plug-in supports the following report formats:
- [JaCoCo](https://www.jacoco.org/jacoco): Code Coverage
- [Cobertura](https://cobertura.github.io/cobertura/): Code Coverage
- [OpenCover](https://github.com/OpenCover/opencover): Code Coverage
- [VectorCAST](https://www.vector.com/int/en/products/products-a-z/software/vectorcast) Code Coverage including MC/DC, Function, Function Call coverages
- [PIT](https://pitest.org/): Mutation Coverage
- [JUnit](https://ant.apache.org/manual/Tasks/junitreport.html): Test Results
- [NUnit](https://nunit.org/): Test Results
Expand Down
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<gitHubRepo>jenkinsci/coverage-plugin</gitHubRepo>

<!-- Library Dependencies Versions -->
<coverage-model.version>0.45.0</coverage-model.version>
<coverage-model.version>0.46.0</coverage-model.version>
<jsoup.version>1.17.2</jsoup.version>

<!-- Jenkins Plug-in Dependencies Versions -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class CoverageSeriesBuilder extends SeriesBuilder<CoverageStatistics> {
static final String BRANCH_COVERAGE = "branch";
static final String MUTATION_COVERAGE = "mutation";
static final String TEST_STRENGTH = "test-strength";
static final String MCDC_PAIR_COVERAGE = "mcdc-pair";
static final String FUNCTION_CALL_COVERAGE = "function-call";
static final String METHOD_COVERAGE = "method";

@Override
protected Map<String, Double> computeSeries(final CoverageStatistics statistics) {
Expand All @@ -29,6 +32,10 @@ protected Map<String, Double> computeSeries(final CoverageStatistics statistics)
add(statistics, Metric.BRANCH, BRANCH_COVERAGE, series);
add(statistics, Metric.MUTATION, MUTATION_COVERAGE, series);
add(statistics, Metric.TEST_STRENGTH, TEST_STRENGTH, series);
add(statistics, Metric.MCDC_PAIR, MCDC_PAIR_COVERAGE, series);
add(statistics, Metric.FUNCTION_CALL, FUNCTION_CALL_COVERAGE, series);
add(statistics, Metric.METHOD, METHOD_COVERAGE, series);

return series;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@
* @see JacksonFacade
*/
public class CoverageTrendChart {
/* Line Mode used to indicate whether is should be a filled line chart or line chart */
private static FilledMode lineMode;

/**
* Sets the line mode for the trend chart.
*
* @param dataSet
*
*/
private void setLineMode(final LinesDataSet dataSet) {
// If the dataset contains MCDC or Function Call Coverage
if (dataSet.containsSeries(CoverageSeriesBuilder.MCDC_PAIR_COVERAGE)
|| dataSet.containsSeries(CoverageSeriesBuilder.FUNCTION_CALL_COVERAGE)) {
lineMode = FilledMode.LINES;
}
else {
lineMode = FilledMode.FILLED;
}
}

/**
* Creates the chart for the specified results.
*
Expand All @@ -38,11 +58,13 @@ public LinesChartModel create(final Iterable<BuildResult<CoverageStatistics>> re
final ChartModelConfiguration configuration) {
CoverageSeriesBuilder builder = new CoverageSeriesBuilder();
LinesDataSet dataSet = builder.createDataSet(configuration, results);

setLineMode(dataSet);

LinesChartModel model = new LinesChartModel(dataSet);
if (dataSet.isNotEmpty()) {
LineSeries lineSeries = new LineSeries(Messages.Metric_LINE(),
JenkinsPalette.GREEN.normal(), StackedMode.SEPARATE_LINES, FilledMode.FILLED,
JenkinsPalette.GREEN.normal(), StackedMode.SEPARATE_LINES, lineMode,
dataSet.getSeries(CoverageSeriesBuilder.LINE_COVERAGE));
model.addSeries(lineSeries);
model.useContinuousRangeAxis();
Expand All @@ -55,6 +77,13 @@ public LinesChartModel create(final Iterable<BuildResult<CoverageStatistics>> re
JenkinsPalette.GREEN.dark());
addSeries(dataSet, model, Messages.Metric_TEST_STRENGTH(), CoverageSeriesBuilder.TEST_STRENGTH,
JenkinsPalette.GREEN.light());

addSeries(dataSet, model, Messages.Metric_MCDC_PAIR(), CoverageSeriesBuilder.MCDC_PAIR_COVERAGE,
JenkinsPalette.RED.light());
addSeries(dataSet, model, Messages.Metric_METHOD(), CoverageSeriesBuilder.METHOD_COVERAGE,
JenkinsPalette.RED.normal());
addSeries(dataSet, model, Messages.Metric_FUNCTION_CALL(), CoverageSeriesBuilder.FUNCTION_CALL_COVERAGE,
JenkinsPalette.RED.dark());
}
return model;
}
Expand All @@ -63,7 +92,7 @@ private static void addSeries(final LinesDataSet dataSet, final LinesChartModel
final String name, final String seriesId, final String color) {
if (dataSet.containsSeries(seriesId)) {
LineSeries branchSeries = new LineSeries(name,
color, StackedMode.SEPARATE_LINES, FilledMode.FILLED,
color, StackedMode.SEPARATE_LINES, lineMode,
dataSet.getSeries(seriesId));

model.addSeries(branchSeries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ public String getDisplayName(final Metric metric) {
return Messages.Metric_LOC();
case TESTS:
return Messages.Metric_TESTS();
case MCDC_PAIR:
return Messages.Metric_MCDC_PAIR();
case FUNCTION_CALL:
return Messages.Metric_FUNCTION_CALL();
default:
throw new NoSuchElementException("No display name found for metric " + metric);
}
Expand Down Expand Up @@ -472,6 +476,10 @@ public String getLabel(final Metric metric) {
return Messages.Metric_Short_LOC();
case TESTS:
return Messages.Metric_Short_TESTS();
case MCDC_PAIR:
return Messages.Metric_Short_MCDC_PAIR();
case FUNCTION_CALL:
return Messages.Metric_Short_FUNCTION_CALL();
default:
throw new NoSuchElementException("No label found for metric " + metric);
}
Expand Down Expand Up @@ -527,6 +535,8 @@ public ListBoxModel getMetricItems() {
add(options, Metric.COMPLEXITY_MAXIMUM);
add(options, Metric.LOC);
add(options, Metric.TESTS);
add(options, Metric.MCDC_PAIR);
add(options, Metric.FUNCTION_CALL);
return options;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
*/
class CoverageSourcePrinter implements Serializable {
private static final long serialVersionUID = -6044649044983631852L;
private static final Sanitizer SANITIZER = new Sanitizer();
protected static final Sanitizer SANITIZER = new Sanitizer();

static final String UNDEFINED = "noCover";
static final String NO_COVERAGE = "coverNone";
static final String FULL_COVERAGE = "coverFull";
static final String PARTIAL_COVERAGE = "coverPart";
private static final String NBSP = "&nbsp;";
protected static final String NBSP = "&nbsp;";

private final String path;
private final int[] linesToPaint;
Expand Down Expand Up @@ -54,7 +54,7 @@ public String renderLine(final int line, final String sourceCode) {
.render();
}

private String cleanupCode(final String content) {
protected String cleanupCode(final String content) {
return content.replace("\n", StringUtils.EMPTY)
.replace("\r", StringUtils.EMPTY)
.replace(" ", NBSP)
Expand Down Expand Up @@ -133,4 +133,8 @@ int getCounter(final int line, final int... counters) {
}
return 0;
}
}

public String getColumnHeader() {
return StringUtils.EMPTY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public void processSourceCodePainting(final Node rootNode, final List<FileNode>
private CoverageSourcePrinter createFileModel(final Node rootNode, final FileNode fileNode) {
if (rootNode.getValue(Metric.MUTATION).isPresent()) {
return new MutationSourcePrinter(fileNode);
}
else if (rootNode.getValue(Metric.MCDC_PAIR).isPresent()
|| rootNode.getValue(Metric.FUNCTION_CALL).isPresent()) {
return new VectorCastSourcePrinter(fileNode);
}
else {
return new CoverageSourcePrinter(fileNode);
Expand Down Expand Up @@ -206,6 +210,9 @@ private int paint(final CoverageSourcePrinter paint, final String relativePathId
Path fullSourcePath = paintedFilesFolder.resolve(sanitizedFileName);
try (BufferedWriter output = Files.newBufferedWriter(fullSourcePath)) {
List<String> lines = Files.readAllLines(Paths.get(resolvedPath.getRemote()), charset);

// added a header to display what is being shown in each column
output.write(paint.getColumnHeader());
for (int line = 0; line < lines.size(); line++) {
output.write(paint.renderLine(line + 1, lines.get(line)));
}
Expand Down
Loading
Loading