-
Notifications
You must be signed in to change notification settings - Fork 33
/
annotator.js
38 lines (33 loc) · 1.04 KB
/
annotator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const core = require("@actions/core");
function extractAnnotations(results) {
let annotations = [];
for (i in results.queries) {
let query = results.queries[i];
for (j in query.files) {
let file = query.files[j];
annotations.push({
file: file['file_name'],
startLine: file['line'],
endLine: file['line'],
severity: query['severity'],
queryName: query['query_name'],
description: query['description'],
});
}
}
return annotations;
}
function annotateChangesWithResults(results) {
const annotations = extractAnnotations(results);
annotations.forEach(annotation => {
core.warning(annotation.description, {
title: `[${annotation.severity}] ${annotation.queryName}`,
startLine: annotation.startLine,
endLine: annotation.endLine,
file: annotation.file,
});
});
}
module.exports = {
annotateChangesWithResults
}