Description
Overview
Files generated by code-generator
currently have a lot of issues picked up by golint
. There are a few options to fix this:
- Fix the actual lint issues in the generated code
- This would require fixing the existing generated code and putting a process in place for the future to prevent lint issues in generated code from being merged
- Ignore the generated files in some other way
- This requires all users to implement their own solution to this problem
- Follow the golang convention for machine-generated files so
golint
automatically skips them- I think this is the most appropriate solution because the golang community has standardized on it, it's trivial to implement, and it avoids adding more process
Proposed Solution
I propose that we add the following comment line just below the boilerplate header:
// Code generated by <generator-name>. DO NOT EDIT.
There are already lines similar to this generated but they do not match the desired regex, so we can just modify them. For example: https://github.com/kubernetes/kubernetes/search?utf8=✓&q=%22Do+not+edit+it+manually%22&type=Code.
After some quick poking around, this will require modifying not only code-generator
but also kubernetes/gengo for example.
I've tested manually editing an auto-generated file to add this line and it does result in golint
ignoring the file as expected.
I'm not very familiar with the process for auto-generated code in Kubernetes itself - would we want to re-generate all of the generated code as part of the PR for this issue?
I'm happy to take this on this weekend if we feel that it's a good solution.