Back to all reviewers

Maintain focused module structure

astral-sh/ruff
Based on 4 comments
Rust

Keep modules focused and well-organized by grouping related functionality together and splitting large files into logical submodules. Each file should have a clear, single responsibility. When a file grows too large or handles multiple concerns, consider breaking it into smaller, more focused modules.

Code Style Rust

Reviewer Prompt

Keep modules focused and well-organized by grouping related functionality together and splitting large files into logical submodules. Each file should have a clear, single responsibility. When a file grows too large or handles multiple concerns, consider breaking it into smaller, more focused modules.

For example, instead of:

// types.rs (large file with mixed concerns)
pub(crate) trait VarianceInferable<'db>: Sized {
    // ... variance-related code
}

pub(crate) struct TypeVarInstance<'db> {
    // ... type variable code
}

Prefer:

// types/variance.rs
pub(crate) trait VarianceInferable<'db>: Sized {
    // ... variance-related code
}

// types/type_var.rs
pub(crate) struct TypeVarInstance<'db> {
    // ... type variable code
}

Key guidelines:

  • Keep files focused on a single responsibility or closely related set of functionality
  • Use submodules to organize related code (e.g., types/variance.rs, types/type_var.rs)
  • Consider splitting a file when it becomes difficult to navigate or understand as a whole
  • Group related functionality together in the same module
  • Use clear module names that reflect their contents
4
Comments Analyzed
Rust
Primary Language
Code Style
Category

Source Discussions