cros: lint: support linting of files based on content

Not all files use extensions (e.g. foo.py or blah.sh).  In fact, our style
guides encourage omitting them when they get installed as executables so
that people don't have to worry about the underlying language.

Update the linter to deal with this scenario.  We read the first 128 bytes
out in order to process the shebang.  Then we use that to determine if it
is a python or shell script and add them to the right linting paths.

For shell scripts, we initially just make sure it parses at a basic level.
There is opportunity for future work here, but will require more effort to
pull off.

BUG=chromium:682860
TEST=`cros lint` on a broken shell script fails, but works on a good one

Change-Id: I5d46d66f7f56cbb74c2fa21880eff61d0e4728f3
Reviewed-on: https://chromium-review.googlesource.com/430930
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Dan Erat <derat@chromium.org>
1 file changed