Back to all reviewers

Maintain consistent style

oven-sh/bun
Based on 12 comments
Other

Maintain consistent style patterns throughout the codebase to improve readability, reduce maintenance overhead, and prevent errors. Key areas to focus on:

Code Style Other

Reviewer Prompt

Maintain consistent style patterns throughout the codebase to improve readability, reduce maintenance overhead, and prevent errors. Key areas to focus on:

  1. Use consistent struct declarations: For top-level structs, prefer:
    const Installer = @This();
    

    instead of:

    pub const Installer = struct {
    
  2. Eliminate redundancies: Remove duplicate declarations such as repeated flags, option definitions, or multiple type declarations.
    // Bad - duplicates in options list
    GLOBAL_OPTIONS[LONG_OPTIONS]="--extension-order --jsx-factory --jsx-fragment --extension-order --jsx-factory --jsx-fragment"
       
    // Good - no duplicates
    GLOBAL_OPTIONS[LONG_OPTIONS]="--extension-order --jsx-factory --jsx-fragment"
    
  3. Maintain consistent formatting: Ensure proper spacing, consistent namespace qualifiers, and appropriate control structures.
    // Bad - inconsistent namespace qualification
    if (comptime Environment.debug_checks) {
       
    // Good - consistent qualification
    if (comptime bun.Environment.debug_checks) {
    
  4. Use appropriate control structures: Choose the most readable structure for the logic being expressed.
    // Consider switch statements for multiple conditions
    fn isValidRedirectStatus(status: u16) bool {
        return switch (status) {
            301, 302, 303, 307, 308 => true,
            else => false,
        };
    }
    

Consistent style makes code easier to read, review, and maintain for the entire team.

12
Comments Analyzed
Other
Primary Language
Code Style
Category

Source Discussions