Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function processBlob(context, owner, repo, tree_sha, filename, file_sha) {
const {data: {content: encoded}} = await context.github.gitdata.getBlob({owner, repo, sha: file_sha})
const decoded = Buffer.from(encoded, 'base64').toString()
context.log(`Blob (${file_sha}) for https://github.com/${owner}/${repo}/blob/${tree_sha}/${filename} is: %j`, decoded)
const analysis = alex.markdown(decoded).messages.map(message => {
const {message: description, ruleId: title, location} = message
return {
path: filename, // The path to the file being annotated.
start_line: location.start.line, // The start line of the annotation.
end_line: location.end.line, // The end line of the annotation.
annotation_level: 'notice', // The level of the annotation. Can be one of notice, warning, or failure.
message: description, // A short description of the feedback for these lines of code. The maximum size is 64 KB.
title: title // The title that represents the annotation. The maximum size is 255 characters.
}
})
return analysis
}
buildResults () {
const results = new Map()
for (const [filename, contents] of this.contentMap) {
const res = alex.markdown(contents).messages
results.set(filename, this.serializeReasons(res))
}
return results
}
}
function checkContent(isRichText, value, config = {}) {
const { messages } = isRichText
? alex.text(documentToPlainTextString(value), config)
: alex.markdown(value, config);
return messages;
}
function checkContent(isRichText, value, config = {}) {
const { messages } = isRichText
? alex.text(documentToPlainTextString(value), config)
: alex.markdown(value, config);
return messages;
}
export async function getAlexErrors(input: string): Promise {
const report = alex.text(
input,
await getAlexConfig()
);
const { messages } = report;
return messages.map(message => {
return message.message;
});
}