Skip to content

Commit

Permalink
feat: log annotations with warning if results are ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
Codex- committed Oct 31, 2023
1 parent 5c0c84e commit ff4c545
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
14 changes: 8 additions & 6 deletions dist/index.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function run(): Promise<void> {
);

if (config.annotations) {
await updateCheckAnnotations(checkId!, knipAnnotations);
await updateCheckAnnotations(checkId!, knipAnnotations, config.ignoreResults);
}

if (!config.ignoreResults && knipSections.length > 0) {
Expand Down
13 changes: 9 additions & 4 deletions src/tasks/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ type Annotation = NonNullable<Unpacked<NonNullable<CheckOutput>["annotations"]>>
export async function updateCheckAnnotations(
checkId: number,
minimalAnnotations: MinimalAnnotation[],
ignoreResults = false,
): Promise<void> {
core.debug(`[updateCheckAnnotations]: Begin pushing annotations (${minimalAnnotations.length})`);
core.debug(
`[updateCheckAnnotations]: Begin pushing annotations (${
minimalAnnotations.length
}) with level '${ignoreResults ? "warning" : "failure"}'`,
);

let i = 0;
while (i < minimalAnnotations.length) {
Expand All @@ -34,9 +39,9 @@ export async function updateCheckAnnotations(
path: ma.path,
start_line: ma.start_line,
end_line: ma.start_line,
// start_column: ma.start_column,
// end_column: ma.start_column + ma.identifier.length,
annotation_level: "failure",
start_column: ma.start_column,
end_column: ma.start_column + ma.identifier.length,
annotation_level: ignoreResults ? "warning" : "failure",
message: `\`${ma.identifier}\` is unused`,
};
return annotation;
Expand Down

0 comments on commit ff4c545

Please sign in to comment.