Skip to content

Commit

Permalink
Clang tidy (fix/suppress) (#714)
Browse files Browse the repository at this point in the history
* bin/jenkins.sh: Use 'travis_wait'

* clang-tidy: Treat warnings as errors

* Suppress some third party clang-tidy warnings

* bin/jenkins.sh: Use 'travis_wait'

* Fix some clang-tidy warnings

* clang-tidy: Fix 'modernize-use-using' warnings

* clang-tidy: Fix 'performance-type-promotion-in-math-fn' warning

* clang-tidy: Disable 'cppcoreguidelines-pro-bounds-pointer-arithmetic' checks

* clang-tidy: Disable 'cppcoreguidelines-pro-type-vararg' checks

* clang-tidy: Disable 'cppcoreguidelines-pro-bounds-array-to-pointer-decay' checks

* clang-tidy: Disable 'cppcoreguidelines-pro-bounds-constant-array-index' checks

* clang-tidy: Disable 'cert-flp30-c' checks

* clang-tidy: Fix/suppress 'performance-noexcept-move-constructor' warnings

* clang-tidy: Fix/suppress 'cppcoreguidelines-special-member-functions' warnings

* clang-tidy: Disable 'cert-err58-cpp' checks

* clang-tidy: Disable 'cppcoreguidelines-pro-type-union-access' checks

* clang-tidy: Disable 'clang-analyzer-optin.performance.Padding' checks

* clang-tidy: Disable 'cppcoreguidelines-pro-type-const-cast' checks

* clang-tidy: Disable 'cppcoreguidelines-owning-memory' checks

* clang-tidy: Fix/suppress warnings

* clang-tidy: Use DRISHTI_BUILD_SHARED_SDK=OFF

* Add clang-tidy testing

* Remove '--verbose' instead of using '--discard 10 --tail 200'

* clang-tidy: Disable 'cert-err60-cpp' checks

* Fix Visual Studio build

* Fix Visual Studio tests

* Suppress clang-tidy warning

* Use 'clang-tidy-libcxx' toolchain
  • Loading branch information
ruslo authored and headupinclouds committed Aug 15, 2018
1 parent 588cea2 commit 3de4257
Show file tree
Hide file tree
Showing 104 changed files with 745 additions and 347 deletions.
17 changes: 14 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,google-readability-casting,misc-*,-misc-incorrect-roundings,-misc-macro-parentheses,-misc-misplaced-widening-cast,-misc-static-assert,modernize-*,-modernize-deprecated-headers,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-return-braced-init-list,-modernize-use-auto,-modernize-use-default-member-init,-modernize-use-emplace,-modernize-use-equals-default,-modernize-use-equals-delete,-modernize-use-noexcept,-modernize-use-transparent-functors,-modernize-use-using,performance-*,-performance-inefficient-string-concatenation,readability-*,-readability-function-size,-readability-identifier-naming,-readability-implicit-bool-cast,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter,-readability-redundant-declaration,-readability-redundant-member-init,-readability-simplify-boolean-expr,,-*,clang-analyzer-*,-clang-analyzer-alpha*,performance-*,cppcoreguidelines-*,cert-*,modernize-*'
WarningsAsErrors: ''
# TODO (?): cppcoreguidelines-pro-bounds-pointer-arithmetic
# TODO (?): cppcoreguidelines-pro-type-vararg
# TODO (?): cppcoreguidelines-pro-bounds-array-to-pointer-decay
# TODO (?): cppcoreguidelines-pro-bounds-constant-array-index
# TODO (?): cert-flp30-c
# TODO (?): cert-err58-cpp
# TODO (?): cppcoreguidelines-pro-type-union-access
# TODO (?): clang-analyzer-optin.performance.Padding
# TODO (?): cppcoreguidelines-pro-type-const-cast
# TODO (?): cppcoreguidelines-owning-memory
# TODO (?): cert-err60-cpp
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,google-readability-casting,misc-*,-misc-incorrect-roundings,-misc-macro-parentheses,-misc-misplaced-widening-cast,-misc-static-assert,modernize-*,-modernize-deprecated-headers,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-return-braced-init-list,-modernize-use-auto,-modernize-use-default-member-init,-modernize-use-emplace,-modernize-use-equals-default,-modernize-use-equals-delete,-modernize-use-noexcept,-modernize-use-transparent-functors,-modernize-use-using,performance-*,-performance-inefficient-string-concatenation,readability-*,-readability-function-size,-readability-identifier-naming,-readability-implicit-bool-cast,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter,-readability-redundant-declaration,-readability-redundant-member-init,-readability-simplify-boolean-expr,,-*,clang-analyzer-*,-clang-analyzer-alpha*,performance-*,cppcoreguidelines-*,cert-*,modernize-*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cert-flp30-c,-cert-err58-cpp,-cppcoreguidelines-pro-type-union-access,-clang-analyzer-optin.performance.Padding,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-owning-memory,-cert-err60-cpp'
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
User: dhirvonen
CheckOptions:
CheckOptions:
- key: cert-dcl59-cpp.HeaderFileExtensions
value: h,hh,hpp,hxx
- key: cert-err09-cpp.CheckThrowTemporaries
Expand Down
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ matrix:
# INSTALL=--strip
# TYPE=polly

- os: linux
env: >
TOOLCHAIN=clang-tidy-libcxx
CONFIG=Release
INSTALL=--strip
TYPE=polly
- os: linux
env: >
TOOLCHAIN=android-ndk-r17-api-24-arm64-v8a-clang-libcxx14
Expand Down
19 changes: 10 additions & 9 deletions bin/jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ case "${TYPE}" in
fi
fi

if [[ "${TOOLCHAIN}" == "clang-tidy" ]];
if [[ "${TOOLCHAIN}" == "clang-tidy-libcxx" ]];
then
SHARED_SDK=OFF
if [[ "${TRAVIS}" == "true" ]];
then
POLLY_DISCARD_OPTIONS="--discard 10 --tail 200"
VERBOSE=""

wget -q "${CLANG_LLVM_FULL_URL}"
tar xf "${CLANG_LLVM_FILENAME}"
Expand All @@ -82,10 +83,11 @@ case "${TYPE}" in
echo "Checks: '-*'" >> _ci/.clang-tidy
echo "WarningsAsErrors: ''" >> _ci/.clang-tidy
else
POLLY_DISCARD_OPTIONS=""
VERBOSE=--verbose
fi
else
POLLY_DISCARD_OPTIONS=""
SHARED_SDK=ON
VERBOSE=--verbose
fi

if [[ ${TRAVIS} == "true" ]]; then
Expand All @@ -105,15 +107,14 @@ case "${TYPE}" in
polly.py \
--toolchain "${TOOLCHAIN}" \
--config "${CONFIG}" \
--verbose \
${POLLY_DISCARD_OPTIONS} \
${VERBOSE} \
--ios-multiarch --ios-combined \
--archive drishti \
--jobs 4 \
${TEST} \
"${INSTALL}" \
--fwd \
DRISHTI_BUILD_SHARED_SDK=ON \
DRISHTI_BUILD_SHARED_SDK=${SHARED_SDK} \
DRISHTI_BUILD_TESTS=YES \
DRISHTI_BUILD_EXAMPLES=YES \
DRISHTI_COPY_3RDPARTY_LICENSES=ON \
Expand Down Expand Up @@ -163,7 +164,7 @@ case "${TYPE}" in

set -x

./gradlew assembleDebug -Parch=${ANDROID_STUDIO_ARCH}
../bin/travis_wait -i 60 "./gradlew assembleDebug -Parch=${ANDROID_STUDIO_ARCH}"

exit 0
fi
Expand Down Expand Up @@ -211,7 +212,7 @@ case "${TYPE}" in
sleep 30

# Now should be fine
./gradlew assembleDebug -Parch=${ANDROID_STUDIO_ARCH}
../bin/travis_wait -i 60 "./gradlew assembleDebug -Parch=${ANDROID_STUDIO_ARCH}"

# Back to normal CMake configuration
sed -i 's,^if(DRISHTI_DEBUG_STOP OR TRUE)$,if(DRISHTI_DEBUG_STOP),' ../CMakeLists.txt
Expand Down
18 changes: 11 additions & 7 deletions src/app/dlib/eyexml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ inline T ntoh_any(T t)
{
static const unsigned char int_bytes[sizeof(int)] = { 0xFF };
static const int msb_0xFF = 0xFF << (sizeof(int) - 1) * CHAR_BIT;
static bool host_is_big_endian = (*(reinterpret_cast<const int*>(int_bytes)) & msb_0xFF) != 0;
static bool host_is_big_endian = (*(reinterpret_cast<const int*>(int_bytes)) & msb_0xFF) != 0; // NOLINT (TODO)
if (host_is_big_endian)
{
return t;
}

auto* ptr = reinterpret_cast<unsigned char*>(&t);
auto* ptr = reinterpret_cast<unsigned char*>(&t); // NOLINT (TODO)
std::reverse(ptr, ptr + sizeof(t));
return t;
}
Expand All @@ -85,9 +85,9 @@ static cv::Size read_png_size(const std::string& filename)
{
unsigned int width, height;
in.seekg(16);
in.read(reinterpret_cast<char*>(&width), 4);
in.read(reinterpret_cast<char*>(&height), 4);
size = { static_cast<int>(ntoh_any(width)), static_cast<int>(ntoh_any(height)) };
in.read(reinterpret_cast<char*>(&width), 4); // NOLINT (TODO)
in.read(reinterpret_cast<char*>(&height), 4); // NOLINT (TODO)
size = { static_cast<int>(ntoh_any(width)), static_cast<int>(ntoh_any(height)) }; // NOLINT (TODO)
}
return size;
}
Expand Down Expand Up @@ -137,8 +137,12 @@ class DlibDocument
m_spec = drishti::eye::EyeModelSpecification::create();
}

~DlibDocument()
= default;
DlibDocument(const DlibDocument&) = delete;
DlibDocument(DlibDocument&&) = delete;
DlibDocument& operator=(const DlibDocument&) = delete;
DlibDocument& operator=(DlibDocument&&) = delete;

~DlibDocument() = default;

void start()
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/dlib/test_shape_predictor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int mine(int argc, char* argv[])

drishti::ml::shape_predictor sp;
load_cpb(sModel, sp);
int ellipse_count = sp.m_ellipse_count;
//int ellipse_count = sp.m_ellipse_count;

#if 0
for(auto &f : filenames)
Expand Down
15 changes: 15 additions & 0 deletions src/app/eye/eye.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ struct Padder : public Transform
eye = eye - tl;
}

Padder(const Padder&) = delete;
Padder(Padder&&) = delete;
Padder& operator=(const Padder&) = delete;
Padder& operator=(Padder&&) = delete;

static bool isGoodAspectRatio(const cv::Size& size, float targetAspectRatio)
{
const float currentAspectRatio = std::abs(static_cast<float>(size.width) / static_cast<float>(size.height));
Expand Down Expand Up @@ -124,6 +129,11 @@ struct Flopper : public Transform
}
}

Flopper(const Flopper&) = delete;
Flopper(Flopper&&) = delete;
Flopper& operator=(const Flopper&) = delete;
Flopper& operator=(Flopper&&) = delete;

bool isRight = true;
};

Expand Down Expand Up @@ -151,6 +161,11 @@ struct Warper : public Transform
}
}

Warper(const Warper&) = delete;
Warper(Warper&&) = delete;
Warper& operator=(const Warper&) = delete;
Warper& operator=(Warper&&) = delete;

const cv::Matx33f* H = nullptr;
};

Expand Down
7 changes: 7 additions & 0 deletions src/app/facecrop/FaceJitterer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ struct FaceWithLandmarks
Landmarks eyesNoseMouth; // {eyeR, eyeL, nose, mouthR, mouthL}
std::string filename;

FaceWithLandmarks() = default;
~FaceWithLandmarks() = default;

FaceWithLandmarks& operator=(FaceWithLandmarks&&) = default;
FaceWithLandmarks(FaceWithLandmarks&&) = default;
FaceWithLandmarks(const FaceWithLandmarks&) = default;

FaceWithLandmarks& operator=(const FaceWithLandmarks& src)
{
image = src.image;
Expand Down
Loading

0 comments on commit 3de4257

Please sign in to comment.