Skip to content

x/tools/go/analysis: don't apply SuggestedFixes to generated files #75948

@adonovan

Description

@adonovan

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:

Metadata

Metadata

Assignees

Labels

AnalysisIssues related to static analysis (vet, x/tools/go/analysis)NeedsFixThe 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.ToolsThis label describes issues relating to any tools in the x/tools repository.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions