Skip to content

Commit e21bab1

Browse files
committed
fix(cli): replace magic numbers with named constants in time formatting
Address code review feedback: add MS_PER_SECOND constant and use existing SECONDS_PER_MINUTE. Add comment explaining the threshold logic for formatting time values (ms/s/min based on magnitude).
1 parent 0c26cd0 commit e21bab1

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

cli/lib/checkup.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,17 @@ function formatSettingPrettyValue(
249249
}
250250

251251
if (unitNormalized === "seconds") {
252+
// Format time values with appropriate units based on magnitude:
253+
// - Sub-second values (< 1s): show in milliseconds for precision
254+
// - Small values (< 60s): show in seconds
255+
// - Larger values (>= 60s): show in minutes for readability
256+
const MS_PER_SECOND = 1000;
252257
if (settingNormalized < 1) {
253-
return `${(settingNormalized * 1000).toFixed(0)} ms`;
254-
} else if (settingNormalized < 60) {
258+
return `${(settingNormalized * MS_PER_SECOND).toFixed(0)} ms`;
259+
} else if (settingNormalized < SECONDS_PER_MINUTE) {
255260
return `${settingNormalized} s`;
256261
} else {
257-
return `${(settingNormalized / 60).toFixed(1)} min`;
262+
return `${(settingNormalized / SECONDS_PER_MINUTE).toFixed(1)} min`;
258263
}
259264
}
260265

0 commit comments

Comments
 (0)