Commit c5ca1f2
fix: sanitize threshold values in complexity SQL queries (#136)
* fix: sanitize threshold values in complexity SQL queries
Coerce threshold warn values through Number() and guard with isNaN
before interpolating into SQL HAVING clauses, preventing malformed
queries when non-numeric values are provided in config.
Impact: 1 functions changed, 4 affected
* test: add regression tests for non-numeric threshold sanitization
* fix: strict type validation for threshold values in complexity queries
Replace Number() coercion + isNaN with typeof === 'number' && isFinite()
to reject values like Number(""), Number(null), Number(true) that silently
coerce to valid numbers. Add maintainabilityIndex to default thresholds.
Update regression tests to verify exceeds arrays and summary.aboveWarn.
Addresses Greptile review on #136.
Impact: 2 functions changed, 1 affected
* test: verify exceeds arrays are empty with invalid thresholds
Assert that no function has exceeds when thresholds are non-numeric
strings, complementing the summary.aboveWarn === 0 assertions.
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>1 parent 452d9e9 commit c5ca1f2
2 files changed
Lines changed: 73 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
673 | 673 | | |
674 | 674 | | |
675 | 675 | | |
| 676 | + | |
676 | 677 | | |
677 | 678 | | |
678 | 679 | | |
| |||
699 | 700 | | |
700 | 701 | | |
701 | 702 | | |
| 703 | + | |
| 704 | + | |
702 | 705 | | |
703 | 706 | | |
704 | 707 | | |
705 | | - | |
| 708 | + | |
706 | 709 | | |
707 | 710 | | |
708 | | - | |
| 711 | + | |
709 | 712 | | |
710 | 713 | | |
711 | | - | |
| 714 | + | |
712 | 715 | | |
713 | 716 | | |
714 | | - | |
| 717 | + | |
715 | 718 | | |
716 | 719 | | |
717 | 720 | | |
| |||
758 | 761 | | |
759 | 762 | | |
760 | 763 | | |
761 | | - | |
| 764 | + | |
762 | 765 | | |
763 | | - | |
| 766 | + | |
764 | 767 | | |
765 | | - | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
766 | 772 | | |
767 | 773 | | |
768 | | - | |
| 774 | + | |
769 | 775 | | |
770 | 776 | | |
771 | 777 | | |
| |||
817 | 823 | | |
818 | 824 | | |
819 | 825 | | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
824 | 833 | | |
825 | 834 | | |
826 | 835 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
| |||
320 | 325 | | |
321 | 326 | | |
322 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
323 | 374 | | |
0 commit comments