| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | export function printAnnotationResults( |
| | |
| | results: any, |
| | { |
| | skippableRules = [], |
| | skippableFlawProperties = [], |
| | }: { skippableRules?: string[]; skippableFlawProperties?: string[] } = {}, |
| | ) { |
| | for (const [file, flaws] of Object.entries(results)) { |
| | |
| | for (const flaw of flaws as any) { |
| | if (intersection(flaw.ruleNames, skippableRules)) { |
| | continue |
| | } |
| | if (skippableFlawProperties.some((prop) => flaw[prop])) { |
| | continue |
| | } |
| |
|
| | let annotation = `::${flaw.severity === 'error' ? 'error' : 'warning'} ` |
| | const bits = [`file=${file}`] |
| | if (flaw.lineNumber) { |
| | bits.push(`line=${flaw.lineNumber}`) |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | if (flaw.ruleDescription) { |
| | bits.push(`title=${flaw.ruleDescription}`) |
| | } |
| |
|
| | annotation += `${bits.join(',')}` |
| |
|
| | if (flaw.errorDetail) { |
| | annotation += flaw.errorDetail.endsWith('.') |
| | ? `::${flaw.errorDetail}` |
| | : `::${flaw.errorDetail}.` |
| | } |
| |
|
| | if (flaw.context) { |
| | annotation += ` ${flaw.context}` |
| | } |
| |
|
| | |
| | |
| | |
| | console.log(annotation) |
| | } |
| | } |
| | } |
| |
|
| | |
| | function intersection(arr1: any[], arr2: any[]) { |
| | return arr1.some((item: any) => arr2.includes(item)) |
| | } |
| |
|