Skip to content

Commit e682a94

Browse files
authored
fix: issue 34 - branchs => branches (#36)
* fix: branchs => branches * feat: hide branches column
1 parent b795fd1 commit e682a94

File tree

10 files changed

+96
-42
lines changed

10 files changed

+96
-42
lines changed

.github/workflows/example.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,14 @@ jobs:
218218
with-chart: true
219219
show-percentage-change-on-table: true
220220
signature: "clover file to comment - only one package"
221+
222+
- name: clover file to comment - hide branches column
223+
uses: ./.
224+
with:
225+
dir-prefix: /var/www/html
226+
file: clover.onepackage.xml
227+
base-file: clover.onepackage.base.xml
228+
with-chart: true
229+
show-percentage-change-on-table: true
230+
with-branches: false
231+
signature: "clover file to comment - hide branches column"

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
10+
### Added
11+
12+
- option `with-branches` to control if the column `Branches` show be rendered
13+
14+
### Fixed
15+
16+
- plural of `branch` is `branches` ([#34](https://github.com/lucassabreu/comment-coverage-clover/issues/34))
17+
918
## [0.9.2] - 2023-03-21
1019

1120
### Fixed

README.md

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ inputs:
4242
with-table:
4343
description: Add a table with a list of files and its coverage
4444
default: true
45+
with-branches:
46+
description: Adds the column "Branches" with the branching coverage
47+
default: true
4548
show-percentage-change-on-table:
4649
description: Show in percentage how much the file coverage changed per file
4750
default: false

bin/index.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89435,7 +89435,7 @@ var fromString = function (str) {
8943589435
return new Stats({
8943689436
lines: new Coverage(m.statements, m.coveredstatements),
8943789437
methods: new Coverage(m.methods, m.coveredmethods),
89438-
branchs: new Coverage(m.conditionals, m.coveredconditionals)
89438+
branches: new Coverage(m.conditionals, m.coveredconditionals)
8943989439
}, allFiles
8944089440
.map(function (f) {
8944189441
f._attributes.name = f._attributes.path || f._attributes.name;
@@ -89450,7 +89450,7 @@ var fromString = function (str) {
8945089450
metrics: {
8945189451
lines: new Coverage(m.statements, m.coveredstatements),
8945289452
methods: new Coverage(m.methods, m.coveredmethods),
89453-
branchs: new Coverage(m.conditionals, m.coveredconditionals)
89453+
branches: new Coverage(m.conditionals, m.coveredconditionals)
8945489454
}
8945589455
}));
8945689456
}, new Map()));
@@ -89543,10 +89543,11 @@ var limitedFragment = function (limit, noSpaceLeft) {
8954389543
}
8954489544
return html;
8954589545
};
89546-
var line = function (name, m, lang, o, showDelta) {
89546+
var line = function (name, m, lang, o, showDelta, showBranchesColumn) {
8954789547
if (o === void 0) { o = null; }
8954889548
if (showDelta === void 0) { showDelta = false; }
89549-
return tr.apply(void 0, __spreadArray([td(name)], ["lines", "methods", "branchs"].map(function (p) {
89549+
if (showBranchesColumn === void 0) { showBranchesColumn = true; }
89550+
return tr.apply(void 0, __spreadArray([td(name)], __spreadArray(["lines", "methods"], (showBranchesColumn ? ["branches"] : []), true).map(function (p) {
8955089551
return td(c2s(m[p], lang) +
8955189552
(!showDelta ? "" : compareFile(m[p], o && o[p], lang)), {
8955289553
align: "right"
@@ -89573,22 +89574,26 @@ var total = function (name, c, oldC) {
8957389574
var link = function (folder, file) {
8957489575
return a("".concat(baseUrl, "/").concat(folder, "/").concat(file), file);
8957589576
};
89576-
var html = function (withTable, c, o, deltaPerFile) {
89577+
var html = function (c, o, configs) {
8957789578
if (o === void 0) { o = null; }
89578-
if (deltaPerFile === void 0) { deltaPerFile = false; }
89579-
return (withTable ? tableWrap(c, o, deltaPerFile) : span)("Summary - ".concat([
89579+
if (configs === void 0) { configs = { withTable: false, deltaPerFile: false, showBranchesColumn: true }; }
89580+
return (configs.withTable
89581+
? tableWrap(c, o, configs.deltaPerFile, configs.showBranchesColumn)
89582+
: span)("Summary - ".concat([
8958089583
total("Lines", c.total.lines, o === null || o === void 0 ? void 0 : o.total.lines),
8958189584
total("Methods", c.total.methods, o === null || o === void 0 ? void 0 : o.total.methods),
89582-
total("Branchs", c.total.branchs, o === null || o === void 0 ? void 0 : o.total.branchs),
89585+
configs.showBranchesColumn &&
89586+
total("Branches", c.total.branches, o === null || o === void 0 ? void 0 : o.total.branches),
8958389587
]
8958489588
.filter(function (v) { return v; })
8958589589
.join(" | ")));
8958689590
};
89587-
var tableWrap = function (c, o, showDelta) {
89591+
var tableWrap = function (c, o, showDelta, showBranchesColumn) {
8958889592
if (o === void 0) { o = null; }
8958989593
if (showDelta === void 0) { showDelta = false; }
89594+
if (showBranchesColumn === void 0) { showBranchesColumn = true; }
8959089595
return function (summaryText) {
89591-
return details(summary(summaryText), "<br />", table(thead(tr(th("Files"), th("Lines"), th("Methods"), th("Branchs"))), tbody(c.folders.size === 0
89596+
return details(summary(summaryText), "<br />", table(thead(tr(th("Files"), th("Lines"), th("Methods"), showBranchesColumn && th("Branches"))), tbody(c.folders.size === 0
8959289597
? tr(td("No files reported or matching filters", { colspan: 4 }))
8959389598
: limitedFragment.apply(void 0, __spreadArray([65536 - 4000,
8959489599
tr(td(b("Table truncated to fit comment"), { colspan: 4 }))], Array.from(c.folders.entries())
@@ -89598,7 +89603,7 @@ var tableWrap = function (c, o, showDelta) {
8959889603
tr(td(b(folder.name), { colspan: 4 }))
8959989604
], folder.files.map(function (f) {
8960089605
var _a;
89601-
return line("&nbsp; &nbsp;".concat(link(folder.name, f.name)), f.metrics, lang, (_a = o === null || o === void 0 ? void 0 : o.get(k, f.name)) === null || _a === void 0 ? void 0 : _a.metrics, showDelta);
89606+
return line("&nbsp; &nbsp;".concat(link(folder.name, f.name)), f.metrics, lang, (_a = o === null || o === void 0 ? void 0 : o.get(k, f.name)) === null || _a === void 0 ? void 0 : _a.metrics, showDelta, showBranchesColumn);
8960289607
}), true);
8960389608
})
8960489609
.reduce(function (accum, item) { return __spreadArray(__spreadArray([], accum, true), item, true); }, []), false)))));
@@ -89611,8 +89616,9 @@ var file = coreExports.getInput("file") || process.env.FILE;
8961189616
var baseFile = coreExports.getInput("base-file") || process.env.BASE_FILE;
8961289617
var onlyWithCover = coreExports.getBooleanInput("only-with-cover");
8961389618
var onlyWithCoverableLines = coreExports.getBooleanInput("only-with-coverable-lines");
89614-
var withChart = coreExports.getInput("with-chart") == "true";
89615-
var withTable = coreExports.getInput("with-table") == "true";
89619+
var withChart = coreExports.getBooleanInput("with-chart");
89620+
var withTable = coreExports.getBooleanInput("with-table");
89621+
var showBranchesColumn = coreExports.getBooleanInput("with-branches");
8961689622
var tableWithOnlyBellow = Number(coreExports.getInput("table-below-coverage") || 100);
8961789623
var tableWithOnlyAbove = Number(coreExports.getInput("table-above-coverage") || 0);
8961889624
var tableWithChangeAbove = Number(coreExports.getInput("table-coverage-change") || 0);
@@ -89635,15 +89641,19 @@ var comment = function (cStats, oldStats, coverageType) { return __awaiter$1(voi
8963589641
}));
8963689642
});
8963789643
return [2 /*return*/, ((withChart ? chart(cStats, oldStats) : "") +
89638-
html(withTable, filter(cStats, {
89644+
html(filter(cStats, {
8963989645
cover: onlyWithCover,
8964089646
coverableLines: onlyWithCoverableLines
8964189647
}, {
8964289648
type: coverageType,
8964389649
min: tableWithOnlyAbove,
8964489650
max: tableWithOnlyBellow,
8964589651
delta: tableWithChangeAbove
89646-
}, oldStats), oldStats, showPercentageChangePerFile))];
89652+
}, oldStats), oldStats, {
89653+
withTable: withTable,
89654+
deltaPerFile: showPercentageChangePerFile,
89655+
showBranchesColumn: showBranchesColumn
89656+
}))];
8964789657
});
8964889658
}); };
8964989659
var filter = function (s, onlyWith, onlyBetween, o) {
@@ -89729,7 +89739,7 @@ var run = function () { return __awaiter$1(void 0, void 0, void 0, function () {
8972989739
return __generator(this, function (_k) {
8973089740
switch (_k.label) {
8973189741
case 0:
89732-
if (!["lines", "methods", "branchs"].includes(tableWithTypeLimit)) {
89742+
if (!["lines", "methods", "branches"].includes(tableWithTypeLimit)) {
8973389743
coreExports.error("there is no coverage type ".concat(tableWithTypeLimit));
8973489744
return [2 /*return*/];
8973589745
}

bin/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/clover/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const fromString = (str: string): Stats => {
6868
{
6969
lines: new Coverage(m.statements, m.coveredstatements),
7070
methods: new Coverage(m.methods, m.coveredmethods),
71-
branchs: new Coverage(m.conditionals, m.coveredconditionals),
71+
branches: new Coverage(m.conditionals, m.coveredconditionals),
7272
},
7373
allFiles
7474
.map((f) => {
@@ -92,7 +92,7 @@ export const fromString = (str: string): Stats => {
9292
metrics: {
9393
lines: new Coverage(m.statements, m.coveredstatements),
9494
methods: new Coverage(m.methods, m.coveredmethods),
95-
branchs: new Coverage(m.conditionals, m.coveredconditionals),
95+
branches: new Coverage(m.conditionals, m.coveredconditionals),
9696
},
9797
})
9898
),

src/html/index.ts

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,20 @@ const line = (
7676
m: Metrics,
7777
lang: string,
7878
o: Metrics = null,
79-
showDelta = false
79+
showDelta = false,
80+
showBranchesColumn = true
8081
) =>
8182
tr(
8283
td(name),
83-
...["lines", "methods", "branchs"].map((p) =>
84-
td(
85-
c2s(m[p], lang) +
86-
(!showDelta ? "" : compareFile(m[p], o && o[p], lang)),
87-
{
88-
align: "right",
89-
}
90-
)
84+
...["lines", "methods", ...(showBranchesColumn ? ["branches"] : [])].map(
85+
(p) =>
86+
td(
87+
c2s(m[p], lang) +
88+
(!showDelta ? "" : compareFile(m[p], o && o[p], lang)),
89+
{
90+
align: "right",
91+
}
92+
)
9193
)
9294
);
9395

@@ -129,31 +131,44 @@ const link = (folder: string, file: string) =>
129131
a(`${baseUrl}/${folder}/${file}`, file);
130132

131133
export const html = (
132-
withTable: boolean,
133134
c: Stats,
134135
o: Stats = null,
135-
deltaPerFile = false
136+
configs: {
137+
withTable: boolean;
138+
deltaPerFile?: boolean;
139+
showBranchesColumn?: boolean;
140+
} = { withTable: false, deltaPerFile: false, showBranchesColumn: true }
136141
): string =>
137-
(withTable ? tableWrap(c, o, deltaPerFile) : span)(
142+
(configs.withTable
143+
? tableWrap(c, o, configs.deltaPerFile, configs.showBranchesColumn)
144+
: span)(
138145
"Summary - ".concat(
139146
[
140147
total("Lines", c.total.lines, o?.total.lines),
141148
total("Methods", c.total.methods, o?.total.methods),
142-
total("Branchs", c.total.branchs, o?.total.branchs),
149+
configs.showBranchesColumn &&
150+
total("Branches", c.total.branches, o?.total.branches),
143151
]
144152
.filter((v) => v)
145153
.join(" | ")
146154
)
147155
);
148156

149157
const tableWrap =
150-
(c: Stats, o: Stats = null, showDelta = false) =>
158+
(c: Stats, o: Stats = null, showDelta = false, showBranchesColumn = true) =>
151159
(summaryText: string): string =>
152160
details(
153161
summary(summaryText),
154162
"<br />",
155163
table(
156-
thead(tr(th("Files"), th("Lines"), th("Methods"), th("Branchs"))),
164+
thead(
165+
tr(
166+
th("Files"),
167+
th("Lines"),
168+
th("Methods"),
169+
showBranchesColumn && th("Branches")
170+
)
171+
),
157172
tbody(
158173
c.folders.size === 0
159174
? tr(td("No files reported or matching filters", { colspan: 4 }))
@@ -169,7 +184,8 @@ const tableWrap =
169184
f.metrics,
170185
lang,
171186
o?.get(k, f.name)?.metrics,
172-
showDelta
187+
showDelta,
188+
showBranchesColumn
173189
)
174190
),
175191
])

src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ const file = getInput("file") || process.env.FILE;
1515
let baseFile = getInput("base-file") || process.env.BASE_FILE;
1616
const onlyWithCover = getBooleanInput("only-with-cover");
1717
const onlyWithCoverableLines = getBooleanInput("only-with-coverable-lines");
18-
const withChart = getInput("with-chart") == "true";
19-
const withTable = getInput("with-table") == "true";
18+
const withChart = getBooleanInput("with-chart");
19+
const withTable = getBooleanInput("with-table");
20+
const showBranchesColumn = getBooleanInput("with-branches");
2021
const tableWithOnlyBellow = Number(getInput("table-below-coverage") || 100);
2122
const tableWithOnlyAbove = Number(getInput("table-above-coverage") || 0);
2223
const tableWithChangeAbove = Number(getInput("table-coverage-change") || 0);
@@ -52,7 +53,6 @@ const comment = async (
5253
return (
5354
(withChart ? chart(cStats, oldStats) : "") +
5455
html(
55-
withTable,
5656
filter(
5757
cStats,
5858
{
@@ -68,7 +68,11 @@ const comment = async (
6868
oldStats
6969
),
7070
oldStats,
71-
showPercentageChangePerFile
71+
{
72+
withTable,
73+
deltaPerFile: showPercentageChangePerFile,
74+
showBranchesColumn,
75+
}
7276
)
7377
);
7478
};
@@ -177,7 +181,7 @@ const notFoundMessage =
177181
"was not found, please check if the path is valid, or if it exists.";
178182

179183
const run = async () => {
180-
if (!["lines", "methods", "branchs"].includes(tableWithTypeLimit)) {
184+
if (!["lines", "methods", "branches"].includes(tableWithTypeLimit)) {
181185
error(`there is no coverage type ${tableWithTypeLimit}`);
182186
return;
183187
}

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Coverage {
1515
export interface Metrics {
1616
lines: Coverage;
1717
methods: Coverage;
18-
branchs: Coverage;
18+
branches: Coverage;
1919
}
2020

2121
export interface File {

0 commit comments

Comments
 (0)