diff --git a/README.md b/README.md index f29b779..e7352fb 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ jobs: ### `clippy_flags` Optional. clippy flags. (cargo clippy --color never -q --message-format json ``) +For example, `clippy_flags: -- -Dwarnings`. ### `tool_name` @@ -53,6 +54,17 @@ Optional. Working directory relative to the root directory. Optional. Reporter of reviewdog command [github-pr-check,github-pr-review]. It's same as `-reporter` flag of reviewdog. +#### github-pr-review +|`cargo clippy`|`cargo clippy -- -Dwarnings`| +|---|---| +|github-pr-review_warning|github-pr-review_error| + +#### github-pr-check +|`cargo clippy`|`cargo clippy -- -Dwarnings`| +|---|---| +|github-pr-check_warning|github-pr-check_error| + + ### `filter_mode` Optional. Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. diff --git a/dist/index.js b/dist/index.js index 0a94336..056e5e5 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index 59c7484..cef6ec6 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/src/main.ts b/src/main.ts index 393847d..4ffa283 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,7 +13,7 @@ async function run(): Promise { 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 { 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 { 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
${content.message.rendered}
\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 { return await exec.exec( reviewdog, [ - '-efm=%E%f:%l:%c:%m', + '-efm=
%E%f:%l:%c:%t:%m',
+            '-efm=%E%f:%l:%c:%t:%m',
             '-efm=%Z__END__',
+            '-efm=%C%m
', '-efm=%C%m', '-efm=%C', `-name=${toolName}`,