Statistics
| Branch: | Tag: | Revision:

root / autotools / check-python-code @ 9648f1b4

History | View | Annotate | Download (1.3 kB)

1
#!/bin/bash
2
#
3

    
4
# Copyright (C) 2009 Google Inc.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
# General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
# 02110-1301, USA.
20

    
21
let problems=0
22

    
23
for script; do
24
  if grep -n -H -F $'\t' "$script"; then
25
    let ++problems
26
    echo "Found tabs in $script" >&2
27
  fi
28

    
29
  if grep -n -H -E '[[:space:]]$' "$script"; then
30
    let ++problems
31
    echo "Found end-of-line-whitespace in $script" >&2
32
  fi
33

    
34
  if [[ "$(wc --max-line-length < "$script")" -gt 80 ]]; then
35
    let ++problems
36
    echo "Longest line in $script is longer than 80 characters" >&2
37
  fi
38
done
39

    
40
if [[ "$problems" -gt 0 ]]; then
41
  echo "Found $problems problem(s) while checking code." >&2
42
  exit 1
43
fi