@@ -3,52 +3,79 @@ import { MetricData } from '../utils/types';
33import { MetricCard } from './MetricCard' ;
44import { MethodTypeCard } from './MethodTypeCard' ;
55import { IndentationCard } from './IndentationCard' ;
6+ import { ComplexityCard } from './ComplexityCard' ;
7+ import { DuplicateCodeCard } from './DuplicateCodeCard' ;
68import { styles } from '../utils/styles' ;
79
810interface MetricsGridProps {
911 selectedFile : MetricData ;
1012}
1113
14+ // keys handled by special cards ↓
15+ const SKIP_KEYS = [
16+ 'file_name' ,
17+ 'file_path' ,
18+ 'file_size' ,
19+ 'file_extension' ,
20+ 'indentation_type' ,
21+ 'indentation_size' ,
22+ 'method_type_count' ,
23+ 'duplicate_blocks' ,
24+ 'duplicate_lines' ,
25+ 'duplicate_percentage' ,
26+ 'average_complexity' ,
27+ 'complexity_distribution' ,
28+ 'total_analyzed_functions' ,
29+ ] ;
30+
1231export const MetricsGrid : React . FC < MetricsGridProps > = ( { selectedFile } ) => {
32+ const m = selectedFile . metrics ;
33+
1334 return (
1435 < div style = { styles . metricsGrid } >
15- { Object . entries ( selectedFile . metrics ) . map ( ( [ key , value ] ) => {
16- // Skip file info metrics
17- if ( [ 'file_name' , 'file_path' , 'file_size' , 'file_extension' ] . includes ( key ) ) {
18- return null ;
19- }
36+ { /* generic & existing cards */ }
37+ { Object . entries ( m ) . map ( ( [ key , value ] ) => {
38+ if ( SKIP_KEYS . includes ( key ) ) return null ;
2039
21- // Handle method type count specially
22- if ( key === 'method_type_count' && typeof value === 'object' && value !== null ) {
40+ if ( key === 'method_type_count' ) {
2341 return (
24- < MethodTypeCard
42+ < MethodTypeCard
2543 key = { key }
2644 value = { value as { public : number ; private : number } }
2745 />
2846 ) ;
2947 }
3048
31- // Skip indentation keys as they'll be handled in their own card
32- if ( key === 'indentation_type' || key === 'indentation_size' ) {
33- return null ;
34- }
35-
36- return (
37- < MetricCard
38- key = { key }
39- metricKey = { key }
40- value = { value }
41- />
42- ) ;
49+ return < MetricCard key = { key } metricKey = { key } value = { value } /> ;
4350 } ) }
4451
45- { /* Indentation Card */ }
46- { ( selectedFile . metrics . indentation_type || selectedFile . metrics . indentation_size ) && (
47- < IndentationCard
48- indentationType = { selectedFile . metrics . indentation_type }
49- indentationSize = { selectedFile . metrics . indentation_size }
52+ { /* indentation */ }
53+ { ( m . indentation_type || m . indentation_size ) && (
54+ < IndentationCard
55+ indentationType = { m . indentation_type }
56+ indentationSize = { m . indentation_size }
57+ />
58+ ) }
59+
60+ { /* duplicate‑code */ }
61+ { ( m . duplicate_percentage !== undefined ||
62+ m . duplicate_blocks !== undefined ||
63+ m . duplicate_lines !== undefined ) && (
64+ < DuplicateCodeCard
65+ percentage = { m . duplicate_percentage }
66+ blocks = { m . duplicate_blocks }
67+ lines = { m . duplicate_lines }
68+ />
69+ ) }
70+
71+ { /* complexity */ }
72+ { m . average_complexity && (
73+ < ComplexityCard
74+ averageComplexity = { m . average_complexity }
75+ distribution = { m . complexity_distribution }
76+ totalFunctions = { m . total_analyzed_functions }
5077 />
5178 ) }
5279 </ div >
5380 ) ;
54- } ;
81+ } ;
0 commit comments