#1567·xberg

chore(lint): pay down the size and complexity baseline

Author: GoldziherCreated Sep 5, 2026Updated Sep 27, 2026
Labelshelp wantedgood first issueP2

poly lint is green in this repo, but not because the code is under the size and complexity limits. 1,572 size/complexity findings across 198 files are suppressed by per-file entries in alef.toml, under the # --- quality-debt baseline --- block. Those 1,572 findings are declared as 504 per-file rule attachments — one attachment can cover many findings in the same file, so the line you delete from the baseline is not the unit of work; the findings behind it are.

Why it is a per-file list and not a rule switched off

Listing each file keeps the metrics active on every file that is not listed, so new code is still checked and new violations still fail. The cost is that each existing offender has to be paid off individually — which is exactly what makes each one a self-contained task.

What one unit of work looks like

  1. Pick a path from the list below.
  2. Reduce its findings — extract helpers from long functions, early-return to flatten nesting, group wide parameter lists into a struct, split an oversized file by responsibility.
  3. Delete that file's entry from the baseline in alef.toml.
  4. Run the crate's/package's tests and poly lint — both must be green.

Ground rules

  • Behaviour must not change. This is restructuring, not redesign. No arithmetic, ordering, dispatch or output changes.
  • A smaller, safe change is worth more than a complete one. If a file cannot be reduced without a behaviour risk you cannot rule out, say so in the PR and leave it.
  • Do not add new paths to the baseline.
  • This repo's poly.toml is generated from alef.toml — edit alef.toml and re-run alef scaffold, never poly.toml directly.

How to reproduce these numbers

poly lint exits 0 on quality warnings and its cache is blind to cross-file rules, so neither the exit code nor a cached run is evidence. Count the suppressions directly:

bash
poly lint --no-cache --no-workspace --format json > lint.json
# then count entries in .suppressed where reason == "per-file-ignore"
# and code is one of the six rules below

Findings suppressed by the **/tests/**-style policy globs and by the generated-binding globs (packages/**, crates/xberg-{jni,node,php}/**) are not part of this issue — attribute each suppression to its matching key before counting.

Rules in this baseline

rule findings files listed meaning
function-too-long 461 137 function longer than 80 lines
nesting-too-deep 649 67 more than 4 levels of nesting
file-too-long 154 154 file longer than 1000 lines
cyclomatic-complexity 161 90 cyclomatic complexity over 20
too-many-parameters 140 49 more than 6 parameters
type-too-long 7 7 type longer than 300 lines
total 1,572 504

Best places to start

These carry the most findings.

file findings rules
crates/xberg-native-pdf/src/rendering/page_renderer.rs 108 function-too-long ×24, nesting-too-deep ×66, file-too-long ×1, cyclomatic-complexity ×4, too-many-parameters ×13
crates/xberg/src/extractors/rtf/parser/text_extract.rs 68 function-too-long ×1, nesting-too-deep ×66, cyclomatic-complexity ×1
crates/xberg-native-pdf/src/structure/spatial_table_detector.rs 43 function-too-long ×20, nesting-too-deep ×12, file-too-long ×1, cyclomatic-complexity ×9, too-many-parameters ×1
crates/xberg/src/extractors/fictionbook.rs 42 function-too-long ×5, nesting-too-deep ×33, file-too-long ×1, cyclomatic-complexity ×3
crates/xberg/src/extraction/docx/parser.rs 39 function-too-long ×5, nesting-too-deep ×29, file-too-long ×1, cyclomatic-complexity ×4
crates/xberg/src/extractors/odt.rs 39 function-too-long ×5, nesting-too-deep ×30, file-too-long ×1, cyclomatic-complexity ×2, too-many-parameters ×1
crates/xberg/src/extractors/rtf/parser/formatting_extract.rs 37 function-too-long ×1, nesting-too-deep ×35, cyclomatic-complexity ×1
crates/xberg/src/extractors/docbook.rs 36 function-too-long ×4, nesting-too-deep ×26, file-too-long ×1, cyclomatic-complexity ×5
crates/xberg-native-pdf/src/extractors/text/advance.rs 36 function-too-long ×6, nesting-too-deep ×26, file-too-long ×1, cyclomatic-complexity ×3
crates/xberg/src/extractors/pdf/ocr/tests.rs 32 function-too-long ×31, file-too-long ×1
crates/xberg-native-pdf/src/fonts/font_dict.rs 30 function-too-long ×23, nesting-too-deep ×4, file-too-long ×1, cyclomatic-complexity ×2
crates/xberg/src/extractors/docx.rs 29 function-too-long ×8, nesting-too-deep ×17, file-too-long ×1, cyclomatic-complexity ×2, too-many-parameters ×1
crates/xberg-native-pdf/src/rendering/text_rasterizer.rs 28 function-too-long ×6, nesting-too-deep ×12, file-too-long ×1, cyclomatic-complexity ×4, too-many-parameters ×5
crates/xberg/src/extractors/latex/mod.rs 26 function-too-long ×4, nesting-too-deep ×18, file-too-long ×1, cyclomatic-complexity ×3
crates/xberg/src/extractors/markdown.rs 24 function-too-long ×1, nesting-too-deep ×21, file-too-long ×1, cyclomatic-complexity ×1

crates/xberg/src/pdf/native/text.rs (5 findings) is excluded from that table on purpose: it is being rewritten under the separate reading-order work item, so do not start there.

Full list — all 198 files
  • .github/workflows/benchmarks.yaml — 1: file-too-long ×1
  • .github/workflows/profiling.yaml — 1: file-too-long ×1
  • .github/workflows/publish.yaml — 1: file-too-long ×1
  • crates/xberg-candle-ocr/src/models/deepseek_ocr/model.rs — 5: function-too-long ×1, file-too-long ×1, too-many-parameters ×3
  • crates/xberg-candle-ocr/src/models/paddleocr_vl/model.rs — 8: function-too-long ×3, nesting-too-deep ×4, file-too-long ×1
  • crates/xberg-cli/src/commands/overrides/mod.rs — 1: type-too-long ×1
  • crates/xberg-cli/src/main.rs — 3: function-too-long ×1, file-too-long ×1, type-too-long ×1
  • crates/xberg-cli/tests/commands_test.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/src/content/operators.rs — 2: file-too-long ×1, type-too-long ×1
  • crates/xberg-native-pdf/src/content/parser.rs — 12: function-too-long ×7, file-too-long ×1, cyclomatic-complexity ×4
  • crates/xberg-native-pdf/src/converters/text_post_processor.rs — 7: function-too-long ×1, nesting-too-deep ×5, file-too-long ×1
  • crates/xberg-native-pdf/src/document/annotations.rs — 7: function-too-long ×3, nesting-too-deep ×1, cyclomatic-complexity ×3
  • crates/xberg-native-pdf/src/document/columns.rs — 19: function-too-long ×12, file-too-long ×1, cyclomatic-complexity ×6
  • crates/xberg-native-pdf/src/document/extract_api.rs — 11: function-too-long ×5, nesting-too-deep ×3, file-too-long ×1, cyclomatic-complexity ×2
  • crates/xberg-native-pdf/src/document/fonts.rs — 23: function-too-long ×2, nesting-too-deep ×18, file-too-long ×1, cyclomatic-complexity ×2
  • crates/xberg-native-pdf/src/document/images.rs — 8: function-too-long ×5, file-too-long ×1, cyclomatic-complexity ×2
  • crates/xberg-native-pdf/src/document/mod.rs — 3: function-too-long ×2, file-too-long ×1
  • crates/xberg-native-pdf/src/document/objects.rs — 9: function-too-long ×5, nesting-too-deep ×1, file-too-long ×1, cyclomatic-complexity ×2
  • crates/xberg-native-pdf/src/document/open.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/src/document/pages.rs — 8: function-too-long ×4, nesting-too-deep ×2, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/document/paths.rs — 4: function-too-long ×2, nesting-too-deep ×1, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/document/reading_order.rs — 9: function-too-long ×3, nesting-too-deep ×4, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/document/span_postprocess.rs — 7: function-too-long ×5, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/document/spans_text.rs — 8: function-too-long ×4, file-too-long ×1, cyclomatic-complexity ×3
  • crates/xberg-native-pdf/src/document/tables.rs — 10: function-too-long ×3, nesting-too-deep ×5, cyclomatic-complexity ×2
  • crates/xberg-native-pdf/src/document/text_assembly.rs — 23: function-too-long ×1, nesting-too-deep ×20, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/elements/path.rs — 2: file-too-long ×1, too-many-parameters ×1
  • crates/xberg-native-pdf/src/encryption/algorithms.rs — 4: file-too-long ×1, too-many-parameters ×3
  • crates/xberg-native-pdf/src/encryption/mod.rs — 2: function-too-long ×2
  • crates/xberg-native-pdf/src/extractors/images.rs — 4: function-too-long ×1, file-too-long ×1, cyclomatic-complexity ×1, too-many-parameters ×1
  • crates/xberg-native-pdf/src/extractors/text/advance.rs — 36: function-too-long ×6, nesting-too-deep ×26, file-too-long ×1, cyclomatic-complexity ×3
  • crates/xberg-native-pdf/src/extractors/text/mod.rs — 4: function-too-long ×1, file-too-long ×1, cyclomatic-complexity ×1, too-many-parameters ×1
  • crates/xberg-native-pdf/src/extractors/text/operators.rs — 12: function-too-long ×2, nesting-too-deep ×8, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/extractors/text/span_merging.rs — 6: function-too-long ×1, nesting-too-deep ×4, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/extractors/text/xobjects.rs — 7: function-too-long ×1, nesting-too-deep ×5, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/fonts/cff_encoding.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/src/fonts/cmap.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/src/fonts/font_dict.rs — 30: function-too-long ×23, nesting-too-deep ×4, file-too-long ×1, cyclomatic-complexity ×2
  • crates/xberg-native-pdf/src/functions/mod.rs — 4: function-too-long ×1, nesting-too-deep ×1, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/parser.rs — 6: function-too-long ×2, nesting-too-deep ×3, file-too-long ×1
  • crates/xberg-native-pdf/src/pipeline/reading_order/xycut.rs — 14: function-too-long ×9, file-too-long ×1, cyclomatic-complexity ×4
  • crates/xberg-native-pdf/src/rendering/mesh_shading.rs — 5: function-too-long ×3, file-too-long ×1, too-many-parameters ×1
  • crates/xberg-native-pdf/src/rendering/page_renderer.rs — 108: function-too-long ×24, nesting-too-deep ×66, file-too-long ×1, cyclomatic-complexity ×4, too-many-parameters ×13
  • crates/xberg-native-pdf/src/rendering/resolution/color.rs — 5: function-too-long ×3, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/rendering/separation_renderer.rs — 18: function-too-long ×4, nesting-too-deep ×2, file-too-long ×1, cyclomatic-complexity ×2, too-many-parameters ×9
  • crates/xberg-native-pdf/src/rendering/sidecar.rs — 6: function-too-long ×5, file-too-long ×1
  • crates/xberg-native-pdf/src/rendering/text_rasterizer.rs — 28: function-too-long ×6, nesting-too-deep ×12, file-too-long ×1, cyclomatic-complexity ×4, too-many-parameters ×5
  • crates/xberg-native-pdf/src/structure/parser.rs — 11: function-too-long ×3, nesting-too-deep ×3, file-too-long ×1, cyclomatic-complexity ×2, too-many-parameters ×2
  • crates/xberg-native-pdf/src/structure/spatial_table_detector.rs — 43: function-too-long ×20, nesting-too-deep ×12, file-too-long ×1, cyclomatic-complexity ×9, too-many-parameters ×1
  • crates/xberg-native-pdf/src/structure/table_extractor.rs — 8: function-too-long ×5, nesting-too-deep ×2, file-too-long ×1
  • crates/xberg-native-pdf/src/structure/traversal.rs — 2: function-too-long ×1, file-too-long ×1
  • crates/xberg-native-pdf/src/text/bidi.rs — 2: file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/xfa/parser.rs — 9: function-too-long ×1, nesting-too-deep ×7, cyclomatic-complexity ×1
  • crates/xberg-native-pdf/src/xref.rs — 6: function-too-long ×3, file-too-long ×1, cyclomatic-complexity ×2
  • crates/xberg-native-pdf/tests/extraction_api_regression.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_46_round2_qa_pass.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_46_round3_qa_pass.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_46_round4_qa_pass.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_ocg_ink_filtering.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_render_ocg_filtering.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_render_output_intent.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_render_resolution_pipeline_qa_wave2.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_render_resolution_pipeline_qa_wave3.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_render_resolution_pipeline_qa_wave4.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_separation_rendering.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_struct_actualtext_probes.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_transparency_flattening_audit.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_transparency_flattening_qa_round2.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_vertical_writing_mode_qa_probes.rs — 1: file-too-long ×1
  • crates/xberg-native-pdf/tests/test_word_boundary_detection.rs — 1: file-too-long ×1
  • crates/xberg-paddle-ocr/src/ocr_lite.rs — 7: too-many-parameters ×7
  • crates/xberg-pdfium-render/src/bindgen/pdfium_7678.rs — 1: file-too-long ×1
  • crates/xberg-pdfium-render/src/bindings.rs — 3: file-too-long ×1, too-many-parameters ×1, type-too-long ×1
  • crates/xberg-pdfium-render/src/bindings/dynamic_bindings.rs — 17: function-too-long ×1, file-too-long ×1, too-many-parameters ×14, type-too-long ×1
  • crates/xberg-pdfium-render/src/bindings/static_bindings.rs — 15: file-too-long ×1, too-many-parameters ×14
  • crates/xberg-pdfium-render/src/font_provider.rs — 1: too-many-parameters ×1
  • crates/xberg-pdfium-render/src/pdf/document/page.rs — 1: too-many-parameters ×1
  • crates/xberg-pdfium-render/src/pdf/document/page/object/path.rs — 4: too-many-parameters ×4
  • crates/xberg-pdfium-render/src/pdf/document/page/objects/common.rs — 2: too-many-parameters ×2
  • crates/xberg-pdfium-render/src/pdf/quad_points.rs — 2: too-many-parameters ×2
  • crates/xberg-tesseract/build.rs — 13: function-too-long ×8, nesting-too-deep ×3, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg-tesseract/src/api.rs — 1: file-too-long ×1
  • crates/xberg/src/api/handlers.rs — 5: function-too-long ×3, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/candle_ocr/glm_ocr_backend.rs — 1: function-too-long ×1
  • crates/xberg/src/chunking/core.rs — 2: function-too-long ×1, file-too-long ×1
  • crates/xberg/src/core/config/concurrency.rs — 2: nesting-too-deep ×1, file-too-long ×1
  • crates/xberg/src/core/config/extraction/core.rs — 4: function-too-long ×1, file-too-long ×1, cyclomatic-complexity ×1, type-too-long ×1
  • crates/xberg/src/core/config/extraction/env.rs — 2: function-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/core/config/ocr.rs — 2: function-too-long ×1, file-too-long ×1
  • crates/xberg/src/core/extractor/file.rs — 3: function-too-long ×1, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/core/mime.rs — 4: function-too-long ×1, nesting-too-deep ×1, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/core/pipeline/features.rs — 4: function-too-long ×1, nesting-too-deep ×1, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/core/pipeline/mod.rs — 5: function-too-long ×3, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/core/pipeline/tests.rs — 5: function-too-long ×4, file-too-long ×1
  • crates/xberg/src/core/split.rs — 5: function-too-long ×4, file-too-long ×1
  • crates/xberg/src/embeddings/mod.rs — 5: function-too-long ×2, file-too-long ×1, too-many-parameters ×2
  • crates/xberg/src/engine/extract_impl.rs — 3: function-too-long ×1, file-too-long ×1, too-many-parameters ×1
  • crates/xberg/src/engine/extract_impl/tests.rs — 1: file-too-long ×1
  • crates/xberg/src/engine/structured/prompts.rs — 5: nesting-too-deep ×2, too-many-parameters ×3
  • crates/xberg/src/extraction/docx/parser.rs — 39: function-too-long ×5, nesting-too-deep ×29, file-too-long ×1, cyclomatic-complexity ×4
  • crates/xberg/src/extraction/ppt/mod.rs — 3: function-too-long ×1, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/extraction/pptx/tests.rs — 7: function-too-long ×6, file-too-long ×1
  • crates/xberg/src/extractors/archive.rs — 3: function-too-long ×2, too-many-parameters ×1
  • crates/xberg/src/extractors/asciidoc.rs — 1: file-too-long ×1
  • crates/xberg/src/extractors/bibtex.rs — 4: function-too-long ×1, nesting-too-deep ×2, cyclomatic-complexity ×1
  • crates/xberg/src/extractors/djot_format/extractor.rs — 18: function-too-long ×1, nesting-too-deep ×15, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/extractors/djot_format/rendering.rs — 3: function-too-long ×2, cyclomatic-complexity ×1
  • crates/xberg/src/extractors/docbook.rs — 36: function-too-long ×4, nesting-too-deep ×26, file-too-long ×1, cyclomatic-complexity ×5
  • crates/xberg/src/extractors/docx.rs — 29: function-too-long ×8, nesting-too-deep ×17, file-too-long ×1, cyclomatic-complexity ×2, too-many-parameters ×1
  • crates/xberg/src/extractors/email.rs — 5: function-too-long ×3, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/extractors/epub/content.rs — 1: function-too-long ×1
  • crates/xberg/src/extractors/epub/metadata.rs — 5: function-too-long ×1, nesting-too-deep ×3, cyclomatic-complexity ×1
  • crates/xberg/src/extractors/epub/mod.rs — 10: function-too-long ×2, nesting-too-deep ×7, cyclomatic-complexity ×1
  • crates/xberg/src/extractors/excel.rs — 4: function-too-long ×1, nesting-too-deep ×2, file-too-long ×1
  • crates/xberg/src/extractors/fictionbook.rs — 42: function-too-long ×5, nesting-too-deep ×33, file-too-long ×1, cyclomatic-complexity ×3
  • crates/xberg/src/extractors/html.rs — 5: function-too-long ×2, nesting-too-deep ×2, file-too-long ×1
  • crates/xberg/src/extractors/hwpx.rs — 13: function-too-long ×2, nesting-too-deep ×9, file-too-long ×1, cyclomatic-complexity ×1
  • crates/xberg/src/extractors/image.rs — 11: function-too-long ×9, nesting-too-deep ×1, file-too-long ×1
  • crates/xberg/src/extractors/iwork/numbers.rs — 1: file-too-long ×1
  • crates/xberg/src/extractors/jats/elements.rs — 15: function-too-long ×1, nesting-too-deep ×13, cyclomatic-complexity ×1
  • crates/xberg/src/extractors/jats/mod.rs — 17: function-too-long ×3, nesting-too-deep ×10, file-too-long ×1, cyclomatic-complexity ×3
  • crates/xberg/src/extractors/jats/parser.rs — 13: function-too-long ×2, nesting-too-deep ×9, cyclomatic-complexity ×2
  • crates/xberg/src/extractors/jupyter.rs — 10: function-too-long ×3, nesting-too-deep ×4, file-too-long ×1, too-many-parameters ×2
  • crates/xberg/src/extractors/latex/commands.rs — 3: function-too-long ×1, nesting-too-deep ×1, cyclomatic-complexity ×1
  • crates/xberg/src/extractors/latex/mod.rs — 26: function-too-long ×4, nesting-too-deep ×18, file-too-long ×1, cyclomatic-complexity ×3
  • crates/xberg/src/extractors/markdown.rs —