diff options
author | James E. King, III <jking@apache.org> | 2017-10-25 09:57:18 -0400 |
---|---|---|
committer | James E. King, III <jking@apache.org> | 2017-10-26 11:37:02 -0400 |
commit | 350fe7531feecf7df5208fa19d25730c6ce0a30d (patch) | |
tree | 89021ac90d92fbcc07ef41f118fc29b7ce80b4a4 | |
parent | 254e86b0103be51c6af9cc50220ee8c144234239 (diff) | |
download | thrift-350fe7531feecf7df5208fa19d25730c6ce0a30d.tar.gz |
THRIFT-4370: build generated code before running static code analysis;
fix E722 flake8 issues identified in python code
This closes #1399
-rwxr-xr-x | build/docker/scripts/sca.sh | 20 | ||||
-rw-r--r-- | lib/py/setup.py | 2 | ||||
-rw-r--r-- | test/features/container_limit.py | 2 | ||||
-rw-r--r-- | test/features/string_limit.py | 2 | ||||
-rwxr-xr-x | test/py/TestServer.py | 4 | ||||
-rwxr-xr-x | test/py/TestSocket.py | 6 |
6 files changed, 25 insertions, 11 deletions
diff --git a/build/docker/scripts/sca.sh b/build/docker/scripts/sca.sh index 2f2fb684e..38803d4ae 100755 --- a/build/docker/scripts/sca.sh +++ b/build/docker/scripts/sca.sh @@ -2,6 +2,18 @@ set -ev # +# Generate thrift files so the static code analysis includes an analysis +# of the files the thrift compiler spits out. If running interactively +# set the NOBUILD environment variable to skip the boot/config/make phase. +# + +if [[ -z "$NOBUILD" ]]; then + ./bootstrap.sh + ./configure --enable-tutorial=no + make -j3 precross +fi + +# # C/C++ static code analysis with cppcheck # add --error-exitcode=1 to --enable=all as soon as everything is fixed # @@ -21,18 +33,20 @@ cppcheck --force --quiet --inline-suppr --enable=all -j2 lib/cpp/src lib/cpp/tes cppcheck --force --quiet --inline-suppr --enable=all -j2 lib/c_glib/src lib/c_glib/test test/c_glib/src tutorial/c_glib # Silent error checks -cppcheck --force --quiet --inline-suppr --error-exitcode=1 -j2 compiler/cpp/src +# See THRIFT-4371 : flex generated code triggers "possible null pointer dereference" in yy_init_buffer +cppcheck --force --quiet --inline-suppr --suppress="*:thrift/thriftl.cc" --error-exitcode=1 -j2 compiler/cpp/src cppcheck --force --quiet --inline-suppr --error-exitcode=1 -j2 lib/cpp/src lib/cpp/test test/cpp tutorial/cpp cppcheck --force --quiet --inline-suppr --error-exitcode=1 -j2 lib/c_glib/src lib/c_glib/test test/c_glib/src tutorial/c_glib # Python code style flake8 --ignore=E501 lib/py flake8 tutorial/py -flake8 --ignore=E501 test/py +# THRIFT-4371 : generated files are excluded because they haven't been scrubbed yet +flake8 --ignore=E501 --exclude="*/gen-py*/*" test/py flake8 test/py.twisted flake8 test/py.tornado flake8 --ignore=E501 test/test.py -flake8 --ignore=E501 test/crossrunner +flake8 --ignore=E501,E722 test/crossrunner flake8 test/features # TODO etc diff --git a/lib/py/setup.py b/lib/py/setup.py index 3d1411812..4056b9b90 100644 --- a/lib/py/setup.py +++ b/lib/py/setup.py @@ -22,7 +22,7 @@ import sys try: from setuptools import setup, Extension -except: +except Exception: from distutils.core import setup, Extension from distutils.command.build_ext import build_ext diff --git a/test/features/container_limit.py b/test/features/container_limit.py index a16e3641e..88f8487fa 100644 --- a/test/features/container_limit.py +++ b/test/features/container_limit.py @@ -61,7 +61,7 @@ def main(argv): print('[OK]: just limit') try: test_list(proto, list(range(args.limit + 1))) - except: + except Exception: print('[OK]: limit + 1') else: print('[ERROR]: limit + 1') diff --git a/test/features/string_limit.py b/test/features/string_limit.py index 14f57d083..b8991d64f 100644 --- a/test/features/string_limit.py +++ b/test/features/string_limit.py @@ -51,7 +51,7 @@ def main(argv): print('[OK]: just limit') try: test_string(proto, 'a' * (args.limit + 1)) - except: + except Exception: print('[OK]: limit + 1') else: print('[ERROR]: limit + 1') diff --git a/test/py/TestServer.py b/test/py/TestServer.py index a7366a87b..04ad62a95 100755 --- a/test/py/TestServer.py +++ b/test/py/TestServer.py @@ -193,7 +193,7 @@ def main(options): try: pfactory.string_length_limit = options.string_limit pfactory.container_length_limit = options.container_limit - except: + except Exception: # Ignore errors for those protocols that does not support length limit pass @@ -255,7 +255,7 @@ def main(options): logging.info('Requesting server to stop()') try: server.stop() - except: + except Exception: pass signal.signal(signal.SIGALRM, clean_shutdown) signal.alarm(4) diff --git a/test/py/TestSocket.py b/test/py/TestSocket.py index ae3160f31..619eb1002 100755 --- a/test/py/TestSocket.py +++ b/test/py/TestSocket.py @@ -36,7 +36,7 @@ class TimeoutTest(unittest.TestCase): self.listen_sock.bind(('localhost', self.port)) self.listen_sock.listen(5) break - except: + except Exception: if i == 49: raise @@ -50,7 +50,7 @@ class TimeoutTest(unittest.TestCase): socket.setTimeout(10) socket.open() leaky.append(socket) - except: + except Exception: self.assert_(time.time() - starttime < 5.0) def testWriteTimeout(self): @@ -64,7 +64,7 @@ class TimeoutTest(unittest.TestCase): while True: lsock.write("hi" * 100) - except: + except Exception: self.assert_(time.time() - starttime < 5.0) |