mit einem Klick
extract-helpers
// Review that local variables with unnecessarily wide scope are extracted into helper functions.
// Review that local variables with unnecessarily wide scope are extracted into helper functions.
Write or review Kueue PR release notes. Use when a user asks to draft, refine, validate, or combine release notes for a Kueue pull request, especially when deciding whether the note should be framed as a bugfix, feature, observability improvement, or breaking change.
Review that algorithm comments match the implementation. Use when a comment describes a formula or algorithm and you want to verify it matches what the code actually does.
Review that new CRD fields have complete godoc comments with enum value descriptions.
Review that paired operations and fields that always appear together are encapsulated in a helper or nested struct.
Review that new feature-gated behavior has explicit gate checks on all reachable code paths.
Review that update/mutation logic has integration test coverage in test/integration/.
| name | extract-helpers |
| description | Review that local variables with unnecessarily wide scope are extracted into helper functions. |
| license | Apache-2.0 |
| metadata | {"copyright":"The Kubernetes Authors"} |
Flag: A local variable whose scope spans more of a function than it needs to — it's only used inside a self-contained block of logic.
Ask: Extract that block into a helper function. This limits the variable's lifetime to the helper, shortens the enclosing function, and makes the intent clearer.
func Greeting(user User) string {
name := strings.TrimSpace(user.FirstName)
if name == "" {
name = "friend"
}
name = strings.Title(name)
return fmt.Sprintf("Hello, %s! You have %d new messages.", name, user.Unread)
}
name is built up over three lines, then used once. Its scope spans the whole function for no reason. Real code tends to have more extreme versions of this.
vs.
func displayName(user User) string {
name := strings.TrimSpace(user.FirstName)
if name == "" {
return "friend"
}
return strings.Title(name)
}
func Greeting(user User) string {
return fmt.Sprintf("Hello, %s! You have %d new messages.", displayName(user), user.Unread)
}
name now lives only inside displayName, and Greeting is a single expressive line.