Skip to main content

Generating Results

Results are generated by the Task. The Task is responsible for populating the results array with the results of the analysis.

The Task base class provides some convenience methods for generating results. The addResult method attempts to simplify the process of adding results such that you don't have to know the specifics of SARIF in order to successfully generate meaningful output.

tip

For more details about SARIF, see the SARIF Specification.

/tasks/demo-task.ts
import { BaseTask, Task } from '@checkup/core';
import { Result } from 'sarif';

export default class DemoTask extends BaseTask implements Task {
taskName = 'demo-task';
taskDisplayName = 'Deme Task';
description = 'A task for demonstration purposes';
category = 'best practices';

async run(): Promise<Result[]> {
let results = await this.getData();

for (let result of results) {
this.addResult({
messageText: result.message,
level: 'fail',
kind: 'error',
{
location: {
uri: result.uri,
startLine: result.line,
startColumn: result.column,
endLine: result.line,
endColumn: result.column
}
}
});
}

return this.results;
}
}