This is a library that helps working with comments from static code analysis.
It supports the same formats as Violations Lib.
It is used by these libraries:
- Violation Comments to GitHub Lib.
- Violation Comments to GitLab Lib.
- Violation Comments to Bitbucket Server Lib.
- Violation Comments to Bitbucket Cloud Lib
It uses a template to render each violation comment. There is a default that can be replaced with a custom template.
The context available when the template is rendered is:
violation
that is an instance of Violation.changedFile
that is an instance of ChangedFile.
The templating language is Handlebars and may look like:
You can avoid escaping (replaces new lines with
) by using triple {
like this:
When using command line tools you may have problems with the ` (accent) character. You can do:
...
-comment-template "
message:
\\\`\\\`\\\`
{{{violation.message}}}
\\\`\\\`\\\`
"
And it will surround the message
with triple ```.
The Handlebars library comes with helper methods, these are registered:
ConditionalHelpers
IfHelper
StringHelpers
UnlessHelper