~samwhited/checkdoc

5844cf19bee4d7dc352884a5b66a4afa76e31aa1 — Sam Whited 2 months ago 237519b main
checkdoc: fix generated code detection and flag

Signed-off-by: Sam Whited <sam@samwhited.com>
1 files changed, 2 insertions(+), 2 deletions(-)

M header.go
M header.go => header.go +2 -2
@@ 58,7 58,7 @@ func fileHeader() *analysis.Analyzer {
				return nil, err
			}
		afterparse:
			genExp := regexp.MustCompile(`^Code generated .* DO NOT EDIT\.$`)
			genExp := regexp.MustCompile("^Code generated .* DO NOT EDIT\\.\n?$")

			for _, file := range pass.Files {
				switch {


@@ 73,7 73,7 @@ func fileHeader() *analysis.Analyzer {
				case pass.Fset.Position(file.Comments[0].List[0].Slash).Offset != 0:
					pass.Reportf(file.Comments[0].List[0].Slash, "no header comment found at start of file")
					continue
				case genExp.MatchString(file.Comments[0].Text()):
				case !includeGen && genExp.MatchString(file.Comments[0].Text()):
					// Skip generated files.
					// TODO: this can technically appear anywhere in the file.
					continue