@@ -460,26 +460,36 @@ export function formatAdvisoryCommand(advisory) {
460460
461461export function formatAnnotations ( blockingMutants , packageRoot , state = { total : 0 , perFile : new Map ( ) } ) {
462462 const annotations = [ ]
463+ const mutantsByLocation = new Map ( )
463464
464- for ( const mutant of blockingMutants . sort ( ( left , right ) => {
465+ for ( const mutant of [ ... blockingMutants ] . sort ( ( left , right ) => {
465466 const pathOrder = left . filePath . localeCompare ( right . filePath )
466467 return pathOrder || left . location . start . line - right . location . start . line
467468 } ) ) {
468469 const repositoryPath = path . posix . join ( packageRoot , mutant . filePath . replaceAll ( "\\" , "/" ) )
469470 const key = `${ repositoryPath } :${ mutant . location . start . line } `
471+ const group = mutantsByLocation . get ( key ) ?? { repositoryPath, mutants : [ ] }
472+ group . mutants . push ( mutant )
473+ mutantsByLocation . set ( key , group )
474+ }
475+
476+ for ( const [ key , { repositoryPath, mutants } ] of mutantsByLocation ) {
470477 const fileCount = state . perFile . get ( repositoryPath ) ?? 0
471- if ( annotations . some ( ( annotation ) => annotation . key === key ) || fileCount >= 7 || state . total >= 20 ) continue
478+ if ( fileCount >= 7 || state . total >= 20 ) continue
472479
480+ const mutant = mutants [ 0 ]
473481 const replacement = String ( mutant . replacement ?? "" )
474482 . replace ( / \s + / g, " " )
475483 . trim ( )
476484 . slice ( 0 , 160 )
485+ const location = `${ repositoryPath } :${ mutant . location . start . line } `
486+ const detail = `${ mutant . status } ${ mutant . mutatorName } mutant${ replacement ? ` (replacement: ${ replacement } )` : "" } `
477487 annotations . push ( {
478488 key,
479489 file : repositoryPath ,
480490 line : mutant . location . start . line ,
481491 message :
482- `${ mutant . status } ${ mutant . mutatorName } mutant ${ replacement ? ` (replacement: ${ replacement } )` : "" } . ` +
492+ `${ location } : ${ mutants . length === 1 ? detail : ` ${ mutants . length } mutation test gaps; example: ${ detail } ` } . ` +
483493 "See the job summary for the complete list and resolution guidance." ,
484494 } )
485495 state . perFile . set ( repositoryPath , fileCount + 1 )
@@ -652,12 +662,6 @@ export function evaluateReport(report, packageEntry) {
652662 "The result is inconclusive; consider fixing flaky or slow tests, or reducing the changed scope." ,
653663 )
654664 }
655- if ( counts . blocking . length > 0 ) {
656- advisories . push (
657- `${ packageEntry . id } has ${ counts . survived } surviving and ${ counts . noCoverage } uncovered changed-code mutants. ` +
658- "Consider adding or strengthening focused tests." ,
659- )
660- }
661665 return { ...counts , advisories }
662666}
663667
@@ -729,7 +733,7 @@ export function runManifest(repoRoot, manifest, reportRoot) {
729733 reportPath,
730734 changedLines : packageEntry . changedExecutableLines ,
731735 ...counts ,
732- result : counts . advisories . length > 0 ? "Advisory findings" : "Passed" ,
736+ result : counts . blocking . length > 0 || counts . advisories . length > 0 ? "Advisory findings" : "Passed" ,
733737 } )
734738 } catch ( error ) {
735739 advisories . push ( error . message )
0 commit comments