File tree Expand file tree Collapse file tree 3 files changed +18
-15
lines changed
Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,20 @@ import type {
22 Audit ,
33 AuditReport ,
44 CategoryRef ,
5- Issue ,
5+ FileIssue ,
66 PluginMeta ,
77 Report ,
88 ReportsDiff ,
99} from '@code-pushup/models' ;
10+ import { isFileIssue } from '@code-pushup/utils' ;
1011import {
1112 type ChangedFiles ,
1213 adjustFileName ,
1314 adjustLine ,
1415 isFileChanged ,
1516} from './git.js' ;
1617
17- export type SourceFileIssue = Required < Issue > & IssueContext ;
18+ export type SourceFileIssue = FileIssue & IssueContext ;
1819
1920type IssueContext = {
2021 audit : Pick < Audit , 'slug' | 'title' > ;
@@ -71,7 +72,7 @@ function getAuditIssues(
7172) : SourceFileIssue [ ] {
7273 return (
7374 audit . details ?. issues
74- ?. filter ( ( issue ) : issue is Required < Issue > => issue . source ?. file != null )
75+ ?. filter ( isFileIssue )
7576 . map ( issue => ( { ...issue , audit, plugin } ) ) ?? [ ]
7677 ) ;
7778}
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import type {
3333 TableAlignment ,
3434 Tree ,
3535} from '@code-pushup/models' ;
36+ import { isFileIssue } from '@code-pushup/utils' ;
3637
3738export function reportToGQL (
3839 report : Report ,
@@ -106,7 +107,7 @@ export function issueToGQL(issue: Issue): PortalIssue {
106107 return {
107108 message : issue . message ,
108109 severity : issueSeverityToGQL ( issue . severity ) ,
109- ...( issue . source ?. file && {
110+ ...( isFileIssue ( issue ) && {
110111 sourceType : safeEnum < PortalIssueSourceType > ( 'SourceCode' ) ,
111112 sourceFilePath : issue . source . file ,
112113 sourceStartLine : issue . source . position ?. startLine ,
Original file line number Diff line number Diff line change 11import type { AuditOutputs , Issue } from '@code-pushup/models' ;
2- import { formatGitPath , getGitRoot } from '@code-pushup/utils' ;
2+ import { formatGitPath , getGitRoot , isFileIssue } from '@code-pushup/utils' ;
33
44export function normalizeIssue ( issue : Issue , gitRoot : string ) : Issue {
5+ // Early exit to avoid cloning; only file sources need path normalization
6+ if ( ! isFileIssue ( issue ) ) {
7+ return issue ;
8+ }
59 const { source, ...issueWithoutSource } = issue ;
6- // early exit to avoid issue object cloning.
7- return source == null
8- ? issue
9- : {
10- ...issueWithoutSource ,
11- source : {
12- ...source ,
13- file : formatGitPath ( source . file , gitRoot ) ,
14- } ,
15- } ;
10+ return {
11+ ...issueWithoutSource ,
12+ source : {
13+ ...source ,
14+ file : formatGitPath ( source . file , gitRoot ) ,
15+ } ,
16+ } ;
1617}
1718
1819export async function normalizeAuditOutputs (
You can’t perform that action at this time.
0 commit comments