-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
AnalysisIssues related to static analysis (vet, x/tools/go/analysis)Issues related to static analysis (vet, x/tools/go/analysis)NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolProposalIssues describing a requested change to a Go tool or command-line program.Issues describing a requested change to a Go tool or command-line program.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.
Milestone
Description
The -fix flag of each executable produced using the analysis framework (singlechecker/multichecker/unitchecker, including cmd/vet and cmd/fix) applies SuggestedFixes from Diagnostics. However, there is rarely a good reason to apply a fix to a generated file since the appropriate action in the case is either:
- (a) ignore the diagnostic because it is unimportant, such as a style issue; generated files are not held to the same standard as source files. Or
- (b) make a manual change to the generator tool to avoid emitting output that triggers the diagnostic. This is appropriate if the diagnostic indicates a real problem in the generated code.
I propose to change the behavior of -fix not to apply to generated files.
cc: @dominikh
(All fixers that will soon appear in cmd/fix currently implement the "generated?" check themselves, but they should not need to.)
See also:
- x/tools/go/analysis: a Diagnostic should indicate when it is a lint-style warning that should be ignored in generated code #41436
- cmd/go: fix: apply fixes from modernizers, inline, and other analyzers #71859
- x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment: ignore generated files #60509
- x/tools/gopls: support Format and CodeAction(source.organizeImports) on generated files #73959
- x/tools/gopls: don't run gofmt on generated files #49555
jakebailey
Metadata
Metadata
Assignees
Labels
AnalysisIssues related to static analysis (vet, x/tools/go/analysis)Issues related to static analysis (vet, x/tools/go/analysis)NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolProposalIssues describing a requested change to a Go tool or command-line program.Issues describing a requested change to a Go tool or command-line program.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.