mirror of
https://github.com/rtk-ai/rtk.git
synced 2026-09-19 07:33:17 +08:00
ebf4cbf539
sqlfluff exits 1 whenever it finds violations, which is the normal case this filter exists for. Two changes in the last push read that exit code as failure and so disabled the filter exactly when it had something to compress: - `sqlfluff_cmd` used `early_exit_on_failure()`, which dumps the injected JSON raw. On a 51-file corpus that is 9.8 KB where plain `sqlfluff lint` is 1.1 KB. - `lint_cmd` substituted `result.stderr`, which is always empty: sqlfluff writes even fatal errors to stdout (verified against 2.3.5 and 4.3.0 - `Error: Unknown dialect 'NOPE'` on stdout, stderr empty, exit 2). Every violation was discarded in favour of a 25-byte `SQLFluff: failed (exit 1)`. Both are one bug reached two ways, because both entry points restated the same routing and format-flag logic and were then edited differently. Extract it into `sqlfluff_cmd::plan`, which states once how rtk invokes sqlfluff and how it reads the result back; `lint_cmd` now calls it instead of keeping a copy. The exit code only disambiguates output the filter could not parse, so a fatal error reaches the user verbatim while violations are still summarized. Also in the report: - Rank the `Violations:` section worst-file-first like every section above it. Iterating sqlfluff's emission order and taking the first 50 dropped exactly the file the summary ranked first. - Build only the lines that get printed, instead of every line to keep fifty. - Omit positions sqlfluff did not report rather than fabricating `:0:0`. - Keep two path segments when no dbt root matches, so `migrations/orders.sql` and `reports/orders.sql` stay distinct in the section meant to be opened. - Treat a missing `fixes` key as unknown rather than zero. sqlfluff 2.x omits it entirely, which silently suppressed the `sqlfluff fix` hint. - Rename the savings test to the bound it actually asserts. Tests cover both regressions against real captured output: 4.3.0 for the current field names and fix data, 2.3.5 for the legacy names and the absent `fixes` key.
2 lines
7.0 KiB
JSON
2 lines
7.0 KiB
JSON
[{"filepath": "models/orders.sql", "violations": [{"start_line_no": 1, "start_line_pos": 1, "code": "LT09", "description": "Select targets should be on a new line unless there is only one select target.", "name": "layout.select_targets", "warning": false, "fixes": [{"type": "delete", "edit": "", "start_line_no": 1, "start_line_pos": 7, "start_file_pos": 6, "end_line_no": 1, "end_line_pos": 8, "end_file_pos": 7}, {"type": "create_before", "edit": "\n", "start_line_no": 1, "start_line_pos": 8, "start_file_pos": 7, "end_line_no": 1, "end_line_pos": 8, "end_file_pos": 7}, {"type": "delete", "edit": "", "start_line_no": 1, "start_line_pos": 10, "start_file_pos": 9, "end_line_no": 1, "end_line_pos": 11, "end_file_pos": 10}, {"type": "create_before", "edit": "\n", "start_line_no": 1, "start_line_pos": 11, "start_file_pos": 10, "end_line_no": 1, "end_line_pos": 11, "end_file_pos": 10}], "start_file_pos": 0, "end_line_no": 1, "end_line_pos": 12, "end_file_pos": 11}, {"start_line_no": 2, "start_line_pos": 1, "code": "CP01", "description": "Keywords must be consistently upper case.", "name": "capitalisation.keywords", "warning": false, "fixes": [{"type": "replace", "edit": "FROM", "start_line_no": 2, "start_line_pos": 1, "start_file_pos": 12, "end_line_no": 2, "end_line_pos": 5, "end_file_pos": 16}], "start_file_pos": 12, "end_line_no": 2, "end_line_pos": 5, "end_file_pos": 16}], "statistics": {"source_chars": 24, "templated_chars": 24, "segments": 29, "raw_segments": 16}, "timings": {"templating": 0.0002585420006653294, "lexing": 0.0002572499943198636, "parsing": 0.0027726670014089905, "linting": 0.002208584002801217, "AL01": 2.0250001398380846e-05, "AL02": 5.7919969549402595e-06, "AL03": 5.437499930849299e-05, "AL04": 6.0957994719501585e-05, "AL05": 0.00013124999532010406, "AL06": 1.708300260361284e-05, "AL07": 6.042006134521216e-06, "AL08": 1.3125005352776498e-05, "AL09": 1.575000351294875e-05, "AL10": 1.3291006325744092e-05, "AM01": 8.082999556791037e-06, "AM02": 2.3749962565489113e-06, "AM03": 1.915999746415764e-06, "AM04": 5.6166994909290224e-05, "AM05": 2.583001332823187e-06, "AM06": 2.125001628883183e-06, "AM07": 2.7080022846348584e-06, "AM08": 2.1660016500391066e-06, "AM09": 7.541995728388429e-06, "CP01": 0.00012812500062864274, "CP02": 5.9124999097548425e-05, "CP03": 3.1669987947680056e-06, "CP04": 1.959000655915588e-06, "CP05": 1.958003849722445e-06, "CV01": 2.0419975044205785e-06, "CV02": 1.6669946489855647e-06, "CV03": 1.1874995834659785e-05, "CV04": 1.8339997041039169e-06, "CV05": 1.5419936971738935e-06, "CV06": 4.916997568216175e-06, "CV07": 4.041001375298947e-06, "CV08": 1.6250050975941122e-06, "CV09": 2.283299545524642e-05, "CV10": 2.0000006770715117e-06, "CV11": 1.8749997252598405e-06, "CV12": 6.4589985413476825e-06, "JJ01": 2.458997187204659e-06, "LT01": 0.00027391700132284313, "LT02": 0.00019841600442305207, "LT03": 4.207999154459685e-06, "LT04": 2.2166997950989753e-05, "LT05": 0.00014241600001696497, "LT06": 3.916000423487276e-06, "LT07": 2.749999111983925e-06, "LT08": 1.9170038285665214e-06, "LT09": 0.00013908399705542251, "LT10": 1.462499494664371e-05, "LT11": 2.2080057533457875e-06, "LT12": 2.058300015050918e-05, "LT13": 6.833004590589553e-06, "LT14": 0.00010991599992848933, "LT15": 1.6666999727021903e-05, "OR01": 2.458997187204659e-06, "PG01": 2.2080057533457875e-06, "PG02": 2.2080057533457875e-06, "RF01": 9.624999802326784e-05, "RF02": 4.4917003833688796e-05, "RF03": 6.900000153109431e-05, "RF04": 2.937500539701432e-05, "RF05": 3.333299537189305e-05, "RF06": 3.5541001125238836e-05, "RF07": 2.2089952835813165e-06, "ST01": 1.959000655915588e-06, "ST02": 1.5830009942874312e-06, "ST03": 1.624997821636498e-06, "ST04": 1.7080019460991025e-06, "ST05": 5.733300349675119e-05, "ST06": 2.0791005226783454e-05, "ST07": 3.6249984987080097e-06, "ST08": 1.720800355542451e-05, "ST09": 1.2583004718180746e-05, "ST10": 1.7500060494057834e-06, "ST11": 1.7790996935218573e-05, "ST12": 3.417000698391348e-06, "TQ01": 1.8339997041039169e-06, "TQ02": 1.5839978004805744e-06, "TQ03": 1.6659978427924216e-06, "TQ04": 1.6670019249431789e-06}}, {"filepath": "models/staging/stg_items.sql", "violations": [{"start_line_no": 1, "start_line_pos": 1, "code": "AM04", "description": "Query produces an unknown number of result columns.", "name": "ambiguous.column_count", "warning": false, "fixes": [], "start_file_pos": 0, "end_line_no": 2, "end_line_pos": 11, "end_file_pos": 19}], "statistics": {"source_chars": 20, "templated_chars": 20, "segments": 25, "raw_segments": 13}, "timings": {"templating": 2.479200338711962e-05, "lexing": 0.00010029200348071754, "parsing": 0.0008636249986011535, "linting": 0.0015631249989382923, "AL01": 1.1541997082531452e-05, "AL02": 3.4580007195472717e-06, "AL03": 3.1042000045999885e-05, "AL04": 4.958399949828163e-05, "AL05": 9.049999789567664e-05, "AL06": 1.6457997844554484e-05, "AL07": 5.374997272156179e-06, "AL08": 9.374998626299202e-06, "AL09": 1.2583004718180746e-05, "AL10": 1.2291995517443866e-05, "AM01": 7.499998901039362e-06, "AM02": 2.0000006770715117e-06, "AM03": 1.7499987734481692e-06, "AM04": 6.704100087517872e-05, "AM05": 2.4999972083605826e-06, "AM06": 2.0420047803781927e-06, "AM07": 2.2500025806948543e-06, "AM08": 1.8339997041039169e-06, "AM09": 6.541995389852673e-06, "CP01": 3.9582999306730926e-05, "CP02": 2.8792004741262645e-05, "CP03": 2.125001628883183e-06, "CP04": 1.6659978427924216e-06, "CP05": 1.8339997041039169e-06, "CV01": 1.5420009731315076e-06, "CV02": 1.7080019460991025e-06, "CV03": 1.0458999895490706e-05, "CV04": 1.8329956219531596e-06, "CV05": 1.6670019249431789e-06, "CV06": 4.334004188422114e-06, "CV07": 3.916997229680419e-06, "CV08": 1.624997821636498e-06, "CV09": 1.9999999494757503e-05, "CV10": 1.9170038285665214e-06, "CV11": 2.125001628883183e-06, "CV12": 6.334004865493625e-06, "JJ01": 2.3329994291998446e-06, "LT01": 0.0001798329976736568, "LT02": 0.00015754099877085537, "LT03": 4.292000085115433e-06, "LT04": 2.1669984562322497e-06, "LT05": 9.900000441120937e-05, "LT06": 3.8330035749822855e-06, "LT07": 2.4579931050539017e-06, "LT08": 1.8749997252598405e-06, "LT09": 3.699999797390774e-05, "LT10": 1.1083997378591448e-05, "LT11": 2.0000006770715117e-06, "LT12": 2.0958999812137336e-05, "LT13": 6.542002665810287e-06, "LT14": 9.579199831932783e-05, "LT15": 1.612499909242615e-05, "OR01": 2.624998160172254e-06, "PG01": 2.082997525576502e-06, "PG02": 1.8329956219531596e-06, "RF01": 7.324999751290306e-05, "RF02": 3.995899896835908e-05, "RF03": 5.833299655932933e-05, "RF04": 1.945799886016175e-05, "RF05": 1.7790996935218573e-05, "RF06": 1.695800165180117e-05, "RF07": 1.8749997252598405e-06, "ST01": 1.5839978004805744e-06, "ST02": 1.7909987946040928e-06, "ST03": 1.624997821636498e-06, "ST04": 1.7499987734481692e-06, "ST05": 5.566600157180801e-05, "ST06": 1.8207996618002653e-05, "ST07": 2.4170003598555923e-06, "ST08": 1.7583995941095054e-05, "ST09": 1.3959004718344659e-05, "ST10": 2.0410006982274354e-06, "ST11": 1.733299723127857e-05, "ST12": 3.7919962778687477e-06, "TQ01": 1.9169965526089072e-06, "TQ02": 1.7499987734481692e-06, "TQ03": 1.7499987734481692e-06, "TQ04": 1.7089987522922456e-06}}]
|