[package] Fixed potential dereference of nullptr
[platform/core/api/webapi-plugins.git] / tools / check-coding-style
1 #!/bin/bash
2 # Copyright (c) 2013 Intel Corporation. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 if [ ! `which cpplint.py` ]; then
7    echo -e "\nPlease make sure cpplint.py is in your PATH. It is part of depot_tools inside Chromium repository."
8    exit 1
9 fi
10
11 if [ ! `which gjslint` ]; then
12    echo -e "\nPlease make sure gjslint (Google Closure Lint) is in your PATH."
13    echo -e "You can install it directly by \"sudo easy_install-2.7 http://closure-linter.googlecode.com/files/closure_linter-latest.tar.gz\"."
14    echo -e "Or visit https://developers.google.com/closure/utilities/docs/linter_howto for more information.\n"
15    exit 1
16 fi
17
18 # Store current dir and change to repository root dir.
19 OLD_PWD=$PWD
20 SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21 cd $SELF_DIR/..
22
23 # FIXME(cmarcelo): the exception 'runtime/references' is for system_info/, we
24 # need to verify whether is really necessary or should be fixed.
25 FILTERS="-readability/streams,-runtime/references"
26
27 # TODO(cmarcelo): Skipping directories so we can enable style
28 # gradually, since it wasn't enforced before.
29 cpplint.py --filter="$FILTERS" $(find . \
30                                ! -path './out*' ! -path './.git*' \
31                                ! -path './demos' ! -path './examples' \
32                                ! -path './packaging' \
33                                ! -name 'XW_Extension*.h' \
34                                ! -name 'picojson.*' \
35                                \( -name '*.h' -o -name '*.cc' \) )
36 CPP_RET_VAL=$?
37
38 gjslint --strict --nojsdoc --max_line_length 100 --unix_mode $(find . \
39                                ! -path './out*' ! -path './.git*' \
40                                ! -path './packaging' \
41                                ! -name 'jquery*' \
42                                ! -name 'flotr2.*' \
43                                -name '*.js' )
44
45 # Return to previous dir and return the code returned by cpplint.py
46 JS_RET_VAL=$?
47 cd $OLD_PWD
48
49 if [ "x$CPP_RET_VAL" = "x0" -a "x$JS_RET_VAL" = "x0" ]; then
50   exit 0
51 else
52   exit 1
53 fi