Skip to content

Commit

Permalink
writer-sarif: add descriptions for ShellCheck rules
Browse files Browse the repository at this point in the history
  • Loading branch information
lzaoral committed Apr 29, 2024
1 parent cd5d2e5 commit a2a4ad1
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/lib/writer-json-sarif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ static void sarifEncodeShellCheckRule(object *rule, const std::string &ruleID)
// name
rule->emplace("name", ruleID);

// shortDescription
object shortDesc = {
{ "text", ruleID }
};
rule->emplace("shortDescription", std::move(shortDesc));

// properties.tags[]
array tags = { "ShellCheck" };
object &props = rule->at("properties").as_object();
Expand All @@ -117,13 +123,20 @@ static void sarifEncodeShellCheckRule(object *rule, const std::string &ruleID)
// help.text && help.markdown
auto helpURI = "https://github.com/koalaman/shellcheck/wiki/" + ruleID;
auto helpMarkdown = "Defect reference: [" + ruleID +"](" + helpURI + ")";
auto helpText = "Defect reference: " + std::move(helpURI);

object help = {
{ "text", "Defect reference: " + helpURI },
{ "text", helpText },
{ "markdown", std::move(helpMarkdown) }
};

rule->emplace("help", std::move(help));

// fullDescription
object fullDesc = {
{ "text", std::move(helpText) }
};
rule->emplace("fullDescription", std::move(fullDesc));
}

static void sarifEncodeCweRule(object *rule, const int cwe, bool append = false)
Expand Down Expand Up @@ -192,7 +205,7 @@ static void sarifEncodeMsg(object *pDst, const std::string& text)
{ "text", sanitizeUTF8(text) }
};

pDst->emplace("message", std::move(message) );
pDst->emplace("message", std::move(message));
}

static void sarifEncodeLevel(object *result, const std::string &event)
Expand Down
Loading

0 comments on commit a2a4ad1

Please sign in to comment.