Skip to content

refactor(clippy): collapse nested if blocks in detect.rs#628

Merged
jamesadevine merged 1 commit into
mainfrom
clippy-fixer/collapsible-if-detect-rs-a09332b0727550ae
May 19, 2026
Merged

refactor(clippy): collapse nested if blocks in detect.rs#628
jamesadevine merged 1 commit into
mainfrom
clippy-fixer/collapsible-if-detect-rs-a09332b0727550ae

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

What clippy found

Three consecutive collapsible_if errors in src/detect.rs (lines 64–73):

error: this `if` statement can be collapsed
  --> src/detect.rs:64:20
  --> src/detect.rs:65:17
  --> src/detect.rs:66:21

Four nested if blocks were checking is_file(), then the extension, then the extension value, then the pipeline detection result.

How it was fixed

Lint: clippy::collapsible_if
Fix: Collapsed all three nested ifs into a single if let chain using Rust 2024 edition's stabilised if let chains
File touched: src/detect.rs

// Before
} else if file_type.is_file() {
    if let Some(ext) = path.extension().and_then(|e| e.to_str()) {
        if ext == "yml" || ext == "yaml" {
            if let Some(pipeline) = try_detect_pipeline(&path, root).await? {
                debug!("Detected agentic pipeline: {}", path.display());
                results.push(pipeline);
            }
        }
    }
}

// After
} else if file_type.is_file()
    && let Some(ext) = path.extension().and_then(|e| e.to_str())
    && (ext == "yml" || ext == "yaml")
    && let Some(pipeline) = try_detect_pipeline(&path, root).await?
{
    debug!("Detected agentic pipeline: {}", path.display());
    results.push(pipeline);
}

Verification

  • cargo build --all-targets
  • cargo test ✅ (all tests pass)
  • cargo clippy --all-targets --all-features --workspace -- -D warnings ✅ (no warnings for detect.rs)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • dev.azure.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "dev.azure.com"

See Network Configuration for more information.

Generated by Clippy Fixer · ● 6.8M ·

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request May 18, 2026
@jamesadevine jamesadevine marked this pull request as ready for review May 19, 2026 21:19
@jamesadevine jamesadevine merged commit f82b1b3 into main May 19, 2026
@jamesadevine jamesadevine deleted the clippy-fixer/collapsible-if-detect-rs-a09332b0727550ae branch May 19, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant