Skip to content

Refactor main into parser, diff, and query modules#57

Merged
leynos merged 2 commits intomainfrom
codex/create-dedicated-modules-for-functions
Aug 7, 2025
Merged

Refactor main into parser, diff, and query modules#57
leynos merged 2 commits intomainfrom
codex/create-dedicated-modules-for-functions

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Aug 7, 2025

Summary

  • extract diff hunk formatting into diff module
  • move GraphQL query strings to graphql_queries
  • split reference parsing into ref_parser and update imports

Testing

  • make lint
  • make test
  • cargo check

https://chatgpt.com/codex/tasks/task_e_6893db4d09b883228dd3df1e195c6c06

Summary by Sourcery

Refactor main.rs into dedicated modules for diff formatting, GraphQL queries, and reference parsing to improve code organization.

Enhancements:

  • Extract diff hunk formatting and gutter logic into a new diff module
  • Move all GraphQL query constants into a new graphql_queries module
  • Extract pull request and issue reference parsing into a new ref_parser module
  • Remove inlined implementations and tests from main.rs and update imports to use the new modules

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Aug 7, 2025

Reviewer's Guide

The PR refactors the monolithic main.rs by splitting out diff hunk formatting, GraphQL query constants, and reference parsing into dedicated modules, updating imports across the codebase and relocating associated tests.

Class diagram for refactored reference parsing (ref_parser.rs)

classDiagram
    class RepoInfo {
        +String owner
        +String name
    }
    class ResourceType {
        <<enum>>
        Issues
        PullRequest
        +allowed_segments() &'static [&'static str]
    }
    class VkError
    class ref_parser {
        +parse_issue_reference(input: &str, default_repo: Option<&str>) Result<(RepoInfo, u64), VkError>
        +parse_pr_reference(input: &str, default_repo: Option<&str>) Result<(RepoInfo, u64), VkError>
        parse_reference(input: &str, default_repo: Option<&str>, resource_type: ResourceType) Result<(RepoInfo, u64), VkError>
        repo_from_fetch_head() Option<RepoInfo>
        repo_from_str(repo: &str) Option<RepoInfo>
    }
    ref_parser ..> RepoInfo
    ref_parser ..> ResourceType
    ref_parser ..> VkError
Loading

Class diagram for diff hunk formatting (diff.rs)

classDiagram
    class ReviewComment {
        +String body
        +String diff_hunk
        +Option<i32> original_position
        +Option<i32> position
        +String path
        +String url
        +Option<Author> author
    }
    class diff {
        +format_comment_diff(comment: &ReviewComment) Result<String, std::fmt::Error>
        GUTTER_WIDTH: usize
    }
    diff ..> ReviewComment
Loading

Class diagram for GraphQL query constants (graphql_queries.rs)

classDiagram
    class graphql_queries {
        +THREADS_QUERY: &str
        +COMMENT_QUERY: &str
        +ISSUE_QUERY: &str
    }
Loading

File-Level Changes

Change Details Files
Extract diff hunk formatting into a dedicated diff module
  • Added src/diff.rs containing format_comment_diff and its tests
  • Removed inline diff formatting logic from main.rs
  • Updated printer/mod.rs to call format_comment_diff from the diff module
src/diff.rs
src/main.rs
src/printer/mod.rs
Move GraphQL query strings into a graphql_queries module
  • Created src/graphql_queries.rs exporting THREADS_QUERY, COMMENT_QUERY, ISSUE_QUERY
  • Removed GraphQL constants from main.rs
  • Updated fetch routines in main.rs to import queries from graphql_queries
src/graphql_queries.rs
src/main.rs
Split reference parsing into a ref_parser module
  • Introduced src/ref_parser.rs with RepoInfo, parse_pr_reference, parse_issue_reference, repo lookup functions, and tests
  • Stripped reference parsing code and related structs/enums from main.rs
  • Updated main.rs to import parsing functions from ref_parser
src/ref_parser.rs
src/main.rs
Clean up main.rs imports and relocate tests
  • Removed unused imports (fs, path, url, Regex constants) from main.rs
  • Relocated parsing tests from main.rs to ref_parser.rs and diff tests to diff.rs
  • Eliminated redundant test code and streamlined main.rs
src/main.rs
src/ref_parser.rs
src/diff.rs

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 7, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Warning

Rate limit exceeded

@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 1 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f5b476f and b6fa102.

📒 Files selected for processing (3)
  • src/diff.rs (1 hunks)
  • src/main.rs (5 hunks)
  • src/ref_parser.rs (1 hunks)

Summary by CodeRabbit

  • New Features

    • Added support for parsing and formatting diff hunks in review comments, improving the clarity of code review displays.
    • Introduced robust parsing for GitHub issue and pull request references from various formats, including URLs and numeric IDs.
  • Refactor

    • Moved reference parsing and GraphQL query definitions to dedicated modules for improved maintainability.
    • Updated internal imports to use new module paths.
  • Chores

    • Enhanced test coverage for diff formatting and reference parsing functionalities.

Walkthrough

Split the parsing and formatting logic for GitHub references and diff hunks into dedicated modules. Move GraphQL query strings to a new module. Update imports and module declarations to reflect this modularisation. Refactor code to delegate reference parsing and diff formatting to the new modules, removing redundant logic from the main file.

Changes

Cohort / File(s) Change Summary
Diff Formatting Module
src/diff.rs
Introduce a module for parsing and formatting diff hunks from review comments. Define constants, a regex for hunk headers, and the format_comment_diff function. Add comprehensive tests for parsing and formatting logic.
GraphQL Queries Module
src/graphql_queries.rs
Add a module containing public constant strings for GraphQL queries: THREADS_QUERY, COMMENT_QUERY, and ISSUE_QUERY. These queries fetch review threads, comments, and issue details from GitHub.
Reference Parser Module
src/ref_parser.rs
Add a module to parse GitHub issue and pull request references into structured RepoInfo data. Implement robust parsing from URLs, numeric references, and local git state. Provide public functions for both issue and PR references. Include unit tests for various scenarios.
Main Refactor
src/main.rs
Remove all reference parsing, diff formatting, and GraphQL query string logic from the main file. Import and delegate these functionalities to the new diff, graphql_queries, and ref_parser modules. Update module declarations and imports accordingly. Remove redundant code and update control flow to use the refactored interfaces.
Printer Update
src/printer/mod.rs
Update import of format_comment_diff to use the new diff module. Change function call to use the direct import. No other logic changes.
Reviews Import Update
src/reviews.rs
Change import of RepoInfo to reference the new ref_parser module. No other logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant Main
    participant RefParser
    participant Diff
    participant GraphQLQueries

    Main->>RefParser: parse_issue_reference / parse_pr_reference(input, default_repo)
    RefParser-->>Main: (RepoInfo, number) or error

    Main->>GraphQLQueries: Use THREADS_QUERY / COMMENT_QUERY / ISSUE_QUERY

    Main->>Diff: format_comment_diff(comment)
    Diff-->>Main: formatted diff string
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related PRs

Poem

Split the code and let it fly,
Each module now knows its why.
Diff and reference, parsed with pride,
GraphQL queries by your side.
Imports tidy, logic neat—
Refactor’s song is now complete!
🦀✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/create-dedicated-modules-for-functions

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@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 @leynos - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/ref_parser.rs:38` </location>
<code_context>
-    clippy::result_large_err,
-    reason = "VkError has many variants but they are small"
-)]
-fn parse_reference(
-    input: &str,
-    default_repo: Option<&str>,
</code_context>

<issue_to_address>
Consider refactoring parse_reference by extracting URL and repo parsing into helper functions to flatten control flow and centralize repeated logic.

Here’s one way to peel off the nested logic in `parse_reference` into focused helpers—this preserves all existing behavior but drastically flattens the main function and centralizes your “.git”‐suffix stripping and regex usage:

```rust
fn strip_git_suffix(name: &str) -> &str {
    name.strip_suffix(".git").unwrap_or(name)
}

fn parse_github_url(
    input: &str,
    resource: ResourceType,
) -> Option<Result<(RepoInfo, u64), VkError>> {
    // Try URL parsing
    let url = Url::parse(input).ok()?;
    if url.host_str()? != "github.com" {
        return None;
    }
    let parts: Vec<_> = url.path_segments()?.collect();
    if parts.len() < 4 {
        return Some(Err(VkError::InvalidRef));
    }

    let owner = parts[0];
    let repo  = strip_git_suffix(parts[1]);
    let seg2  = parts[2];

    if !resource.allowed_segments().contains(&seg2) {
        return Some(Err(VkError::WrongResourceType {
            expected: resource.allowed_segments(),
            found: seg2.to_owned(),
        }));
    }
    let number = parts[3].parse().map_err(|_| VkError::InvalidRef)?;
    Some(Ok((RepoInfo {
        owner: owner.into(),
        name:  repo.into(),
    }, number)))
}

fn parse_repo_str(repo: &str) -> Option<RepoInfo> {
    if let Some(caps) = GITHUB_RE.captures(repo) {
        let owner = caps.name("owner")?.as_str().to_owned();
        let name  = strip_git_suffix(caps.name("repo")?.as_str()).to_owned();
        return Some(RepoInfo { owner, name });
    }
    // fallback to plain "foo/bar"
    let mut parts = repo.splitn(2, '/');
    let (o, n) = (parts.next()?, parts.next()?);
    Some(RepoInfo {
        owner: o.into(),
        name:  strip_git_suffix(n).into(),
    })
}

fn repo_from_fetch_head() -> Option<RepoInfo> {
    let content = fs::read_to_string(".git/FETCH_HEAD").ok()?;
    content
        .lines()
        .filter_map(|l| parse_repo_str(l))
        .next()
}
```

Then your `parse_reference` collapses to:

```rust
fn parse_reference(
    input: &str,
    default_repo: Option<&str>,
    resource: ResourceType,
) -> Result<(RepoInfo, u64), VkError> {
    // 1) URL case
    if let Some(res) = parse_github_url(input, resource) {
        return res;
    }

    // 2) Number + default‐repo case
    if let Ok(num) = input.parse::<u64>() {
        let repo = default_repo
            .and_then(parse_repo_str)
            .or_else(repo_from_fetch_head)
            .ok_or(VkError::RepoNotFound)?;
        return Ok((repo, num));
    }

    // 3) Anything else
    Err(VkError::InvalidRef)
}
```

This
- removes inline “.git” stripping everywhere  
- collapses both regex paths into a single `parse_repo_str`  
- flattens the big `if … else if … else` tree into three very simple steps.
</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.

Comment thread src/ref_parser.rs
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Aug 7, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 7, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 6

🔭 Outside diff range comments (1)
src/main.rs (1)

1-757: File exceeds 400 line limit.

At 757 lines, this file violates the 400-line maximum. Further decompose the module by extracting:

  • Thread and review fetching logic (lines 186-279)
  • Summary generation and printing (lines 288-322)
  • Configuration loading logic (lines 419-438)
  • Test utilities and fixtures (lines 478-486, 568-574)
♻️ Duplicate comments (1)
src/ref_parser.rs (1)

38-80: Refactor parse_reference to reduce cyclomatic complexity.

The function has high cyclomatic complexity with deeply nested control flow. Extract URL parsing, repo parsing, and validation logic into focused helper functions as suggested in the previous review.

The previous review comment provides an excellent refactoring approach that would:

  • Reduce cyclomatic complexity from ~8 to ~3
  • Centralise .git suffix stripping logic
  • Improve readability and maintainability
  • Separate URL parsing from number parsing concerns

Implement the suggested helper functions: strip_git_suffix, parse_github_url, parse_repo_str, and repo_from_fetch_head.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 15d0375 and f5b476f.

📒 Files selected for processing (6)
  • src/diff.rs (1 hunks)
  • src/graphql_queries.rs (1 hunks)
  • src/main.rs (3 hunks)
  • src/printer/mod.rs (2 hunks)
  • src/ref_parser.rs (1 hunks)
  • src/reviews.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • src/reviews.rs
  • src/printer/mod.rs
  • src/diff.rs
  • src/main.rs
  • src/graphql_queries.rs
  • src/ref_parser.rs
🔇 Additional comments (7)
src/reviews.rs (1)

10-10: Import path correctly updated for the refactored module structure.

The change properly reflects the new location of RepoInfo in the ref_parser module.

src/printer/mod.rs (1)

8-8: Import and usage correctly updated for the refactored diff module.

The explicit import and direct function call improve code clarity.

Also applies to: 79-79

src/graphql_queries.rs (1)

1-61: Well-structured module for GraphQL queries.

The module properly encapsulates all GraphQL query strings with clear naming and appropriate visibility. The module doc comment clearly describes its purpose.

src/diff.rs (1)

88-95: Unused parsed values are correctly prefixed.

The _old_count and _new_count variables are parsed but unused. The underscore prefix correctly indicates this is intentional.

src/main.rs (1)

10-14: Module imports correctly reflect the refactored structure.

The new module declarations and imports properly integrate the extracted functionality.

Also applies to: 18-20

src/ref_parser.rs (2)

1-1: LGTM: Module documentation follows guidelines.

The module doc comment properly explains the module's purpose using the required //! format and follows en-GB spelling conventions.


139-249: LGTM: Comprehensive test coverage.

The test suite covers all major parsing scenarios including URL parsing, git suffix handling, plural segments, and error cases. Tests follow good practices with descriptive names and clear assertions.

Comment thread src/diff.rs Outdated
Comment thread src/main.rs Outdated
Comment thread src/ref_parser.rs Outdated
Comment thread src/ref_parser.rs Outdated
Comment thread src/ref_parser.rs Outdated
Comment thread src/ref_parser.rs Outdated
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Aug 7, 2025

@coderabbitai please create a new GitHub issue for the following:

VkError variants are semantically small; FIXME: consider boxing large variants

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 7, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

I'll help you create a GitHub issue for the VkError optimization. Let me first search for the VkError definition and the specific FIXME comment to provide proper context.


🏁 Script executed:

#!/bin/bash
# Search for VkError enum definition
ast-grep --pattern 'enum VkError {
  $$$
}'

# Also search for the FIXME comment specifically
rg -n "VkError variants are semantically small.*consider boxing large variants"

# Search for any FIXME comments related to VkError
rg -n "FIXME.*VkError"

# Find VkError usage to understand the context
rg -A 5 -B 2 "enum VkError"

Length of output: 524


Let me get the full VkError enum definition to understand all the variants:


🏁 Script executed:

#!/bin/bash
# Get the complete VkError enum definition
ast-grep --pattern 'enum VkError {
  $$$
}' -A 20

# Also check if there's a clippy warning or comment about this
rg -B 2 -A 10 "enum VkError"

# Look for any clippy allow or warnings related to large_enum_variant
rg -n "large_enum_variant"

Length of output: 614


Let me get the complete enum definition and look for any clippy warnings:


🏁 Script executed:

#!/bin/bash
# Get more context around the VkError enum to see all variants
rg -A 30 "pub enum VkError" src/main.rs

# Search for any clippy warnings in the entire codebase
rg -n "clippy" 

# Check if there are any compiler warnings in Cargo.toml or other config files
fd "Cargo.toml" --exec cat {}

# Look for any TODO or FIXME comments that might be related
rg -n "FIXME\|TODO" src/main.rs

Length of output: 4730


Now I understand! I can see there are multiple clippy::result_large_err allow attributes throughout the codebase, which is the clippy lint that warns about large enum variants in Result types. Let me create the GitHub issue for this optimization:


🏁 Script executed:

#!/bin/bash
# Create a GitHub issue for the VkError optimization
gh issue create \
  --title "Optimize VkError enum: Box large variants to reduce memory usage" \
  --body "## Description

The \`VkError\` enum currently has several large variants that trigger clippy's \`result_large_err\` lint warnings. This requires multiple \`#[allow(clippy::result_large_err)]\` annotations throughout the codebase (found in \`src/ref_parser.rs\` lines 35, 83, 94 and \`src/main.rs\` lines 330, 347, 390, 420, 442).

## Problem

Large enum variants can lead to:
- Increased memory usage for all \`Result<T, VkError>\` instances
- Poor cache performance due to larger stack allocations
- Unnecessary memory copying when passing \`Result\` values

## Current VkError variants

The enum includes several potentially large variants:
- \`RequestContext { context: String, source: reqwest::Error }\`
- \`WrongResourceType { expected: &'static [&'static str], found: String }\`
- \`BadResponse(String)\`
- \`BadResponseSerde(String)\`
- \`ApiErrors(String)\`
- \`Request(reqwest::Error)\`
- \`Io(std::io::Error)\`
- \`Config(ortho_config::OrthoError)\`

## Proposed Solution

Box the larger variants to reduce the enum's overall size:
- Box variants containing \`String\` fields
- Box variants containing large external error types (\`reqwest::Error\`, \`std::io::Error\`, \`ortho_config::OrthoError\`)

This would allow removing the \`#[allow(clippy::result_large_err)]\` annotations while improving memory efficiency.

## References

- Pull Request: https://github.com/leynos/vk/pull/57
- Clippy documentation: https://rust-lang.github.io/rust-clippy/master/index.html#/result_large_err

Requested by: @leynos" \
  --assignee leynos

Length of output: 1650


@leynos: I've successfully created GitHub issue #58 for optimizing the VkError enum by boxing large variants. The issue includes:

  • Context: The current VkError enum has large variants causing clippy result_large_err warnings, requiring multiple #[allow] annotations across 8 locations in the codebase
  • Problem analysis: Large enum variants increase memory usage and affect performance for all Result<T, VkError> instances
  • Detailed variant list: All current VkError variants with identification of the larger ones containing String fields and external error types
  • Proposed solution: Box the larger variants to reduce overall enum size and eliminate the need for clippy suppressions
  • References: Links to this PR and clippy documentation

The issue has been assigned to you and is available at: #58

@leynos leynos merged commit 2b56fad into main Aug 7, 2025
2 checks passed
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.

1 participant