@@ -32,16 +32,15 @@ function len(x) { return Array.isArray(x) ? x.length : 0; }
3232function num ( x ) { return typeof x === 'number' && Number . isFinite ( x ) ? x : 0 ; }
3333
3434function summarize ( payload ) {
35- // Expected shape: { categories: { magicNumbers, complexity, domainTerms, architecture, counts? }, effort: { byCategory? } }
3635 const cat = payload && payload . categories ? payload . categories : { } ;
3736 const effort = payload && payload . effort ? payload . effort : { } ;
3837 const byCat = ( effort && effort . byCategory ) ? effort . byCategory : { } ;
38+ const lines = payload && payload . lines ? payload . lines : { } ;
3939 return {
4040 magicNumbers : len ( cat . magicNumbers ) ,
4141 complexity : len ( cat . complexity ) ,
4242 domainTerms : len ( cat . domainTerms ) ,
4343 architecture : len ( cat . architecture ) ,
44- // Optional counts (informational)
4544 counts : {
4645 errors : num ( cat . counts && cat . counts . errors ) ,
4746 warnings : num ( cat . counts && cat . counts . warnings ) ,
@@ -52,6 +51,12 @@ function summarize(payload) {
5251 complexity : num ( byCat . complexity ) ,
5352 domainTerms : num ( byCat . domainTerms ) ,
5453 architecture : num ( byCat . architecture )
54+ } ,
55+ lines : {
56+ physical : num ( lines . physical ) ,
57+ executable : num ( lines . executable ) ,
58+ comments : num ( lines . comments ) ,
59+ commentRatio : typeof lines . commentRatio === 'number' ? lines . commentRatio : 0
5560 }
5661 } ;
5762}
@@ -101,8 +106,21 @@ function main() {
101106 if ( deltas . length === 0 ) {
102107 console . log ( '[ratchet] OK: no increases in analyzer categories' ) ;
103108 if ( effortInc . length ) {
104- const lines = effortInc . map ( d => ` effort.${ d . key } : ${ d . base } h -> ${ d . current } h` ) ;
105- console . log ( '[ratchet] Note: effort increased (informational):\n' + lines . join ( '\n' ) ) ;
109+ const linesInfo = effortInc . map ( d => ` effort.${ d . key } : ${ d . base } h -> ${ d . current } h` ) ;
110+ console . log ( '[ratchet] Note: effort increased (informational):\n' + linesInfo . join ( '\n' ) ) ;
111+ }
112+ // Show line metrics (informational)
113+ if ( ( b . lines && ( b . lines . physical || b . lines . executable ) ) || ( c . lines && ( c . lines . physical || c . lines . executable ) ) ) {
114+ const physB = num ( b . lines && b . lines . physical ) ;
115+ const physC = num ( c . lines && c . lines . physical ) ;
116+ const exB = num ( b . lines && b . lines . executable ) ;
117+ const exC = num ( c . lines && c . lines . executable ) ;
118+ const crB = b . lines ? b . lines . commentRatio : 0 ;
119+ const crC = c . lines ? c . lines . commentRatio : 0 ;
120+ console . log ( '[ratchet] Lines (informational):' ) ;
121+ if ( physB || physC ) console . log ( ` physical: ${ physB } -> ${ physC } (${ physC - physB >= 0 ? '+' : '' } ${ physC - physB } )` ) ;
122+ if ( exB || exC ) console . log ( ` executable: ${ exB } -> ${ exC } (${ exC - exB >= 0 ? '+' : '' } ${ exC - exB } )` ) ;
123+ console . log ( ` commentRatio: ${ ( crB * 100 ) . toFixed ( 1 ) } % -> ${ ( crC * 100 ) . toFixed ( 1 ) } %` ) ;
106124 }
107125 process . exit ( 0 ) ;
108126 return ;
@@ -112,6 +130,23 @@ function main() {
112130 for ( const d of deltas ) {
113131 console . error ( ` ${ d . key } : ${ d . base } -> ${ d . current } (+${ d . current - d . base } )` ) ;
114132 }
133+ // Lines (informational) + brief assessment
134+ if ( ( b . lines && ( b . lines . physical || b . lines . executable ) ) || ( c . lines && ( c . lines . physical || c . lines . executable ) ) ) {
135+ const physB = num ( b . lines && b . lines . physical ) ;
136+ const physC = num ( c . lines && c . lines . physical ) ;
137+ const exB = num ( b . lines && b . lines . executable ) ;
138+ const exC = num ( c . lines && c . lines . executable ) ;
139+ const crB = b . lines ? b . lines . commentRatio : 0 ;
140+ const crC = c . lines ? c . lines . commentRatio : 0 ;
141+ console . error ( '\n[ratchet] Lines (informational):' ) ;
142+ if ( physB || physC ) console . error ( ` physical: ${ physB } -> ${ physC } (${ physC - physB >= 0 ? '+' : '' } ${ physC - physB } )` ) ;
143+ if ( exB || exC ) console . error ( ` executable: ${ exB } -> ${ exC } (${ exC - exB >= 0 ? '+' : '' } ${ exC - exB } )` ) ;
144+ console . error ( ` commentRatio: ${ ( crB * 100 ) . toFixed ( 1 ) } % -> ${ ( crC * 100 ) . toFixed ( 1 ) } %` ) ;
145+ const parts = [ ] ;
146+ parts . push ( exC < exB ? 'executable ↓' : exC > exB ? 'executable ↑' : 'executable =' ) ;
147+ parts . push ( crC > crB ? 'docs ↑' : crC < crB ? 'docs ↓' : 'docs =' ) ;
148+ console . error ( ` Assessment: ${ parts . join ( ', ' ) } ` ) ;
149+ }
115150 console . error ( '\nTo inspect:' ) ;
116151 console . error ( ' - open analysis-current.json' ) ;
117152 console . error ( ' - compare with analysis-baseline.json' ) ;
0 commit comments