Catch error level from Clippy

This commit is contained in:
Takayuki Nakata 2022-12-01 16:59:53 +09:00
parent 70c5f4eb95
commit 41d079cb4a
3 changed files with 31 additions and 8 deletions

17
dist/index.js generated vendored
View file

@ -169,7 +169,15 @@ function run() {
}));
const code = yield core.group('Running Clippy with reviewdog 🐶 ...', () => __awaiter(this, void 0, void 0, function* () {
const output = [];
yield exec.exec('cargo', ['clippy', '--color', 'never', '-q', '--message-format', 'json', ...parse(clippyFlags)], {
yield exec.exec('cargo', [
'clippy',
'--color',
'never',
'-q',
'--message-format',
'json',
...parse(clippyFlags)
], {
cwd,
ignoreReturnCode: true,
listeners: {
@ -192,10 +200,11 @@ function run() {
}
core.debug('this is a compiler-message!');
const span = content.message.spans[0];
const messageLevel = content.message.level === 'warning' ? 'w' : 'e';
const rendered = reporter === 'github-pr-review'
? ` \n<pre><code>${content.message.rendered}</code></pre>\n__END__`
: `${content.message.rendered}\n__END__`;
const ret = `${span.file_name}:${span.line_start}:${span.column_start}:${rendered}`;
const ret = `${span.file_name}:${span.line_start}:${span.column_start}:${messageLevel}:${rendered}`;
output.push(ret);
}
}
@ -203,8 +212,10 @@ function run() {
process.env['REVIEWDOG_GITHUB_API_TOKEN'] =
core.getInput('github_token');
return yield exec.exec(reviewdog, [
'-efm=%E%f:%l:%c:%m',
'-efm=<pre><code>%E%f:%l:%c:%t:%m',
'-efm=%E%f:%l:%c:%t:%m',
'-efm=%Z__END__',
'-efm=%C%m</code></pre>',
'-efm=%C%m',
'-efm=%C',
`-name=${toolName}`,

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -13,7 +13,7 @@ async function run(): Promise<void> {
try {
const reviewdogVersion = core.getInput('reviewdog_version') || 'latest'
const toolName = core.getInput('tool_name') || 'clippy'
const clippyFlags = core.getInput('clippy_flags');
const clippyFlags = core.getInput('clippy_flags')
const level = core.getInput('level') || 'error'
const reporter = core.getInput('reporter') || 'github-pr-check'
const filterMode = core.getInput('filter_mode') || 'added'
@ -38,7 +38,15 @@ async function run(): Promise<void> {
const output: string[] = []
await exec.exec(
'cargo',
['clippy', '--color', 'never', '-q', '--message-format', 'json', ...parse(clippyFlags)],
[
'clippy',
'--color',
'never',
'-q',
'--message-format',
'json',
...parse(clippyFlags)
],
{
cwd,
ignoreReturnCode: true,
@ -64,11 +72,13 @@ async function run(): Promise<void> {
core.debug('this is a compiler-message!')
const span = content.message.spans[0]
const messageLevel =
content.message.level === 'warning' ? 'w' : 'e'
const rendered =
reporter === 'github-pr-review'
? ` \n<pre><code>${content.message.rendered}</code></pre>\n__END__`
: `${content.message.rendered}\n__END__`
const ret = `${span.file_name}:${span.line_start}:${span.column_start}:${rendered}`
const ret = `${span.file_name}:${span.line_start}:${span.column_start}:${messageLevel}:${rendered}`
output.push(ret)
}
}
@ -80,8 +90,10 @@ async function run(): Promise<void> {
return await exec.exec(
reviewdog,
[
'-efm=%E%f:%l:%c:%m',
'-efm=<pre><code>%E%f:%l:%c:%t:%m',
'-efm=%E%f:%l:%c:%t:%m',
'-efm=%Z__END__',
'-efm=%C%m</code></pre>',
'-efm=%C%m',
'-efm=%C',
`-name=${toolName}`,