These days, "gofmt" prints the filename, line and error why it failed. We have to strip everything except the filename.
Other improvements:
- Deduplicate file names in case one file has multiple errors.
- Print one file name per line which makes it easier to see which files were affected.
Please refer to #2694 and #2670 for motivation and reasoning for
this change.
I've tried to follow best practice in inserting the copyright
headers. In other open source projects, not all files carry
the notice. For example documentation doesn't. I've followed
similar ground rules.
I did not change the php because there is a separate LICENSE
file there by Pixel Federation. We'll first need to notify
them our intent before changing anything there.
As for the presubmit check, it's going to be non-trivial
because of the number of exceptions, like file types,
directories and generated code. So, it will have to be
a separate project.
1. pre-commit-msg hook:
If a branch starts with "<bug number>" or "b<bug number>", the bug marker BUG=<bug number> will be automatically added to the commit message.
2. commit-msg hook:
If no bug number is found in the branch, "git commit" will prompt the user for one after they entered the commit message.
This hook applies only to internal developers (i.e. people with a @google.com email address).
Both scripts return early if any commit in the feature branch already has a "BUG=<bug number>" or "b/<bug number>" marker.
Ironically, this commit does not contain a bug marker yet :)
Renaming error variables to warnings, fixing white spaces.
Also removing extra code that had been merged by mistake
in memorytopo.go in commit 657f565144
It is from this repository: https://github.com/dominikh/go-unused
As part of this change:
- adding download of the tool to bootstrap.sh.
- re-enabling a few tests that were disabled.
- removing a bunch of unused code.
I have an alias to the pre-commit script which I sometimes run manually
e.g. to go over all lint errors.
Before this fix, pre-commit could only be run from $VTTOP.
Ignore some google-specific warnings that don't apply.
When displaying errors, print path name on each error line instead of as
a header.
Clean up a couple of python files modified while testing.
Some precommits (go vet, golint) require a working Go environment
because they not only look at the file under inspection itself, but they
also try to load the imported packages.
Unfortunately, they don't fail if they cannot load the imports. Instead,
you see subsequent errors due to the missing imports.
For example:
Go vet error: "composite literal uses unkeyed fields"
This occurs when we use a struct initializer
without keyed fields where the struct is defined in another Go package.
In that case, the tools cannot find out how many/which fields the struct
has and if it's actually okay to use unkeyed fields because we specify
all fields.
If selected, the user will step through each file with warnings. Between
files, the user has to press enter to make sure that we don't flood the
whole screen and it's easy to fix one file after the other.
Golint should never be required, as per the docs:
"""
The suggestions made by golint are exactly that: suggestions.
Golint is not perfect, and has both false positives and false negatives.
Do not treat its output as a gold standard. We will not be adding
pragmas or other knobs to suppress specific warnings, so do not expect or
require code to be completely "lint-free".
"""
This hook only shows the line count of the golint output for each file
modified in a commit. That way you don't get flooded just because you
changed one line in a file with a hundred pre-existing lint issues.
However, if we just print the warnings without stopping, you'll probably
never see them because your editor comes up to let you write a commit
message. So we try to steal back the keyboard and pause to let you know
you might want to look into the lint warnings. If the stealing ends up
being buggy, we'll have to think of something else.