Commit Graph

16 Commits (b71fbb3df9af8e0b9c624483023aed41536aa909)

Author SHA1 Message Date
nikhiljindal 0799c11cb5 printf->print 2015-09-24 13:10:25 -07:00
Maciej Szulik 7edb1afad6 Fixed typo in verify-flags-underscore 2015-08-26 13:29:10 +02:00
Eric Paris 03f4e52812 Make verify-flags-underscore.py return error on failure
We were running it in shippable and travis, but since it didn't return
an error it wasn't actually catching things.
2015-08-24 22:12:17 -05:00
Nikhil Jindal 9eb0970bdb Merge pull request #13091 from mesosphere/python-set-sort
Fix sort on sets in hack/verify-flags-underscore.py
2015-08-24 14:07:12 -07:00
Dr. Stefan Schimanski 211fe33f40 Fix undefined variable f in 'finally' clause of verify-flags-underscore.py 2015-08-24 16:36:52 +02:00
Dr. Stefan Schimanski ce013e288c Fix sort on sets in hack/verify-flags-underscore.py 2015-08-24 15:06:33 +02:00
Eric Paris ca310ffdac Sort output from hack/verify-flag-underscore.py
So we get some consistency and readability to the exceptions.txt
2015-08-17 11:32:18 -07:00
Eric Paris 99dc464c9b verify-flags-underscore.py: update how to add to exclusion list 2015-08-17 11:19:32 -07:00
Eric Paris b432f036db verify-flags-underscore.py: ignore juju variables 2015-08-17 11:19:32 -07:00
Eric Paris f3fd2e1028 verify-flags-underscore.py: ignore if trailed by :
These are often yaml definitions, and thus not usages of kubernetes
flags.  Not necessarily always, but usually.
2015-08-17 11:19:32 -07:00
Eric Paris d1ba0bb692 verify-flags-underscore.py: ignore salt grains 2015-08-17 11:19:31 -07:00
Eric Paris d7f9477a94 verify-flags-underscore.py: exclude salt variable which look like flags 2015-08-17 11:19:31 -07:00
Eric Paris 7f96f9312b verify-flags-underscore.py: ignore 'flags' that look like bash variables
We ignore bad 'flags' if they are proceeded by $ or { as these are
likely bash variables and not in fact bad flag usage.
2015-08-17 11:19:31 -07:00
Eric Paris 56f6ad0c01 Specifically exclude some flag definitions in verify-flag-underscore.sh
We know there are some flags (declared with an _) which we wish to
ignore. These flags are used by container definitions, e2e, etc. By
explicitly ignoring those flags we can cut the amount of noise in the
whitelist.
2015-08-14 14:11:02 -04:00
Eric Paris 30d34d0e59 Reduce false positives with verify-flag-underscore.sh by updating regex
Check to make sure there is not an alphanumeric character immeditely
before or after the 'flag'.  It there is an alphanumeric character then
this is obviously not actually the flag we care about.  For example if
the project declares a flag "valid-name" but the regex finds something
like "invalid_name" we should not match.  Clearly this "invalid_name" is
not actually a wrong usage of the "valid-name" flag.
2015-08-13 21:06:39 -04:00
Eric Paris f54098fe00 Verify all flag usage does not use _
This works by defining two 'static' lists in hack. The first is the list
of all flags in the project which use a `-` or an `_` in their name. All
files being processed by verify-flags-underscore.py (or all files in the
repo if no filename arguments are given) will be searched for flag
declaration using a simple regex. Its not super smart. If a flag is
found which is not in the static list it will complain/reject the commit
until a human adds it to the list. If we do not keep a static list of
flags it takes >.2 seconds to find them 'all' at runtime. Since this is
run in pre-commit saving every part of a second helps.

After it finds all of the flags it runs all of the arguments (or all
files in repo if no arguments) looking for usage of those flags which
includes an `_`. There are lots of places where these are false
positives. For example we have a flag named oom-adj-score but the kernel
calls it oom_adj_score. To handle this we keep a second 'whitelist' of
lines which are allowed to use these flag names with an `_`.

Running the entire git repo looking for flags in every golang file and
looking in every single file for bad usage takes about 8.75 seconds.

Running it in the precommit hook where we only check things that changed
takes about .06 seconds.
2015-08-12 16:17:02 -04:00