1- import { FullyAnalyzedFile } from " ./types"
1+ import { FullyAnalyzedFile } from ' ./types'
22
33const colLengths = {
44 filename : 30 ,
@@ -9,17 +9,16 @@ const colLengths = {
99
1010const round = ( num : number ) : number => Math . round ( num * 100 ) / 100
1111
12- const formatCol = ( value : string , limit : number ) => {
13- return ( value . length > limit )
14- ? value . slice ( limit + 3 ) . padStart ( limit , '.' )
15- : value . padEnd ( limit , ' ' )
12+ const formatCol = ( value : string , limit : number ) : string => {
13+ return value . length > limit
14+ ? value . slice ( limit + 3 ) . padStart ( limit , '.' )
15+ : value . padEnd ( limit , ' ' )
1616}
1717
1818const getScoreNote = ( score : number ) : string => {
1919 if ( score > 60 ) return 'OK'
2020
2121 if ( score > 50 ) return '(Could be better)'
22-
2322 return '(Needs improvement)'
2423}
2524
@@ -31,31 +30,36 @@ const formatComplexityScore = (score: number): string => {
3130}
3231
3332const generateTableLines = ( flatFileResults : FullyAnalyzedFile [ ] ) : string => {
34- return flatFileResults . map ( ( result ) => {
35- const { complexityReport, filename, timesDependedOn } = result
33+ return flatFileResults
34+ . map ( ( result ) => {
35+ const { complexityReport, filename, timesDependedOn } = result
3636
37- if ( ! complexityReport ) {
38- return ''
39- }
37+ if ( ! complexityReport ) {
38+ return ''
39+ }
4040
41- const { lineEnd, codehawkScore } = complexityReport
42- const score = formatComplexityScore ( codehawkScore )
41+ const { lineEnd, codehawkScore } = complexityReport
42+ const score = formatComplexityScore ( codehawkScore )
4343
44- // Convert output into stdout-friendly, padded columns
45- const filenameCol = formatCol ( filename , colLengths . filename )
46- const linesCol = formatCol ( lineEnd . toString ( ) , colLengths . lines )
47- // Add 1 to the times depended on, assuming that all files are used at least once
48- // (Codehawk reports external uses only)
49- const depsCol = formatCol ( ( timesDependedOn + 1 ) . toString ( ) , colLengths . timesUsed )
50- const maintainabilityCol = formatCol ( score , colLengths . maintainability )
44+ // Convert output into stdout-friendly, padded columns
45+ const filenameCol = formatCol ( filename , colLengths . filename )
46+ const linesCol = formatCol ( lineEnd . toString ( ) , colLengths . lines )
47+ // Add 1 to the times depended on, assuming that all files are used at least once
48+ // (Codehawk reports external uses only)
49+ const depsCol = formatCol (
50+ ( timesDependedOn + 1 ) . toString ( ) ,
51+ colLengths . timesUsed
52+ )
53+ const maintainabilityCol = formatCol ( score , colLengths . maintainability )
5154
52- return (
53- `| ${ filenameCol } | ${ linesCol } | ${ depsCol } | ${ maintainabilityCol } |`
54- )
55- } ) . join ( '\n ' ) // Newline + 4 spaces
55+ return `| ${ filenameCol } | ${ linesCol } | ${ depsCol } | ${ maintainabilityCol } |`
56+ } )
57+ . join ( '\n ' ) // Newline + 4 spaces
5658}
5759
58- export const formatResultsAsTable = ( flatFileResults : FullyAnalyzedFile [ ] ) : string => {
60+ export const formatResultsAsTable = (
61+ flatFileResults : FullyAnalyzedFile [ ]
62+ ) : string => {
5963 return `
6064 Codehawk Static Analysis Results
6165 Top ${ flatFileResults . length } file${ flatFileResults . length > 1 ? 's' : '' }
0 commit comments