Commit e85963e
committed
Fix regex to detect empty lines containing only whitespace
Addressed review feedback: The previous regex only detected consecutive
newlines that were immediately adjacent (\n\n\n). It failed to detect
multiple consecutive empty lines when those lines contained only spaces
or tabs (\n \n \n).
Updated regex to treat [ \t]*\r?\n (optional whitespace + newline) as
an empty line, rather than just \r?\n. This ensures that lines containing
only whitespace are properly treated as empty when checking for multiple
consecutive empty lines.
Changes:
- Updated regex pattern: (?<=([ \t]*\r?\n)([ \t]*\r?\n))[ \t]*\r?\n
- Added test file EmptyLinesWithWhitespace.cls with spaces on empty lines
- Added specific test case for whitespace-only empty lines
- Updated existing tests to include new violation1 parent a848e74 commit e85963e
3 files changed
Lines changed: 61 additions & 1 deletion
File tree
- packages/code-analyzer-regex-engine
- src
- test
- test-data/apexClassWhitespace/4_multipleEmptyLines
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
295 | 307 | | |
296 | 308 | | |
297 | 309 | | |
| |||
330 | 342 | | |
331 | 343 | | |
332 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
333 | 357 | | |
334 | 358 | | |
335 | 359 | | |
| |||
347 | 371 | | |
348 | 372 | | |
349 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
350 | 400 | | |
351 | 401 | | |
352 | 402 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments