Back to all reviewers

Scope dependencies appropriately

zed-industries/zed
Based on 5 comments
Toml

Configure dependencies with their minimum necessary scope to maintain clean architecture and improve build times. Key practices: 1. **Test-only dependencies should be dev-dependencies**

Configurations Toml

Reviewer Prompt

Configure dependencies with their minimum necessary scope to maintain clean architecture and improve build times. Key practices:

  1. Test-only dependencies should be dev-dependencies If a dependency is only used for tests, add it as a dev-dependency and use #[cfg(test)] annotations:
    // Instead of adding to main Cargo.toml
    // unicode-width = "0.2"
       
    // Add to [dev-dependencies] section instead
    // And restrict usage to test code:
    #[cfg(test)]
    use unicode_width::UnicodeWidthStr;
    
  2. Keep core modules lightweight Don’t add heavy dependencies to utility or core modules. Move dependent code to appropriate modules:
    // Instead of this in util/Cargo.toml:
    // schemars.workspace = true
       
    // Create plain enums in util:
    pub enum SortStrategy {
        Lexicographical,
        Alphabetical,
    }
       
    // Then convert in settings module where JsonSchema is available
    
  3. Scope feature flags correctly Define features at the appropriate module level rather than globally. For workspace-wide features, manage them centrally:
    # In workspace Cargo.toml:
    tokio = { version = "1.0", features = ["rt", "rt-multi-thread"] }
       
    # In module Cargo.toml:
    tokio.workspace = true
    
  4. Extract global configuration changes When changing dependency configurations that affect multiple modules, consider making it a separate PR to properly evaluate the impact.
5
Comments Analyzed
Toml
Primary Language
Configurations
Category

Source Discussions