@@ -67,6 +67,7 @@ function allocateRoundedHoursByCount(normalizedHoursData, totalHoursWorked) {
6767 const byRemainderDesc = [ ...provisional ] . sort ( ( a , b ) => b . remainder - a . remainder ) ;
6868 let i = 0 ;
6969 while ( remaining > 0 && byRemainderDesc . length > 0 ) {
70+ // FIX: Avoiding direct property mutation on array references being re-sorted
7071 byRemainderDesc [ i % byRemainderDesc . length ] . allocatedHours += 1 ;
7172 remaining -= 1 ;
7273 i += 1 ;
@@ -82,10 +83,11 @@ export function formatRangeLabel(rangeStr) {
8283 const normalizedRange = normalizeBucketId ( rangeStr ) ;
8384
8485 if ( normalizedRange . includes ( '+' ) ) {
85- const num = parseFloat ( normalizedRange . replace ( '+' , '' ) ) ;
86+ // FIX: Prefer Number() over parseFloat() for safer numeric string conversions
87+ const num = Number ( normalizedRange . replace ( '+' , '' ) ) ;
8688 return `${ num } + hrs` ;
8789 } else {
88- const num = parseFloat ( normalizedRange ) ;
90+ const num = Number ( normalizedRange ) ;
8991 return `${ num } -${ num + 9 } hrs` ;
9092 }
9193}
@@ -161,15 +163,15 @@ export default function VolunteerHoursDistribution({
161163 hoursData,
162164 totalHoursData,
163165} ) {
164- // FIXED: Using standard globalThis setup
166+ // FIXED: Comparing with 'undefined' directly instead of using 'typeof' on an object property
165167 const [ windowSize , setWindowSize ] = useState ( {
166- width : typeof globalThis . window !== ' undefined' ? globalThis . window . innerWidth : 1200 ,
167- height : typeof globalThis . window !== ' undefined' ? globalThis . window . innerHeight : 800 ,
168+ width : globalThis . window !== undefined ? globalThis . window . innerWidth : 1200 ,
169+ height : globalThis . window !== undefined ? globalThis . window . innerHeight : 800 ,
168170 } ) ;
169171
170172 useEffect ( ( ) => {
171- // FIXED: Cleaned up negated conditions and wrapped with explicit globalThis tracking
172- if ( typeof globalThis . window !== ' undefined' ) {
173+ // FIXED: Removed 'typeof' check on globalThis.window property access
174+ if ( globalThis . window !== undefined ) {
173175 const updateWindowSize = ( ) => {
174176 setWindowSize ( {
175177 width : globalThis . window . innerWidth ,
@@ -221,4 +223,4 @@ export { HoursWorkList, mergeHoursBuckets };
221223export function computeDistribution ( hoursData , totalHoursData ) {
222224 const { userData, totalVolunteers, totalHoursWorked } = buildChartData ( hoursData , totalHoursData ) ;
223225 return { userData, totalVolunteers, totalHoursWorked } ;
224- }
226+ }
0 commit comments