scripts/pylint/do_pylint.sh
changeset 388 699b206b64b7
child 853 062290a3b3cf
equal deleted inserted replaced
387:c55195361cb6 388:699b206b64b7
       
     1 #!/bin/sh
       
     2 # Copyright 2008 the Melange authors.
       
     3 #
       
     4 # Licensed under the Apache License, Version 2.0 (the "License");
       
     5 # you may not use this file except in compliance with the License.
       
     6 # You may obtain a copy of the License at
       
     7 #
       
     8 #   http://www.apache.org/licenses/LICENSE-2.0
       
     9 #
       
    10 # Unless required by applicable law or agreed to in writing, software
       
    11 # distributed under the License is distributed on an "AS IS" BASIS,
       
    12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13 # See the License for the specific language governing permissions and
       
    14 # limitations under the License.
       
    15 
       
    16 # Set some environmental variables for pylint and run it on Melange code
       
    17 # To disable some of the checks use options listed below:
       
    18 # disable unused imports: --disable-msg=W0611
       
    19 # disable TODO: --disable-msg=W0511
       
    20 # disable report: --reports=no
       
    21 # disable similarity check: --disable-checker=similarities
       
    22 #
       
    23 # Checks listed above are disabled in silent mode 
       
    24 # which can be run using --silent argument
       
    25 
       
    26 SILENT_ARGS=""
       
    27 ARGS=( "$@" )
       
    28 
       
    29 if [ "$1" == "--silent" ]; then
       
    30   SILENT_ARGS="--disable-msg=W0611 --disable-msg=W0511 --reports=no --disable-checker=similarities"
       
    31   ARGS[0]=""
       
    32 fi
       
    33 
       
    34 PROJ_DIR=$(dirname "$0")/../..
       
    35 PROJ_DIR=$(cd "$PROJ_DIR"; pwd)
       
    36 APP_DIR="${PROJ_DIR}/app"
       
    37 
       
    38 # Note: We will add ghop and gsoc modules once there something in there
       
    39 CHECK_MODULES="soc reflistprop settings.py urls.py main.py"
       
    40 
       
    41 PYLINTRC=$(dirname "$0")/pylintrc
       
    42 PYTHONPATH="${PYTHONPATH}:${PROJ_DIR}/app/:${PROJ_DIR}/thirdparty/google_appengine/"
       
    43 
       
    44 export PYTHONPATH
       
    45 export PYLINTRC
       
    46 
       
    47 PYLINT_PATH=$(which pylint)
       
    48 
       
    49 if [ "$PYLINT_PATH" = "" ]; then
       
    50   echo >&2 "Cannot find pylint. Make sure pylint is in your PATH variable."
       
    51   exit 1
       
    52 fi
       
    53 
       
    54 CHECK_MODULES_PATHS=""
       
    55 
       
    56 for x in $CHECK_MODULES
       
    57 do
       
    58     CHECK_MODULES_PATHS="${CHECK_MODULES_PATHS} ${APP_DIR}/${x}"
       
    59 done
       
    60 
       
    61 pylint $SILENT_ARGS $ARGS $CHECK_MODULES_PATHS