You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by fo...@apache.org on 2020/04/26 09:26:28 UTC

[avro] branch master updated: AVRO-2813: Add cppcheck as a C++ linter (#862)

This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new f56cafb  AVRO-2813: Add cppcheck as a C++ linter (#862)
f56cafb is described below

commit f56cafb83854a7529625bd1d82521f5848399ccc
Author: Kengo Seki <se...@apache.org>
AuthorDate: Sun Apr 26 18:26:20 2020 +0900

    AVRO-2813: Add cppcheck as a C++ linter (#862)
---
 build.sh                | 2 +-
 lang/c++/build.sh       | 4 +++-
 lang/c++/impl/Zigzag.cc | 2 ++
 share/docker/Dockerfile | 1 +
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/build.sh b/build.sh
index c9cfc88..93c9272 100755
--- a/build.sh
+++ b/build.sh
@@ -88,7 +88,7 @@ do
       (cd lang/py && ./build.sh lint test)
       (cd lang/py3 && ./build.sh lint test)
       (cd lang/c; ./build.sh test)
-      (cd lang/c++; ./build.sh test)
+      (cd lang/c++; ./build.sh lint test)
       (cd lang/csharp; ./build.sh test)
       (cd lang/js; ./build.sh lint test)
       (cd lang/ruby; ./build.sh lint test)
diff --git a/lang/c++/build.sh b/lang/c++/build.sh
index 543638b..598d7aa 100755
--- a/lang/c++/build.sh
+++ b/lang/c++/build.sh
@@ -77,7 +77,9 @@ do
 
 case "$target" in
   lint)
-    echo 'This is a stub where someone can provide linting.'
+    # some versions of cppcheck seem to require an explicit
+    # "--error-exitcode" option to return non-zero code
+    cppcheck --error-exitcode=1 --inline-suppr -f -q -x c++ .
     ;;
 
   test)
diff --git a/lang/c++/impl/Zigzag.cc b/lang/c++/impl/Zigzag.cc
index 371bd2d..06db5b4 100644
--- a/lang/c++/impl/Zigzag.cc
+++ b/lang/c++/impl/Zigzag.cc
@@ -24,6 +24,7 @@ namespace avro {
 uint64_t
 encodeZigzag64(int64_t input)
 {
+    // cppcheck-suppress shiftTooManyBitsSigned
     return ((input << 1) ^ (input >> 63));
 }
 
@@ -36,6 +37,7 @@ decodeZigzag64(uint64_t input)
 uint32_t
 encodeZigzag32(int32_t input)
 {
+    // cppcheck-suppress shiftTooManyBitsSigned
     return ((input << 1) ^ (input >> 31));
 }
 
diff --git a/share/docker/Dockerfile b/share/docker/Dockerfile
index a9467af..50b296d 100644
--- a/share/docker/Dockerfile
+++ b/share/docker/Dockerfile
@@ -34,6 +34,7 @@ RUN apt-get -qqy update \
                                                  bzip2 \
                                                  bundler \
                                                  cmake \
+                                                 cppcheck \
                                                  curl \
                                                  doxygen \
                                                  flex \