Skip to content

Lower bumpy_road_function detection threshold to 2.5#192

Open
leynos wants to merge 5 commits intomainfrom
fix-bumpy-road-lint-threshold-j24qix
Open

Lower bumpy_road_function detection threshold to 2.5#192
leynos wants to merge 5 commits intomainfrom
fix-bumpy-road-lint-threshold-j24qix

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Apr 7, 2026

Summary

  • Lowered the bumpy_road_function detection threshold from 3.0 to 2.5 to better detect legitimate two-bump patterns in nested match expressions.
  • Updated tests, UI fixtures, and docs to reflect the new threshold.
  • Added a dedicated UI fixture for nested-match scenarios and updated legacy stderr accordingly.

Changes

Core

  • Change default threshold in crates/bumpy_road_function/src/analysis.rs from 3.0 to 2.5.

Tests

  • Update crates/bumpy_road_function/tests/features/bumpy_road.feature: expected threshold to 2.5.
  • Update crates/bumpy_road_function/ui/dylint.toml: threshold to 2.5.

UI Fixtures

  • Added: crates/bumpy_road_function/ui/fail_match_with_nested_if.rs
  • Added: crates/bumpy_road_function/ui/pass_single_match_cluster.rs
  • Updated: crates/bumpy_road_function/ui/fail_two_clusters_legacy.stderr to reflect threshold 2.5.

Documentation

  • docs/adr-002-dylint-expect-attribute-macro.md: adjust wording around cfg checks and 2.5 threshold; minor wording fixes.
  • docs/whitaker-dylint-suite-design.md: update moving-average threshold note to 2.5 and add rationale for lowering; snippet showing threshold = 2.5.

Notes

  • The threshold adjustment includes guidance: users can revert to 3.0 via dylint.toml if false positives arise.

Test plan

  • Run cargo test for bumpy_road_function and UI test suite
  • Verify bumpy_road.feature threshold expectation is 2.5
  • Validate new UI fixtures compile and pass with adjusted threshold
  • Confirm stderr outputs reflect threshold 2.5

◳ Generated by DevBoxer


ℹ️ Tag @devboxerhub to ask questions and address PR feedback

📎 Task: https://www.devboxer.com/task/b91af476-364b-4b17-bd66-1c1b24c5ae89

📝 Closes #133

Summary by Sourcery

Lower the default bumpy_road_function detection threshold and expand coverage for nested match scenarios while updating configuration, tests, and documentation accordingly.

Enhancements:

  • Reduce the default bumpy_road_function moving-average threshold from 3.0 to 2.5 to better detect two-bump patterns in complex match expressions.
  • Add new UI fixtures to cover nested conditional match expressions that should trigger the lint and a single-cluster match that should not.

CI:

  • Broaden nextest UI test filters to include crates whose UI tests are exposed via a binary named ui with a top-level fn ui().

Documentation:

  • Update design and ADR documentation to describe the new 2.5 threshold, its rationale, and configuration examples.

Tests:

  • Adjust bumpy_road_function feature tests, UI thresholds, and legacy stderr expectations to align with the new default threshold.

…r detecting bumps

- Updated the default threshold in Settings, dylint.toml, and related tests to 2.5.
- Adjusted documentation to reflect lowered threshold, improving detection of legitimate complexity bumps in match expressions with nested conditionals.
- Added new UI test fixtures to validate lint behavior with nested conditionals and single cluster scenarios.

This change enhances sensitivity for detecting bumpy road patterns while preserving configurability for users.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 7, 2026

Reviewer's Guide

Lowers the default bumpy_road_function moving-average threshold from 3.0 to 2.5, aligns tests, UI fixtures, and docs with the new behavior, adds nested-match UI coverage, and updates nextest’s UI test filter to catch additional ui test binaries.

Flow diagram for bumpy_road_function analysis with 2.5 threshold and new UI fixtures

flowchart TD
    A[Start lint: analyze function body] --> B[Compute line_complexity for each line]
    B --> C[Apply moving average with window = 3]
    C --> D[Threshold smoothed signal at T = 2.5]
    D --> E[Identify contiguous bumps where value >= 2.5]
    E --> F[Filter bumps shorter than min_bump_lines = 2]
    F --> G{Number of remaining bumps}

    G -->|< 2 bumps| H[No warning: function passes]
    G -->|>= 2 bumps| I[Emit bumpy_road_function warning]

    subgraph UI_fixtures
        J[fail_match_with_nested_if.rs<br>match with two arms, each with nested conditionals<br>produces two separated bumps]
        K[pass_single_match_cluster.rs<br>match with one complex arm<br>produces a single contiguous bump]
    end

    J --> B
    K --> B

    I --> Z[End]
    H --> Z
Loading

File-Level Changes

Change Details Files
Lower default bumpy_road_function detection threshold and update configuration/tests to match.
  • Change Settings::default threshold value from 3.0 to 2.5 in the bumpy_road_function analysis settings.
  • Update the Gherkin feature test expectation for the normalized default threshold to 2.5.
  • Adjust the bumpy_road_function UI dylint.toml configuration to use threshold 2.5.
crates/bumpy_road_function/src/analysis.rs
crates/bumpy_road_function/tests/features/bumpy_road.feature
crates/bumpy_road_function/ui/dylint.toml
Add UI fixtures to exercise nested-match two-bump cases and a single-cluster match case, with corresponding stderr expectations.
  • Introduce a failing UI fixture with a match expression containing two nested conditional clusters intended to trigger the lint at the new threshold.
  • Introduce a passing UI fixture with a single conditional cluster that should not trigger the lint.
  • Add/update corresponding .stderr files so diagnostics match the new threshold behavior, including legacy two-cluster expectations.
crates/bumpy_road_function/ui/fail_match_with_nested_if.rs
crates/bumpy_road_function/ui/pass_single_match_cluster.rs
crates/bumpy_road_function/ui/fail_two_clusters_legacy.stderr
crates/bumpy_road_function/ui/fail_match_with_nested_if.stderr
Update documentation to describe the new 2.5 threshold and rationale, plus minor formatting/wording fixes.
  • Change the described moving-average threshold from 3.0 to 2.5 in the suite design doc and add a note explaining the rationale and configurability of the threshold.
  • Update the TOML configuration example to show threshold = 2.5.
  • Reflow and clarify ADR wording around Dylint lint execution, cfg checks, and macro ordering to improve readability.
docs/whitaker-dylint-suite-design.md
docs/adr-002-dylint-expect-attribute-macro.md
Broaden nextest’s UI test filter to reliably include ui binaries with a single top-level fn ui().
  • Extend the nextest filter expression with an additional clause (binary(ui) & test(=ui)) and document why the extra clause is needed for crates like bumpy_road_function.
.config/nextest.toml

Assessment against linked issues

Issue Objective Addressed Explanation
#133 Ensure the bumpy_road_function lint reports functions like session_key_from_env that have two nested conditional blocks in a match expression (i.e., legitimate two-bump patterns) as bumpy roads.
#133 Clarify documentation on whether any additional flags or configuration are required to enable or run the experimental bumpy_road_function lint beyond using the --experimental installer mode and adding it to dylint libraries. The PR updates documentation and configuration around the bumpy road threshold (lowering it to 2.5) and explains the rationale, but it does not add or modify documentation about how to enable experimental lints or any extra flags needed to run bumpy_road_function in Whitaker.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-delta-analysis[bot]

This comment was marked as outdated.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Overview

This PR lowers the bumpy_road_function lint detection threshold from 3.0 to 2.5 to improve detection of functions with multiple nested conditional blocks (two or more "bumps" at depth ≥ 2), such as the session_key_from_env function identified in issue #133. The lower threshold enables the lint to flag patterns involving nested conditionals that would previously have been missed.

Changes

Core threshold update

  • Updated Settings::default() in crates/bumpy_road_function/src/analysis.rs to set threshold: 2.5 (previously 3.0).
  • Updated crates/bumpy_road_function/ui/dylint.toml test configuration to reflect the new threshold.

Test updates

  • Updated crates/bumpy_road_function/tests/features/bumpy_road.feature to expect threshold becomes 2.5 in the "Negative thresholds fall back to defaults" scenario.
  • Updated crates/bumpy_road_function/ui/fail_two_clusters_legacy.stderr diagnostic output to reflect "above the threshold 2.5".

New UI test fixtures

  • Added crates/bumpy_road_function/ui/fail_match_with_nested_if.rs: a test fixture with a key_from_file function containing nested match and conditional expressions designed to trigger the bumpy road lint at the new threshold. Includes corresponding stderr snapshot fail_match_with_nested_if.stderr.
  • Added crates/bumpy_road_function/ui/pass_single_match_cluster.rs: a passing fixture with a categorise function that uses a refactored helper predicate is_small_eligible to keep conditional complexity within bounds.

Documentation updates

  • Updated docs/whitaker-dylint-suite-design.md to reflect the new threshold (T = 2.5) and added rationale explaining that moving-average smoothing reduces raw peaks by approximately 15–20%. Includes guidance that users can raise the threshold back to 3.0 or higher via dylint.toml if false positives occur.
  • Updated docs/adr-002-dylint-expect-attribute-macro.md with minor whitespace/line-wrapping adjustments for improved readability.

Test infrastructure

  • Updated .config/nextest.toml to expand the serial-dylint-ui test group filter to include additional test patterns (binary(ui) & test(=ui)) for improved integration test coverage.

Outcome

Closes #133. The threshold reduction allows bumpy_road_function to detect and flag functions with two or more nested conditional clusters, improving detection of maintainability concerns in complex conditional logic whilst maintaining flexibility for users to adjust sensitivity via dylint.toml configuration.

Walkthrough

Reduces the default threshold for the bumpy_road_function lint from 3.0 to 2.5, alongside new UI test fixtures demonstrating nested conditional detection. Updates test expectations, test infrastructure, configuration files, and documentation to reflect the lower sensitivity threshold.

Changes

Cohort / File(s) Summary
Core Configuration Change
crates/bumpy_road_function/src/analysis.rs
Updated Settings::default() threshold from 3.0 to 2.5, lowering the baseline smoothing-value cutoff for default configuration.
Test Infrastructure & Fixtures
.config/nextest.toml, crates/bumpy_road_function/ui/dylint.toml, crates/bumpy_road_function/ui/fail_match_with_nested_if.rs, crates/bumpy_road_function/ui/pass_single_match_cluster.rs
Added new UI test fixtures for nested conditional detection (fail and pass cases) and updated test filter configuration and lint settings to align with new threshold.
Test Expectations & Outputs
crates/bumpy_road_function/ui/fail_match_with_nested_if.stderr, crates/bumpy_road_function/ui/fail_two_clusters_legacy.stderr, crates/bumpy_road_function/tests/features/bumpy_road.feature
Updated expected test outputs and feature file assertions to reflect threshold change from 3.0 to 2.5.
Documentation
docs/adr-002-dylint-expect-attribute-macro.md, docs/whitaker-dylint-suite-design.md
Updated design documentation with new threshold value and added rationale for sensitivity adjustment; minor whitespace reformatting in ADR.

Suggested labels

Issue

Poem

🛣️ Bumpy roads now caught sooner,
Threshold drops from three to two-point-five,
Nested ifs can't hide away,
Tests declare the lint's alive! ✨

🚥 Pre-merge checks | ✅ 8 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Developer Documentation ⚠️ Warning Pull request modifies tooling, internal API behaviour, and code patterns without sufficient documentation of changes or resolution of review comments. Document nextest filter pattern and Settings threshold rationale in developers-guide.md; add rustdoc to Mode enum; fix categorise function assertion; replace crate-level dead-code suppressions with item-level attributes.
✅ Passed checks (8 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: lowering the bumpy_road_function detection threshold from 3.0 to 2.5.
Description check ✅ Passed The description comprehensively details the threshold change, updated tests, new UI fixtures, and documentation adjustments, all aligned with the changeset.
Linked Issues check ✅ Passed The PR successfully addresses issue #133 by lowering the threshold to 2.5 to detect nested conditionals in match expressions, including new UI fixtures mirroring the reported function structure.
Out of Scope Changes check ✅ Passed All changes remain within scope: threshold adjustment, test updates, UI fixtures for nested conditionals, and documentation reflecting the new threshold. The nextest.toml change is minor scope expansion to support UI test execution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Testing ✅ Passed Core functionality change (threshold 3.0 → 2.5) and new UI fixtures are adequately guarded by unit tests, BDD scenarios, and behavioural snapshot testing.
User-Facing Documentation ✅ Passed The PR documentation updates in whitaker-dylint-suite-design.md appropriately reflect the threshold change from 3.0 to 2.5, including technical rationale and user configuration guidance.
Module-Level Documentation ✅ Passed All Rust modules modified or added in this pull request carry clear, descriptive module-level documentation using the //! rustdoc comment convention.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #133

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-bumpy-road-lint-threshold-j24qix

Comment @coderabbitai help to get the list of available commands and usage tips.

The Mode enum visibility was changed from private to public to allow use outside the module.

Additionally, a new stderr file was added capturing warnings about nested conditional logic complexity in the key_from_file function, suggesting refactoring to reduce complexity.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 7, 2026

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

Complex Conditional

crates/bumpy_road_function/ui/pass_single_match_cluster.rs: categorise

What lead to degradation?

categorise has 1 complex conditionals with 3 branches, threshold = 2

Why does this problem occur?

A complex conditional is an expression inside a branch such as an if-statmeent which consists of multiple, logical operations. Example: if (x.started() && y.running()).Complex conditionals make the code even harder to read, and contribute to the Complex Method code smell. Encapsulate them.

How to fix it?

Apply the DECOMPOSE CONDITIONAL refactoring so that the complex conditional is encapsulated in a separate function with a good name that captures the business rule. Optionally, for simple expressions, introduce a new variable which holds the result of the complex conditional.

Helpful refactoring examples

To get a general understanding of what this code health issue looks like - and how it might be addressed - we have prepared some diffs for illustrative purposes.

SAMPLE

# complex_conditional.js
 function messageReceived(message, timeReceived) {
-   // Ignore all messages which aren't from known customers:
-   if (!message.sender &&
-       customers.getId(message.name) == null) {
+   // Refactoring #1: encapsulate the business rule in a
+   // function. A clear name replaces the need for the comment:
+   if (!knownCustomer(message)) {
      log('spam received -- ignoring');
      return;
    }
 
-  // Provide an auto-reply when outside business hours:
-  if ((timeReceived.getHours() > 17) ||
-      (timeReceived.getHours() < 8)) {
+  // Refactoring #2: encapsulate the business rule.
+  // Again, note how a clear function name replaces the
+  // need for a code comment:
+  if (outsideBusinessHours(timeReceived)) {
     return autoReplyTo(message);
   }
 
   pingAgentFor(message);
+}
+
+function outsideBusinessHours(timeReceived) {
+  // Refactoring #3: replace magic numbers with
+  // symbols that communicate with the code reader:
+  const closingHour = 17;
+  const openingHour = 8;
+
+  const hours = timeReceived.getHours();
+
+  // Refactoring #4: simple conditional rules can
+  // be further clarified by introducing a variable:
+  const afterClosing = hours > closingHour;
+  const beforeOpening = hours < openingHour;
+
+  // Yeah -- look how clear the business rule is now!
+  return afterClosing || beforeOpening;
 }

@coderabbitai

This comment was marked as resolved.

…function

Changed the key file path from an incorrect '/tmp/key' to 'key' to align with expected file location and fix file reading errors.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Extracted conditional logic for small eligible numbers into the helper function `is_small_eligible` to improve clarity and maintainability in the single cluster match arm.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Update the nextest filter expression to catch crates where the integration test
binary is named `ui` with a top-level test function `ui()`. This change ensures
such tests are correctly matched and run, addressing cases not previously caught
by the substring match `test(ui::ui)`.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos marked this pull request as ready for review April 8, 2026 23:09
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The default threshold value (2.5) is now duplicated across Settings::default, the feature test expectation, the UI dylint.toml, and docs snippets—consider centralizing it in a single constant or helper (and referencing it from tests where practical) to reduce the chance of drift on future threshold changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The default threshold value (2.5) is now duplicated across `Settings::default`, the feature test expectation, the UI `dylint.toml`, and docs snippets—consider centralizing it in a single constant or helper (and referencing it from tests where practical) to reduce the chance of drift on future threshold changes.

## Individual Comments

### Comment 1
<location path=".config/nextest.toml" line_range="34" />
<code_context>
+# integration binary is `tests/ui.rs` with a top-level `fn ui()` — the test
+# name reported to nextest is plain `ui`, not `ui::ui`, so the substring
+# match `test(ui::ui)` does not capture them (e.g. bumpy_road_function).
+filter = "test(driver::ui::) | test(tests::ui::) | test(ui::ui) | (binary(ui) & test(=ui))"
 test-group = "serial-dylint-ui"
 retries = { backoff = "exponential", count = 2, delay = "5s" }
</code_context>
<issue_to_address>
**issue (review_instructions):** Add or document an automated test that demonstrates the nextest filter bug and verifies this new `(binary(ui) & test(=ui))` clause fixes it.

Treat this filter change as a bug fix: previously, certain `ui` tests (e.g. `tests/ui.rs` with top-level `fn ui()`) were not executed, and this clause is intended to correct that. Introduce an automated test (or test harness invocation) that fails without this filter change and passes with it, so that regressions in the filter expression are caught in CI.

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*`

**Instructions:**
Bug fixes *must* be demonstrated by a test.

</details>
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

# integration binary is `tests/ui.rs` with a top-level `fn ui()` — the test
# name reported to nextest is plain `ui`, not `ui::ui`, so the substring
# match `test(ui::ui)` does not capture them (e.g. bumpy_road_function).
filter = "test(driver::ui::) | test(tests::ui::) | test(ui::ui) | (binary(ui) & test(=ui))"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (review_instructions): Add or document an automated test that demonstrates the nextest filter bug and verifies this new (binary(ui) & test(=ui)) clause fixes it.

Treat this filter change as a bug fix: previously, certain ui tests (e.g. tests/ui.rs with top-level fn ui()) were not executed, and this clause is intended to correct that. Introduce an automated test (or test harness invocation) that fails without this filter change and passes with it, so that regressions in the filter expression are caught in CI.

Review instructions:

Path patterns: **/*

Instructions:
Bug fixes must be demonstrated by a test.

@coderabbitai coderabbitai bot added the Issue label Apr 8, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/bumpy_road_function/ui/fail_match_with_nested_if.rs`:
- Around line 9-13: The public enum Mode (variants Debug and Release) lacks
rustdoc comments; add concise Rustdoc comments above the Mode enum and each
variant using /// to describe the purpose of the enum and what each variant
represents (e.g., Debug: run with debug assertions and extra checks; Release:
optimized production build behavior) so the public API is documented for cargo
doc generation and consumers can understand intended semantics of Mode, Debug,
and Release.
- Line 5: Remove the crate-level #[expect(dead_code, ...)] attribute and instead
add #[expect(dead_code, reason = "UI test fixture; function analysed but not
invoked")] (or #[allow(dead_code)] if preferred) directly to each unused fixture
item in this file (the specific unused functions/structs/enums that implement
the UI test cases), e.g. annotate each test fixture function/struct rather than
the whole crate so dead-code is scoped to those symbols only.

In `@crates/bumpy_road_function/ui/pass_single_match_cluster.rs`:
- Around line 15-17: Update the rustdoc example for the function categorise:
change the expected assertion from "medium" to "other" so the example matches
actual behaviour (replace the line assert_eq!(categorise(42), "medium"); with
assert_eq!(categorise(42), "other"); in the doc test for categorise).
- Line 5: Remove the crate-level suppression by deleting the top-level attribute
'#![expect(dead_code, reason = "UI test fixture; functions are analysed but not
invoked")]' and instead apply item-level attributes to only the unused test
fixture items in this file (e.g., prepend '#[expect(dead_code, reason = "UI test
fixture; function not invoked")]' to each unused function, struct, or static
used solely for the UI test fixture). Ensure you only annotate the specific
fixture symbols (the unused functions/structs/statics declared in
pass_single_match_cluster.rs) so other unintended dead_code warnings remain
active.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 94142d16-06aa-4759-9a4f-636959a5ec95

📥 Commits

Reviewing files that changed from the base of the PR and between 502edb6 and a9dfaa6.

📒 Files selected for processing (10)
  • .config/nextest.toml
  • crates/bumpy_road_function/src/analysis.rs
  • crates/bumpy_road_function/tests/features/bumpy_road.feature
  • crates/bumpy_road_function/ui/dylint.toml
  • crates/bumpy_road_function/ui/fail_match_with_nested_if.rs
  • crates/bumpy_road_function/ui/fail_match_with_nested_if.stderr
  • crates/bumpy_road_function/ui/fail_two_clusters_legacy.stderr
  • crates/bumpy_road_function/ui/pass_single_match_cluster.rs
  • docs/adr-002-dylint-expect-attribute-macro.md
  • docs/whitaker-dylint-suite-design.md

//!
//! This variant uses a match expression with two arms, each containing a nested
//! conditional block. The two conditional clusters form separated bumps.
#![expect(dead_code, reason = "UI test fixture; functions are analysed but not invoked")]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Replace blanket dead-code suppression with tightly scoped expectations.

Move #![expect(dead_code, ...)] from crate scope to the specific unused fixture items. Avoid hiding unrelated dead-code mistakes.

Patch
-#![expect(dead_code, reason = "UI test fixture; functions are analysed but not invoked")]
@@
+#[expect(dead_code, reason = "UI test fixture API analysed by lint tests")]
 pub fn key_from_file(mode: Mode, allow_fallback: bool) -> Result<Vec<u8>, String> {
@@
+#[expect(dead_code, reason = "UI test fixture marker")]
 fn dead_code_fixture_marker() {}

As per coding guidelines: “Lints must not be silenced except as a last resort … No lint groups, no blanket or file-wide suppression.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/bumpy_road_function/ui/fail_match_with_nested_if.rs` at line 5, Remove
the crate-level #[expect(dead_code, ...)] attribute and instead add
#[expect(dead_code, reason = "UI test fixture; function analysed but not
invoked")] (or #[allow(dead_code)] if preferred) directly to each unused fixture
item in this file (the specific unused functions/structs/enums that implement
the UI test cases), e.g. annotate each test fixture function/struct rather than
the whole crate so dead-code is scoped to those symbols only.

Comment on lines +9 to +13
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Mode {
Debug,
Release,
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Document the public Mode API.

Add rustdoc for the enum and its variants. Keep public API docs complete for generated documentation.

Patch
 #[derive(Clone, Copy, PartialEq, Eq)]
+/// Selects validation strictness for key loading.
 pub enum Mode {
+    /// Allow debug-friendly fallback behaviour.
     Debug,
+    /// Enforce strict release validation behaviour.
     Release,
 }

As per coding guidelines: “Document public APIs in Rust using Rustdoc comments (///) so documentation can be generated with cargo doc.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/bumpy_road_function/ui/fail_match_with_nested_if.rs` around lines 9 -
13, The public enum Mode (variants Debug and Release) lacks rustdoc comments;
add concise Rustdoc comments above the Mode enum and each variant using /// to
describe the purpose of the enum and what each variant represents (e.g., Debug:
run with debug assertions and extra checks; Release: optimized production build
behavior) so the public API is documented for cargo doc generation and consumers
can understand intended semantics of Mode, Debug, and Release.

//!
//! This example uses a match expression where all conditional complexity is
//! concentrated in a single arm, forming only one contiguous cluster.
#![expect(dead_code, reason = "UI test fixture; functions are analysed but not invoked")]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Scope the dead_code expectation to specific items.

Replace the crate-level suppression with item-level #[expect(dead_code, reason = "...")] on only the unused fixture items. Prevent unrelated dead-code regressions from being masked in this file.

Patch
-#![expect(dead_code, reason = "UI test fixture; functions are analysed but not invoked")]
@@
+#[expect(dead_code, reason = "UI test fixture entry point for lint analysis")]
 pub fn categorise(input: i32) -> &'static str {
@@
+#[expect(dead_code, reason = "UI test fixture marker")]
 fn dead_code_fixture_marker() {}

As per coding guidelines: “Lints must not be silenced except as a last resort … No lint groups, no blanket or file-wide suppression.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/bumpy_road_function/ui/pass_single_match_cluster.rs` at line 5, Remove
the crate-level suppression by deleting the top-level attribute
'#![expect(dead_code, reason = "UI test fixture; functions are analysed but not
invoked")]' and instead apply item-level attributes to only the unused test
fixture items in this file (e.g., prepend '#[expect(dead_code, reason = "UI test
fixture; function not invoked")]' to each unused function, struct, or static
used solely for the UI test fixture). Ensure you only annotate the specific
fixture symbols (the unused functions/structs/statics declared in
pass_single_match_cluster.rs) so other unintended dead_code warnings remain
active.

Comment on lines +15 to +17
/// ```ignore
/// assert_eq!(categorise(42), "medium");
/// ```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix the rustdoc example result.

Update the example expectation to match actual behaviour: categorise(42) returns "other", not "medium".

Patch
 /// ```ignore
-/// assert_eq!(categorise(42), "medium");
+/// assert_eq!(categorise(42), "other");
 /// ```
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// ```ignore
/// assert_eq!(categorise(42), "medium");
/// ```
///
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/bumpy_road_function/ui/pass_single_match_cluster.rs` around lines 15 -
17, Update the rustdoc example for the function categorise: change the expected
assertion from "medium" to "other" so the example matches actual behaviour
(replace the line assert_eq!(categorise(42), "medium"); with
assert_eq!(categorise(42), "other"); in the doc test for categorise).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bumpy_road_function does not flag nested conditionals in session_key_from_env

1 participant