Skip to content

Commit

Permalink
Fix "flat" report structure (#679)
Browse files Browse the repository at this point in the history
With a "flat" report, the `looksGood` property can but be an empty list.
This had been left out in the code, so no way to get a "flat" report
anymore.

The reporting of a "flat" structure also needed to be improved to return
the spec(s) along with the anomaly message. The code only reported the
anomaly message, meaning that there was no way to know where the anomaly
had been detected.
  • Loading branch information
tidoust authored Aug 26, 2024
1 parent 087bb2e commit e634e53
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
30 changes: 25 additions & 5 deletions src/lib/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,20 @@ function serializeEntry(entry, format, depth = 0) {
}
}
else if (entry.message) {
res = pad(`* [ ] ${entry.message}`, depth);
if (depth === 0) {
if (entry.spec) {
res = `* [ ] [${entry.spec.title}](${entry.spec.crawled}) - ${entry.message}`;
}
else if (entry.specs) {
const specs = entry.specs
.map(spec => `[${spec.title}](${spec.crawled})`)
.join(', ');
res = `* [ ] ${specs} - ${entry.message}`;
}
}
else {
res = pad(`* [ ] ${entry.message}`, depth);
}
}

for (const item of entry.items ?? []) {
Expand Down Expand Up @@ -490,9 +503,16 @@ function formatReport(format, report) {
return [
{
title: 'Study report',
content: report.map(entry =>
`## ${entry.title}
${serializeEntry(entry, 'markdown')}`)
content: report.map(entry => {
if (entry.title) {
return `## ${entry.title}
${serializeEntry(entry, 'markdown')}
`;
}
else {
return serializeEntry(entry, 'markdown');
}
})
}
]
}
Expand Down Expand Up @@ -533,7 +553,7 @@ function getNamesOfNonReportedEntries(report, specs, what, structure) {

const levels = structure.split('/')
.map(level => level.replace(/\s+/g, ''));
let allNames;
let allNames = [];
switch (levels[0]) {
case 'flat':
// Not much we can say there
Expand Down
1 change: 0 additions & 1 deletion strudy.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ ${entry.content}
let reported = 0;
for (const entry of content) {
console.log(entry);
console.log();
reported += 1;
if (options.max > 0 && reported >= options.max) {
break;
Expand Down

0 comments on commit e634e53

Please sign in to comment.