Skip to content

Commit

Permalink
Fix clang-tidy (envoyproxy#7475)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Argueta <dereka@pinterest.com>
  • Loading branch information
derekargueta authored and mattklein123 committed Jul 8, 2019
1 parent 91b4c9c commit f683743
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Checks: 'abseil-*,
modernize-*,
performance-*,
readability-braces-around-statements,
readability-container-size-empty'
readability-redundant-*,
readability-container-size-empty,
readability-redundant-*'

#TODO(lizan): grow this list, fix possible warnings and make more checks as error
WarningsAsErrors: 'abseil-duration-*,
Expand Down
6 changes: 6 additions & 0 deletions ci/run_clang_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

set -e

# Quick syntax check of .clang-tidy using PyYAML.
if ! python -c 'import yaml, sys; yaml.safe_load(sys.stdin)' < .clang-tidy > /dev/null; then
echo ".clang-tidy has a syntax error"
exit 1
fi

echo "Generating compilation database..."

cp -f .bazelrc .bazelrc.bak
Expand Down
2 changes: 1 addition & 1 deletion source/common/grpc/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ absl::optional<Status::GrpcStatus> Common::getGrpcStatus(const Http::HeaderMap&

uint64_t grpc_status_code;
if (!grpc_status_header || grpc_status_header->value().empty()) {
return absl::optional<Status::GrpcStatus>();
return {};
}
if (!absl::SimpleAtoi(grpc_status_header->value().getStringView(), &grpc_status_code) ||
grpc_status_code > Status::GrpcStatus::MaximumValid) {
Expand Down
2 changes: 1 addition & 1 deletion source/common/stats/thread_local_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ ThreadLocalStoreImpl::ScopeImpl::findStatLockHeld(
return absl::nullopt;
}

return std::cref(*iter->second.get());
return std::cref(*iter->second);
}

Counter& ThreadLocalStoreImpl::ScopeImpl::counterFromStatName(StatName name) {
Expand Down
2 changes: 1 addition & 1 deletion source/common/upstream/outlier_detection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ SuccessRateAccumulatorBucket* SuccessRateAccumulator::updateCurrentWriter() {
absl::optional<double>
SuccessRateAccumulator::getSuccessRate(uint64_t success_rate_request_volume) {
if (backup_success_rate_bucket_->total_request_counter_ < success_rate_request_volume) {
return absl::optional<double>();
return {};
}

return {backup_success_rate_bucket_->success_request_counter_ * 100.0 /
Expand Down
2 changes: 1 addition & 1 deletion test/common/protobuf/utility_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ TEST_F(ProtobufUtilityTest, HashedValue) {
EXPECT_EQ(hv1, hv2);
EXPECT_NE(hv1, hv3);

HashedValue copy(hv1);
HashedValue copy(hv1); // NOLINT(performance-unnecessary-copy-initialization)
EXPECT_EQ(hv1, copy);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ TEST_P(QuicMemSliceTest, ConstructMemSliceFromBuffer) {
quic::QuicMemSlice slice1{quic::QuicMemSliceImpl(buffer, str2.length())};
EXPECT_EQ(str.length(), buffer.length());
EXPECT_EQ(str2, std::string(slice1.data(), slice1.length()));
std::string str2_old = str2;
std::string str2_old = str2; // NOLINT(performance-unnecessary-copy-initialization)
// slice1 is released, but str2 should not be affected.
slice1.Reset();
EXPECT_TRUE(slice1.empty());
Expand Down

0 comments on commit f683743

Please sign in to comment.