Deprecated Api
ID |
go.deprecated_api |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Code Smell |
Language |
Go |
Tags |
code-style, maintainability |
Description
Reports a call to a project-local function whose doc comment marks it as deprecated with the Go
convention // Deprecated:. Calling a deprecated function keeps obsolete code alive instead of
moving to the replacement named in the notice.
Rationale
go doc and the Go tooling treat a doc-comment paragraph beginning with Deprecated: as a
deprecation notice. The check is conservative: it flags only a call that resolves to a same-project
function whose own doc comment carries that marker. A call into another package, or one that cannot
be resolved, is never flagged because its documentation is not visible at this point.
// Deprecated: use newHash instead.
func oldHash(s string) int { ... }
_ = oldHash("a") // FLAW — calls a deprecated function
_ = newHash("b") // OK — not deprecated
Remediation
Replace the call with the non-deprecated alternative named in the Deprecated: notice. If no
caller remains, remove the deprecated function.