Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangesToPlan ¶
func ChangesToPlan(changes []wstypes.Change) *wstypes.RefactoringPlan
ChangesToPlan creates a RefactoringPlan from a set of changes.
func DiagnosticsToChanges ¶
DiagnosticsToChanges converts diagnostics with SuggestedFixes into types.Change slices. It picks the first SuggestedFix from each diagnostic (if any).
func FillOldText ¶
FillOldText populates each change's OldText from the workspace's copy of the file it applies to.
This serves two purposes. A dry run renders OldText as the "before" side of its diff, so without it the caller reviews a preview that only shows what the code would become. And on apply, Serializer.applyChange verifies OldText against the bytes actually at those offsets, turning a stale-offset bug into a clean error instead of a corrupted file.
Changes whose file or offsets are not found in the workspace are left as-is.
Types ¶
type RunResult ¶
type RunResult struct {
Result any
Diagnostics []analysis.Diagnostic
}
RunResult holds the output of running an analyzer across one or more packages.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package boolsimplify walks the `!` operators already written in source and removes the ones srctext.PushNeg can push inward with De Morgan's laws, where doing so strictly reduces the number of `!` operators.
|
Package boolsimplify walks the `!` operators already written in source and removes the ones srctext.PushNeg can push inward with De Morgan's laws, where doing so strictly reduces the number of `!` operators. |
|
Package deepifelse detects nested if-else chains that should be flattened into guard clauses, and rewrites the ones it can.
|
Package deepifelse detects nested if-else chains that should be flattened into guard clauses, and rewrites the ones it can. |
|
Package earlyreturn detects conditionals that keep the happy path indented and rewrites them as guard clauses, so the main flow sits at the left margin.
|
Package earlyreturn detects conditionals that keep the happy path indented and rewrites them as guard clauses, so the main flow sits at the left margin. |
|
Package errorwrap provides a go/analysis analyzer that detects improper error wrapping patterns: bare error returns, fmt.Errorf with %v instead of %w, and fmt.Errorf calls with no descriptive context message.
|
Package errorwrap provides a go/analysis analyzer that detects improper error wrapping patterns: bare error returns, fmt.Errorf with %v instead of %w, and fmt.Errorf calls with no descriptive context message. |
|
Package filedata provides a pass-through analyzer that makes raw file content available to downstream analyzers via pass.ResultOf.
|
Package filedata provides a pass-through analyzer that makes raw file content available to downstream analyzers via pass.ResultOf. |
|
Package srctext provides helpers for lifting verbatim source text out of an AST node, and for the small syntactic rewrites (condition inversion) that the flattening analyzers share.
|
Package srctext provides helpers for lifting verbatim source text out of an AST node, and for the small syntactic rewrites (condition inversion) that the flattening analyzers share. |
|
Package stmtfacts answers the two questions every flattening analyzer has to ask before it may drop an `else`: does this branch hand control away for good, and would dedenting that block redeclare a name the enclosing scope already uses.
|
Package stmtfacts answers the two questions every flattening analyzer has to ask before it may drop an `else`: does this branch hand control away for good, and would dedenting that block redeclare a name the enclosing scope already uses. |
|
Package switchchain detects if/else-if/else chains that should be switch statements, and rewrites the ones it can.
|
Package switchchain detects if/else-if/else chains that should be switch statements, and rewrites the ones it can. |