Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clang-tidy #7475

Merged
merged 4 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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