Skip to content

Commit 63a60ec

Browse files
committed
html-writer: create links to description of SC checkers
Suggested-by: Ondrej Vasik
1 parent 7752669 commit 63a60ec

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

html-writer.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,14 @@ void HtmlWriter::Private::writeNewDefWarning(const Defect &def) {
399399
<< this->newDefMsg << "]</span>";
400400
}
401401

402+
void linkifyShellCheckMsg(std::string *pMgs) {
403+
static boost::regex reShellCheckMsg(" \\[SC([0-9]+)\\]$");
404+
*pMgs = boost::regex_replace(*pMgs, reShellCheckMsg,
405+
" <a href=\"https://github.com/koalaman/shellcheck/wiki/SC\\1\""
406+
" title=\"description of ShellCheck's checker SC\\1\">"
407+
"[SC\\1]</a>");
408+
}
409+
402410
void HtmlWriter::handleDef(const Defect &def) {
403411
d->core.writeHeaderOnce(d->scanProps, d->plainTextUrl);
404412

@@ -479,7 +487,11 @@ void HtmlWriter::handleDef(const Defect &def) {
479487
d->str << "<span style='color: #" << color << ";'>";
480488
}
481489

482-
d->str << HtmlLib::escapeTextInline(evt.msg);
490+
// translate message text
491+
std::string msgText = HtmlLib::escapeTextInline(evt.msg);
492+
if (def.checker == "SHELLCHECK_WARNING")
493+
linkifyShellCheckMsg(&msgText);
494+
d->str << msgText;
483495

484496
if (isCtxLine)
485497
d->str << "</span>";

0 commit comments

Comments
 (0)