You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2017/12/03 01:02:45 UTC

[15/50] [abbrv] thrift git commit: THRIFT-4370: build generated code before running static code analysis; fix E722 flake8 issues identified in python code

THRIFT-4370: build generated code before running static code analysis;
fix E722 flake8 issues identified in python code

This closes #1399


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/350fe753
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/350fe753
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/350fe753

Branch: refs/heads/0.11.0
Commit: 350fe7531feecf7df5208fa19d25730c6ce0a30d
Parents: 254e86b
Author: James E. King, III <jk...@apache.org>
Authored: Wed Oct 25 09:57:18 2017 -0400
Committer: James E. King, III <jk...@apache.org>
Committed: Thu Oct 26 11:37:02 2017 -0400

----------------------------------------------------------------------
 build/docker/scripts/sca.sh      | 20 +++++++++++++++++---
 lib/py/setup.py                  |  2 +-
 test/features/container_limit.py |  2 +-
 test/features/string_limit.py    |  2 +-
 test/py/TestServer.py            |  4 ++--
 test/py/TestSocket.py            |  6 +++---
 6 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/350fe753/build/docker/scripts/sca.sh
----------------------------------------------------------------------
diff --git a/build/docker/scripts/sca.sh b/build/docker/scripts/sca.sh
index 2f2fb68..38803d4 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

http://git-wip-us.apache.org/repos/asf/thrift/blob/350fe753/lib/py/setup.py
----------------------------------------------------------------------
diff --git a/lib/py/setup.py b/lib/py/setup.py
index 3d14118..4056b9b 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

http://git-wip-us.apache.org/repos/asf/thrift/blob/350fe753/test/features/container_limit.py
----------------------------------------------------------------------
diff --git a/test/features/container_limit.py b/test/features/container_limit.py
index a16e364..88f8487 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')

http://git-wip-us.apache.org/repos/asf/thrift/blob/350fe753/test/features/string_limit.py
----------------------------------------------------------------------
diff --git a/test/features/string_limit.py b/test/features/string_limit.py
index 14f57d0..b8991d6 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')

http://git-wip-us.apache.org/repos/asf/thrift/blob/350fe753/test/py/TestServer.py
----------------------------------------------------------------------
diff --git a/test/py/TestServer.py b/test/py/TestServer.py
index a7366a8..04ad62a 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)

http://git-wip-us.apache.org/repos/asf/thrift/blob/350fe753/test/py/TestSocket.py
----------------------------------------------------------------------
diff --git a/test/py/TestSocket.py b/test/py/TestSocket.py
index ae3160f..619eb10 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)