google / addlicense

A program which ensures source code files have copyright license headers by scanning directory patterns recursively
Apache License 2.0
716 stars 169 forks source link

Bug: Files generated by stringer are skipped #95

Closed karlkfi closed 3 years ago

karlkfi commented 3 years ago

I've found that in recent versions of addlicense, any file generated by stringer is skipped or has its license comment striped, if present.

The files generated by strinnger have the following file header comments:

// Code generated by "stringer -type=EVENT"; DO NOT EDIT.

The "EVENT" value changes between files but the rest of the comment is standard. I suspect something in that comment is causing the file to be skipped by addlicense.

Unfortunately, it doesn't just skip those files, it actively strips the addlicense comment if you add it manually.

karlkfi commented 3 years ago

Stringer, for reference: https://pkg.go.dev/golang.org/x/tools/cmd/stringer

karlkfi commented 3 years ago

Looks like this might be intentional:

willnorris commented 3 years ago

Skipping over generated files is certainly intentional. I'm not sure how it would actively strip an existing addlicense comment, but if it is, then that's certainly a bug I'd like to be able to reproduce.

karlkfi commented 3 years ago

I suspect the stripping might have been from my makefile re-generating the files on top of files that previously had the header. So that's not actually addlicense behavior, sorry.

I'll close, since the behavior is intentional.