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.