Change missing code snippet handling in UI

Also, simplify sarif tests.
This commit is contained in:
Andrew Eisenberg
2022-03-30 12:02:19 -07:00
parent 4bdf579ce2
commit 43f314b2b5
2 changed files with 15 additions and 5 deletions

View File

@@ -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>

View File

@@ -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);
}