File upstream rustqual issues found during adoption
rustqual problems found while adopting it, to report at https://github.com/SaschaOnTour/rustqual/issues (pinned at v1.8.2 in the justfile). Reproduce each one on the current version before filing, and drop any that a newer release has fixed.
SRP-002stops counting at the first#[cfg(test)]anywhere in a file.count_production_linesinsrc/adapters/analyzers/srp/module.rsbreaks on the first line starting with#[cfg(test)], so a test-only helper partway down a file hides all the production code below it.--compare --fail-on-regressionmisses new findings. It treats a regression asquality_scoredropping. Adding compliant code alongside a new finding dilutes the score enough to hold it level. A baseline that can't be parsed reports "not regressed" and exits 0 under--no-fail.- Dimensions that can't be disabled. IOSP has no
enabledkey, andMAGIC_NUMBERstill fires under[complexity] enabled = false. Disabling a dimension then reports its matchingqual:allowmarkers as orphaned (ORPHAN_SUPPRESSION), even though the findings keep firing. See.config/rustqual/dry.toml. DRYis all-or-nothing. Turning off[duplicates]also turns off dead-code (DRY-002) and dead-type detection. A per-rule switch would remove the need for a second pass. Running two passes meansqual:allow(dry, duplicate)(DRY-001) andqual:allow(dry, fragment)(DRY-003) cannot be used: each marker suppresses its finding in the DRY pass, but the main pass (which disables[duplicates]) reports the marker asORPHAN-001(item 3; verified with probe markers on 2026-11-12). The guidance files note this limitation until the second pass is removed;qual:inversepairs are unaffected.ai-jsonlacks the stable rule ID and the threshold/actual values (for examplelength=72 > 60). Agents need both to fix a finding without a second lookup.- Possible IOSP false positive.
exponential_backoff(crates/jp_llm/src/retry.rs) appears as a violation although it seems to call only std methods and do arithmetic. Confirm with--verbosethat a method name matched a project function before filing. CX-003skips functions classified as trivial. A function with no logic and no calls into the project isTrivial, andattach_metrics(src/adapters/analyzers/iosp/classify.rs) drops every complexity metric of a trivial function, magic numbers included.pub fn probe() -> u32 { 4242 }produced noCX-003in CI, onlyDRY-002. For a function that only returns the literal this is defensible: the function name does the job of aconstname. The same classification covers any straight-line body, though, so a literal passed to a std or third-party call in such a function should go unreported too. Reproduce that second case before filing, and propose limiting the exemption to a body that is a single literal expression.TQ-002doesn't follow calls through trait impls. A test that reaches the code under test through.into()(From) orto_string()(Display) is reported as calling no production function:from_datetimeincrates/jp_cli/src/cmd/time_tests.rsandinitialize_timeout_display_includes_timeout_command_and_stderrincrates/jp_mcp/src/client_tests.rs, both markedqual:allow(test_quality, no_sut). Two neighboring tests inclient_tests.rsassert onto_string()the same way and are not reported; find out what differs before filing.- Concrete impact of item 1. Before moving early
#[cfg(test)]items to the end of each file,crates/jp_llm/src/provider/anthropic.rs(~3,700 lines,#[cfg(test)]import on line 25) counted as 22 production lines,openai.rsas 52, andgoogle.rsas 134, allowing the largest files in the workspace to pass theSRP-002length check. T-1haqsmg enforces placing#[cfg(test)]only at the end of a file in JP, but the upstream bug remains for workspaces without that convention. SRP-002does not name its clusters. The SARIF message reports "N independent clusters" without listing the functions in each cluster, even though the analyzer computes them (cluster_names). For example,crates/jp_cli/src/bootstrap.rsis reported with 3 clusters despite having a single responsibility; without the function names, the finding cannot be verified or acted on. The cluster check is disabled in.config/rustqual/config.tomluntil the message includes cluster members.qual:allow(complexity, magic_numbers)on astaticorconstis reported asORPHAN-001without explaining why.rustqualdoes not flag magic numbers insideconstorstaticinitializers, so a suppression marker on those items has no finding to match. ReportingORPHAN-001is accurate, but the message ("no finding in window") does not indicate thatconstandstaticitems are already exempt fromCX-003.- SARIF messages omit fields the analyzer already computes. The guidance files (T-0yh8q2s) hardcode the missing context:
CX-001,CX-002,CX-004, andCX-005report the measured value without the threshold (ComplexityFindingstores both).A20reports only a count ("error-handling smells 1") without naming whetherunwrap,expect,panic!,unreachable!, ortodo!triggered it.DRY-001,DRY-003, andDRY-005report "N other function(s)" without listing them, even though each finding stores itsparticipants(only the text report prints them).DRY-002omits theuncalled/testonlyclassification and the remediation suggestion.
DRY-002andDRY-006count calls, not references. A function passed as a value is flagged as dead code:http_handlerincrates/jp_attachment_http_content/src/lib.rs(used to initialize astatic) andparse_specincrates/jp_cli/src/cmd/compact_flag.rs(a clap value parser). Astaticregistered via#[distributed_slice(HANDLERS)](HANDLERin the attachment crates), which is read by the linker, is also flagged. Neither rule acceptsqual:allow, andqual:apiis rejected on private items.DRY-005groupsmatchexpressions by shape, ignoring the matched type.group_repeated_patterns(src/adapters/analyzers/dry/match_patterns.rs) groups by a hash of the normalizedmatchalone. Normalization strips path prefixes from patterns and erases literal values, so everymatchthat maps the same number of unit variants to string literals lands in the same group regardless of the enum. For example, "repeated match on Self (6 occurrences)" groupsPathRoot::as_strinbookworm(whose arm patterns start withPathRoot::) together with<Status as Display>::fmtinticket: the type name in the message is extracted from the second-to-last path segment of an arm in onematchof the group (extract_enum_name), not used in the grouping key. Propose including the matched type in the grouping key (resolvingSelfto the enclosingimpltype) and skippingmatchexpressions whose matched type cannot be inferred from the arm patterns. The detector also ignores[duplicates] enabled = false:run_dry_pass(src/app/secondary.rs) gates it ondetect_repeated_matchesalone, so JP's main pass runs it too.TQ-001passes any test that contains a function call.detect_assertion_free_tests(src/adapters/analyzers/tq/assertions.rs) treats any function or method call in the test body as an implicit assertion. As a result,#[test] fn it_works() { run_thing(); }(the rustqual documentation's own example of whatTQ-001catches) passes, and only tests with neither assertion macros nor calls are reported.
Comments
- From: jp
- Date: 2026-11-04T09:44:53Z
T-1dhk659 vendors rustqual into crates/contrib/rustqual, so these become "fix here, offer upstream" rather than "file and wait". Items 2 (--compare misses new findings), 3 (dimensions that can't be disabled) and 4 (DRY is all-or-nothing) are covered by its follow-up, which folds qual's per-finding diff and per-rule switches into rustqual. Item 5 (ai-json lacks rule ID and metric values) is a small change once it's in-tree. Items 1 and 6 still need reproducing.