Skip to content

Commit d06b633

Browse files
authored
@W-17159591@ Enabled SARIF output format (#1690)
1 parent f105bfe commit d06b633

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

src/lib/writers/ResultsWriter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class ResultsFileWriter implements ResultsWriter {
3535
} else if (['.html', '.htm'].includes(ext)) {
3636
this.format = OutputFormat.HTML;
3737
} else if (ext === '.sarif' || file.toLowerCase().endsWith('.sarif.json')) {
38-
throw new Error('TODO: Support SARIF-type output');
38+
this.format = OutputFormat.SARIF;
3939
// Check for `.json` AFTER checking for `.sarif.json`!
4040
} else if (ext === '.json') {
4141
this.format = OutputFormat.JSON;

test/lib/writers/ResultsWriter.test.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ describe('ResultsWriter implementations', () => {
2323
{ext: '.html', expectedOutput: `Results formatted as ${OutputFormat.HTML}`},
2424
{ext: '.htm', expectedOutput: `Results formatted as ${OutputFormat.HTML}`},
2525
{ext: '.json', expectedOutput: `Results formatted as ${OutputFormat.JSON}`},
26-
//{ext: '.sarif', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`},
27-
//{ext: '.sarif.json', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`},
26+
{ext: '.sarif', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`},
27+
{ext: '.sarif.json', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`},
2828
{ext: '.xml', expectedOutput: `Results formatted as ${OutputFormat.XML}`}
2929
])('Accepts and outputs valid file format: *$ext', ({ext, expectedOutput}) => {
3030
const validFile = `beep${ext}`;
@@ -40,20 +40,6 @@ describe('ResultsWriter implementations', () => {
4040
}]);
4141
});
4242

43-
/**
44-
* All of these extensions are ones we intend to support long-term, but don't yet. When we add support for one of
45-
* these extensions, we should remove it from the cases array here and uncomment the corresponding line
46-
* in the case array for the valid format tests.
47-
*/
48-
it.each([
49-
{ext: '.sarif'},
50-
{ext: '.sarif.json'}
51-
])('Throws TODO error for not-yet-supported format: *$ext', ({ext}) => {
52-
const notYetSupportedFile = `beep${ext}`;
53-
// Expect the error message to include an indication that the functionality will be implemented eventually.
54-
expect(() => new ResultsFileWriter(notYetSupportedFile)).toThrow('TODO');
55-
});
56-
5743
it('Writes file even when results are empty', () => {
5844
const expectations = {
5945
file: 'beep.csv',

0 commit comments

Comments
 (0)