Skip to content

Restore mutex Lock/Unlock cuddling support in v5 #218

@susuper

Description

@susuper

Problem

In wsl v4, allow-cuddle-with-calls defaulted to ["Lock", "RLock"] and allow-cuddle-with-rhs defaulted to ["Unlock", "RUnlock"]. This allowed idiomatic Go mutex patterns without requiring blank lines:

s.mu.Lock()
for _, item := range items {
    // critical section
}
s.mu.Unlock()

In v5, this was removed. Now the above code triggers:
missing whitespace above this line (invalid statement above range)
missing whitespace above this line (invalid statement above expr)

Why This Matters

Mutex Lock/Unlock and the protected code form a logical unit. Adding blank lines separates things that belong together and can actually harm readability. This is a universal Go pattern used extensively in the standard library and major projects.

Proposal

Add a configuration option to restore mutex-aware cuddling in v5, for example:

 wsl_v5:
  allow-mutex-cuddle: true  # default: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions