Skip to content

Commit

Permalink
try to fix issues with annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
auguwu committed Aug 16, 2023
1 parent 7a58e31 commit a5ee754
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

32 changes: 10 additions & 22 deletions src/clippy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ export const getClippyOutput = async (
const execOptions: ExecOptions = {
ignoreReturnCode: true,
failOnStdErr: false,
silent: false,
silent: true,
listeners: {
stdline(piece) {
try {
JSON.parse(piece);
data.push(piece);
} catch (e) {
assertIsError(e);
console.log(piece);
}
}
}
Expand Down Expand Up @@ -180,26 +180,14 @@ export const renderMessages = async (pieces: string[], renderer: Renderer = kDef
? [message.rendered]
: [
message.rendered,

// We shouldn't include file as tests will be flaky
// in CI, so it'll only show up if it was
// actually ran.
process.env.VITEST === 'true'
? ({
startColumn: primarySpan.column_start,
endColumn: primarySpan.column_end,
startLine: primarySpan.line_start,
endLine: primarySpan.line_end,
title: message.message
} satisfies AnnotationProperties)
: ({
startColumn: primarySpan.column_start,
endColumn: primarySpan.column_end,
startLine: primarySpan.line_start,
endLine: primarySpan.line_end,
title: message.message,
file: data.target.src_path
} satisfies AnnotationProperties)
{
startColumn: primarySpan.column_start,
endColumn: primarySpan.column_end,
startLine: primarySpan.line_start,
endLine: primarySpan.line_end,
title: message.message,
file: data.target.src_path
} satisfies AnnotationProperties
];

method.apply(renderer, args);
Expand Down
12 changes: 6 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ async function main() {
: annotation.level === 'warning'
? ('warning' as const)
: ('notice' as const),
path: annotation.file!,
start_line: annotation.startLine!,
end_line: annotation.endLine!,
path: annotation.file || './file/that/probably/doesnt/exist.rs',
start_line: annotation.startLine || 0,
end_line: annotation.endLine || 0,
start_column: annotation.startColumn,
end_column: annotation.endColumn,
raw_details: annotation.rendered,
Expand All @@ -149,9 +149,9 @@ async function main() {
: annotation.level === 'warning'
? ('warning' as const)
: ('notice' as const),
path: annotation.file!,
start_line: annotation.startLine!,
end_line: annotation.endLine!,
path: annotation.file || './file/that/probably/doesnt/exist.rs',
start_line: annotation.startLine || 0,
end_line: annotation.endLine || 0,
start_column: annotation.startColumn,
end_column: annotation.endColumn,
raw_details: annotation.rendered,
Expand Down

0 comments on commit a5ee754

Please sign in to comment.