Repository navigation
Skip generated files - #29
Merged
Merged
Conversation
Every analyzer reports on code that a person must fix. Code that a generator writes has no person to fix it, so the analyzers need one shared answer to "is this file generated?". The helper follows the Go convention: the marker comment before the package clause. An author therefore controls skipping with the comment alone, and no flag or allow list is necessary.
A generator writes functions with branches that a person cannot simplify, so the complexity limit reports files that no one may edit.
The methodical fixer already declined to edit generated files. The new helper gives that rule one name, so the analyzer reads the convention the same way everywhere.
A generator writes compound conditionals, and the analyzer asks for a predicate function that no person may add to a generated file.
A generated file can repeat a directive that its body violates, and a person cannot remove the mutation or the directive there.
A generator writes test helpers that call the testing failure methods, and a person cannot replace those calls in a generated file.
A generated file holds methods that are not next to their type and not sorted, and a person cannot move them. A type that a generator writes also leaves its handwritten methods alone, because those methods can never move next to the type.
A reader must know that a clean run says nothing about generated files, and must know how to exclude a file from analysis when a person does own it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A diagnostic in a generated file is not meaningful because the next run of the generator overwrites the file. Constable now skips files that carry the conventional Go generated-code comment,
// Code generated <tool> DO NOT EDIT..