Skip to content

Commit

Permalink
Updates for coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSVector committed May 20, 2024
1 parent 7ed3f4f commit efd0813
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ private void setLineMode(final LinesDataSet dataSet) {
// If the dataset contains MCDC, Function or Function Call Coverage
if (dataSet.containsSeries(CoverageSeriesBuilder.MCDC_PAIR_COVERAGE)
|| dataSet.containsSeries(CoverageSeriesBuilder.FUNCTION_COVERAGE)
|| dataSet.containsSeries(CoverageSeriesBuilder.FUNCTION_CALL_COVERAGE))
{
|| dataSet.containsSeries(CoverageSeriesBuilder.FUNCTION_CALL_COVERAGE)) {
lineMode = FilledMode.LINES;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ class CoverageSourcePrinter implements Serializable {
coveredPerLine = file.getCoveredCounters();
missedPerLine = file.getMissedCounters();

// adding in VectorCAST metrics

mcdcPairCoveredPerLine = file.getMcdcPairCoveredCounters();
mcdcPairMissedPerLine = file.getMcdcPairMissedCounters();

functionCallCoveredPerLine = file.getFunctionCallCoveredCounters();
functionCallMissedPerLine = file.getFunctionCallMissedCounters();
}

private String getColumnHeader(String third) {
private String getColumnHeader(final String third) {
return tr().withClass(CoverageSourcePrinter.UNDEFINED).with(
td().withClass("line").with(text("Line")),
td().withClass("line").with(text("St/Br")),
Expand All @@ -61,15 +59,14 @@ private String getColumnHeader(String third) {
).render();
}

private String getColumnHeader(String third, String fourth) {
private String getColumnHeader(final String third, final String fourth) {
return tr().withClass(CoverageSourcePrinter.UNDEFINED).with(
td().withClass("line").with(text("Line")),
td().withClass("line").with(text("St/Br")),
td().withClass("line").with(text(third)),
td().withClass("line").with(text(fourth)),
td().withClass("line").with(text(NBSP))
).render();

}

// adding column header so show what is being presented in the file view
Expand Down Expand Up @@ -103,7 +100,7 @@ else if (hasMcdc && hasFc) {
return trString;
}

private String getTr (final int line, final String sourceCode, final boolean isPainted) {
private String getTr(final int line, final String sourceCode, final boolean isPainted) {
return tr()
.withClass(isPainted ? getColorClass(line) : CoverageSourcePrinter.UNDEFINED)
.condAttr(isPainted, "data-html-tooltip", isPainted ? getTooltip(line) : StringUtils.EMPTY)
Expand All @@ -117,7 +114,7 @@ private String getTr (final int line, final String sourceCode, final boolean isP
.render();
}

private String getTr (final int line, final String sourceCode, final boolean isPainted, String third, String fouth) {
private String getTr(final int line, final String sourceCode, final boolean isPainted, final String third, final String fouth) {
return tr()
.withClass(isPainted ? getColorClass(line) : CoverageSourcePrinter.UNDEFINED)
.condAttr(isPainted, "data-html-tooltip", isPainted ? getTooltip(line) : StringUtils.EMPTY)
Expand All @@ -135,7 +132,7 @@ private String getTr (final int line, final String sourceCode, final boolean isP
.render();
}

private String getTr (final int line, final String sourceCode, final boolean isPainted, String third) {
private String getTr(final int line, final String sourceCode, final boolean isPainted, String third) {
return tr().withClass(isPainted ? getColorClass(line) : CoverageSourcePrinter.UNDEFINED)
.condAttr(isPainted, "data-html-tooltip", isPainted ? getTooltip(line) : StringUtils.EMPTY)
.with(td().withClass("line").with(a().withName(String.valueOf(line)).withText(String.valueOf(line))),
Expand All @@ -160,24 +157,19 @@ public String renderLine(final int line, final String sourceCode) {
if (!hasMcdc && hasFc) {
trString = getTr(line, sourceCode, isPainted, getFunctionCallSummaryColumn(line));
}

// If this file only has Line, St/Br, and MCDC
else if (hasMcdc && !hasFc) {
trString = getTr(line, sourceCode, isPainted, getMcdcPairSummaryColumn(line));
}

// If this file only has Line, St/Br, FunctionCall and MCDC
else if (hasMcdc && hasFc) {
trString = getTr(line, sourceCode, isPainted, getFunctionCallSummaryColumn(line), getMcdcPairSummaryColumn(line));
}

// If this file only has Line and St/Br
else {
trString = getTr(line, sourceCode, isPainted);
}

}
return trString;

}

private String cleanupCode(final String content) {
Expand Down Expand Up @@ -229,15 +221,15 @@ public String getMcdcPairTooltop(final int line) {
var mcdcPairCovered = getMcdcPairCovered(line);
var mcdcPairMissed = getMcdcPairMissed(line);
String mcdcPairTooltip = "";

if (mcdcPairCovered + mcdcPairMissed > 1) {
if (mcdcPairMissed == 0) {
mcdcPairTooltip = String.format("All MC/DC pairs covered: %d/%d", mcdcPairCovered, mcdcPairCovered + mcdcPairMissed);
} else {
}
else {
mcdcPairTooltip = String.format("MC/DC pairs partially covered: %d/%d", mcdcPairCovered, mcdcPairCovered + mcdcPairMissed);
}

}

return mcdcPairTooltip;
}

Expand All @@ -249,14 +241,14 @@ public String getfunctionCallTooltop(final int line) {
if (functionCallCovered + functionCallMissed > 1) {
if (functionCallMissed == 0) {
functionCallTooltip = String.format("All function calls covered: %d/%d", functionCallCovered, functionCallCovered + functionCallMissed);
} else {
}
else {
functionCallTooltip = String.format("Function calls partially covered: %d/%d", functionCallCovered, functionCallCovered + functionCallMissed);
}
} else if (functionCallCovered == 1) {
}
else if (functionCallCovered == 1) {
functionCallTooltip = "Function call covered";
}

return functionCallTooltip;
}

Expand Down Expand Up @@ -330,7 +322,7 @@ int findIndexOfLine(final int line) {

public Boolean hasAnyMcdcPairCoverage() {
Boolean hasMcDc = false;
for ( int i = 0; i < mcdcPairCoveredPerLine.length && !hasMcDc; i++) {
for (Metric.MCDC_PAIRint i = 0; i < mcdcPairCoveredPerLine.length && !hasMcDc; i++) {
if ((mcdcPairCoveredPerLine[i] + mcdcPairMissedPerLine[i]) > 0) {
hasMcDc = true;
}
Expand All @@ -341,7 +333,7 @@ public Boolean hasAnyMcdcPairCoverage() {

public Boolean hasAnyFunctionCallCoverage() {
Boolean hasFc = false;
for ( int i = 0; i < functionCallMissedPerLine.length && !hasFc; i++) {
for (int i = 0; i < functionCallMissedPerLine.length && !hasFc; i++) {
if ((functionCallCoveredPerLine[i] + functionCallMissedPerLine[i]) > 0) {
hasFc = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void configureValueColumn(final String key, final Metric metric, final S
.withResponsivePriority(1)
.build();
columns.add(lineCoverage);
if (deltaHeaderLabel != null && deltaHeaderLabel != "") {
if (deltaHeaderLabel != null && deltaHeaderLabel.compareTo("") != 0) {
TableColumn lineCoverageDelta = new ColumnBuilder().withHeaderLabel(deltaHeaderLabel)
.withDataPropertyKey(key + "Delta")
.withDetailedCell()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ public enum Parser {
COBERTURA(Messages._Parser_Cobertura(), ParserType.COVERAGE,
"**/cobertura.xml",
"symbol-footsteps-outline plugin-ionicons-api"),
VECTORCAST(Messages._Parser_VectorCAST(), ParserType.COVERAGE,
"xml_data/cobertura/coverage_results*.xml",
VECTORCAST(Messages._Parser_VectorCAST(), ParserType.COVERAGE,
"xml_data/cobertura/coverage_results*.xml",
"symbol-footsteps-outline plugin-ionicons-api"),
JACOCO(Messages._Parser_JaCoCo(), ParserType.COVERAGE,
"**/jacoco.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class CoverageViewModel extends DefaultAsyncTableContentProvider implemen
private static final ElementFormatter FORMATTER = new ElementFormatter();
private static final Set<Metric> TREE_METRICS = Set.of(
Metric.LINE, Metric.BRANCH, Metric.MUTATION, Metric.TEST_STRENGTH, Metric.COMPLEXITY, Metric.TESTS,
Metric.MCDC_PAIR,Metric.FUNCTION_CALL,Metric.FUNCTION);
Metric.MCDC_PAIR, Metric.FUNCTION_CALL, Metric.FUNCTION);
private static final String UNDEFINED = "-";
private final Run<?, ?> owner;
private final String displayName;
Expand Down

0 comments on commit efd0813

Please sign in to comment.