Change missing code snippet handling in UI
Also, simplify sarif tests.
This commit is contained in:
@@ -188,8 +188,6 @@ const FileCodeSnippet = ({
|
||||
messageChildren?: React.ReactNode,
|
||||
}) => {
|
||||
|
||||
const code = codeSnippet?.text.split('\n') || [];
|
||||
|
||||
const startingLine = codeSnippet?.startLine || 0;
|
||||
const endingLine = codeSnippet?.endLine || 0;
|
||||
|
||||
@@ -198,6 +196,18 @@ const FileCodeSnippet = ({
|
||||
startingLine,
|
||||
endingLine);
|
||||
|
||||
if (!codeSnippet) {
|
||||
return (
|
||||
<Container>
|
||||
<TitleContainer>
|
||||
<Link href={titleFileUri}>{fileLink.filePath}</Link>
|
||||
</TitleContainer>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
const code = codeSnippet.text.split('\n');
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<TitleContainer>
|
||||
|
||||
@@ -438,7 +438,7 @@ describe('SARIF processing', () => {
|
||||
expect(actualCodeSnippet).to.deep.equal(expectedCodeSnippet);
|
||||
});
|
||||
|
||||
it('should not return errors for result locations with no contextRegion', () => {
|
||||
it('should use highlightedRegion for result locations with no contextRegion', () => {
|
||||
const sarif = buildValidSarifLog();
|
||||
sarif.runs![0]!.results![0]!.locations![0]!.physicalLocation!.contextRegion = undefined;
|
||||
|
||||
@@ -623,8 +623,8 @@ describe('SARIF processing', () => {
|
||||
expect(msg.startsWith('Error when processing SARIF result')).to.be.true;
|
||||
}
|
||||
|
||||
function expectNoParsingError(result: { errors: string[] | undefined }) {
|
||||
const array = result.errors || [];
|
||||
function expectNoParsingError(result: { errors: string[] }) {
|
||||
const array = result.errors;
|
||||
expect(array.length, array.join()).to.equal(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user