~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to utilities/lint.sh

  • Committer: Curtis Hovey
  • Date: 2007-10-01 16:11:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5182.
  • Revision ID: curtis.hovey@canonical.com-20071001161128-20misj492mfpso37
Updated a few files to illustrate how lint works.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
#
3
 
# Runs pyflakes and pylint on files changed in tree
4
 
#
5
 
# 2005-07-14 creation (kiko)
6
 
# 2005-07-15 added verbose mode, and fixed up warnings
7
 
# 2005-07-20 added detection of conflict markers
8
 
# 2005-07-21 nicer handling of verbose mode, tweaking of warnings
9
 
# 2005-09-23 tweak more warnings on a dir-specific basis
 
3
# Runs xmlint, pyflakes and pylint on files changed from parent branch.
 
4
# Use -v to run pylint under stricter conditions with additional messages.
 
5
 
 
6
VERBOSITY=0
 
7
if [ "$1" == "-v" ]; then
 
8
    shift
 
9
    VERBOSITY=1
 
10
fi
10
11
 
11
12
if [ -z "$1" ]; then
12
13
    rev=`bzr info | sed '/parent branch:/!d; s, .*file://,-r ancestor:,'`
18
19
 
19
20
echo "= Launchpad lint ="
20
21
echo ""
 
22
echo "Checking for conflicts. Running xmllint, pyflakes, and pylint."
 
23
echo ""
21
24
 
22
25
if [ -z "$files" ]; then
23
26
    echo "No changed files detected."
24
27
    exit
25
28
fi
 
29
echo ""
26
30
 
27
31
for file in $files; do
28
32
    # NB. Odd syntax on following line to stop lint.sh detecting conflict
74
78
    fi
75
79
fi
76
80
 
77
 
PYLINT=`which pylint`
78
 
if [ -z $PYLINT ]; then
 
81
pylint=`which pylint`
 
82
if [ -z $pylint ]; then
79
83
    exit
80
84
fi
81
85
 
82
86
echo "== Pylint notices =="
 
87
echo ""
 
88
if [ $VERBOSITY -eq 1 ]; then
 
89
    echo "Using verbose rules."
 
90
else
 
91
    echo "Using normal rules."
 
92
fi
83
93
 
84
 
pylint="python2.4 -Wi::DeprecationWarning $PYLINT"
 
94
pylint="python2.4 -Wi::DeprecationWarning $pylint"
85
95
rcfile="--rcfile=utilities/lp.pylintrc"
86
96
sed_deletes="/^*/d; /Unused import \(action\|_python\)/d; "
87
97
sed_deletes="$sed_deletes /_action: Undefined variable/d; "
88
98
sed_deletes="$sed_deletes /_getByName: Instance/d; "
89
99
sed_deletes="$sed_deletes /Redefining built-in .id/d;"
 
100
sed_deletes="$sed_deletes /Redefining built-in 'filter'/d;"
 
101
 
 
102
if [ $VERBOSITY -eq 1 ]; then
 
103
    rcfile="--rcfile=utilities/lp-verbose.pylintrc"
 
104
fi
90
105
 
91
106
for file in $pyfiles; do
92
107
    # Messages are disabled by directory or file name.
122
137
    if [ ! -z "$output" ]; then
123
138
        echo ""
124
139
        echo ""
125
 
        echo "=== Pylint notices on $file ==="
 
140
        echo "=== $file ==="
 
141
        echo ""
126
142
        echo "$output"
127
143
    fi
128
144
done