Skip to content

Commit ac15016

Browse files
Address code review comments: extract magic numbers to constants
Co-authored-by: granatonatalia <[email protected]>
1 parent 9ece38b commit ac15016

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/app/pages/mapping/mapping.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import { perfNow } from 'src/app/util/util';
1515
import { SettingsService } from 'src/app/service/settings/settings.service';
1616

1717
const SEPARATOR = '\x1F'; // ASCII Unit Separator
18+
const DEFAULT_COLUMN_WIDTH = 10;
19+
const COLUMN_PADDING = 2;
20+
const MAX_COLUMN_WIDTH = 50;
1821

1922
export interface MappingRow {
2023
uuid: Uuid;
@@ -180,13 +183,13 @@ export class MappingComponent implements OnInit, AfterViewInit {
180183
// Auto-fit columns (optional, improves readability)
181184
worksheet.columns.forEach(column => {
182185
let maxLength = 0;
183-
column.eachCell?.({ includeEmpty: true }, cell => {
184-
const cellLength = cell.value ? cell.value.toString().length : 10;
186+
column.eachCell({ includeEmpty: true }, cell => {
187+
const cellLength = cell.value ? cell.value.toString().length : DEFAULT_COLUMN_WIDTH;
185188
if (cellLength > maxLength) {
186189
maxLength = cellLength;
187190
}
188191
});
189-
column.width = Math.min(maxLength + 2, 50); // Max width of 50
192+
column.width = Math.min(maxLength + COLUMN_PADDING, MAX_COLUMN_WIDTH);
190193
});
191194

192195
// Write file

0 commit comments

Comments
 (0)