Debian Codegraph @

tools/run_lint.sh

raw
1 #!/bin/bash
2 # Copyright 2016 Google Inc. All rights reserved.
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 find . -name "*.py" | sort |\
16 xargs pylint --rcfile tools/pylintrc --msg-template='{msg_id}:{line:4} {obj}: {msg}[{symbol}]' > ./tools/new_lint_errors.txt
17
18 # Cannot disable the following errors, seems this is a known issue from searching online.
19 sed -i ':a;N;$!ba;s/R0801.*duplicate-code]//g' ./tools/new_lint_errors.txt
20 sed -i 's/R0904.*too-many-public-methods]//g' ./tools/new_lint_errors.txt
21 sed -i 's/R0912.*too-many-branches]//g' ./tools/new_lint_errors.txt
22 sed -i 's/R0914.*too-many-locals]//g' ./tools/new_lint_errors.txt
23 sed -i 's/R0915.*too-many-statements]//g' ./tools/new_lint_errors.txt
24 sed -i '/^\s*$/d' ./tools/new_lint_errors.txt
25 new_diff=$(diff -u tools/current_lint_errors.txt tools/new_lint_errors.txt | grep -E "^\+[^+]")
26
27 if [ "$new_diff" == "" ]
28 then
29 echo "[OK] The codebase passes the linter tests!";
30 else
31 echo "[ERROR] There are additional new lint errors present in your changes."
32 echo "$new_diff"
33 exit 1
34 fi