Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit e9a943b

Browse files
authored
Tidy up code. (#220)
* Remove some unnecessary includes. * Some clang-tidy adjustments.
1 parent 37eeaed commit e9a943b

34 files changed

+52
-52
lines changed

opencensus/common/internal/random.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
#ifndef OPENCENSUS_COMMON_INTERNAL_RANDOM_H_
1616
#define OPENCENSUS_COMMON_INTERNAL_RANDOM_H_
1717

18+
#include <cstddef>
1819
#include <cstdint>
19-
#include <cstring>
20-
#include <memory>
2120
#include <random>
22-
#include <vector>
2321

22+
#include "absl/base/thread_annotations.h"
2423
#include "absl/synchronization/mutex.h"
2524
#include "absl/time/clock.h"
2625

opencensus/common/internal/random_benchmark.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include <cstddef>
1516
#include <cstdint>
1617
#include <vector>
1718

opencensus/common/internal/stats_object.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <vector>
2626

2727
#include "absl/base/macros.h"
28-
#include "absl/memory/memory.h"
2928
#include "absl/strings/str_cat.h"
3029
#include "absl/strings/substitute.h"
3130
#include "absl/time/clock.h"

opencensus/common/internal/stats_object_test.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
#include <cstdlib>
1919
#include <deque>
2020
#include <iostream>
21-
#include <memory>
2221
#include <numeric>
23-
#include <random>
24-
#include <utility>
2522

2623
#include "absl/strings/str_join.h"
2724
#include "absl/types/span.h"

opencensus/common/internal/string_vector_hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#ifndef OPENCENSUS_COMMON_INTERNAL_STRING_VECTOR_HASH_H_
1616
#define OPENCENSUS_COMMON_INTERNAL_STRING_VECTOR_HASH_H_
1717

18-
#include <functional>
18+
#include <cstddef>
1919
#include <string>
2020
#include <vector>
2121

opencensus/context/internal/context_benchmark.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "opencensus/context/context.h"
16-
1715
#include <functional>
1816

1917
#include "benchmark/benchmark.h"
18+
#include "opencensus/context/context.h"
2019

2120
namespace opencensus {
2221
namespace context {

opencensus/context/internal/with_context_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
#include "opencensus/context/with_context.h"
1616

17-
#include <iostream>
1817
#include <thread>
18+
#include <utility>
1919

2020
#include "gtest/gtest.h"
2121
#include "opencensus/context/context.h"
@@ -45,7 +45,7 @@ TEST(WithContextTest, WithContextConditional) {
4545
#ifndef NDEBUG
4646
TEST(WithContextDeathTest, DestructorOnWrongThread) {
4747
opencensus::context::Context ctx = opencensus::context::Context::Current();
48-
EXPECT_DEATH_IF_SUPPORTED(
48+
EXPECT_DEBUG_DEATH(
4949
{
5050
auto* wc = new opencensus::context::WithContext(ctx);
5151
std::thread t([wc]() {

opencensus/exporters/stats/stackdriver/internal/stackdriver_e2e_test.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ StackdriverE2eTest::RetrieveData(
135135
}
136136
if (response.next_page_token().empty()) {
137137
break;
138-
} else {
139-
request.set_page_token(response.next_page_token());
140138
}
139+
request.set_page_token(response.next_page_token());
141140
}
142141
return data;
143142
}

opencensus/exporters/stats/stackdriver/internal/stackdriver_exporter.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <vector>
2222

2323
#include <grpcpp/grpcpp.h>
24+
#include "absl/memory/memory.h"
2425
#include "absl/strings/str_cat.h"
2526
#include "absl/strings/string_view.h"
2627
#include "absl/synchronization/mutex.h"

opencensus/exporters/stats/stdout/internal/stdout_exporter.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
#include "opencensus/exporters/stats/stdout/stdout_exporter.h"
1616

1717
#include <cstdint>
18-
#include <functional>
1918
#include <iostream>
19+
#include <memory>
20+
#include <string>
21+
#include <utility>
22+
#include <vector>
2023

2124
#include "absl/memory/memory.h"
2225
#include "absl/strings/str_cat.h"
@@ -30,7 +33,7 @@ namespace stats {
3033

3134
namespace {
3235

33-
// Functions to print data for different aggregation types.
36+
// Functions to format data for different aggregation types.
3437
std::string DataToString(double data) { return absl::StrCat(": ", data, "\n"); }
3538
std::string DataToString(int64_t data) {
3639
return absl::StrCat(": ", data, "\n");
@@ -47,7 +50,7 @@ std::string DataToString(const opencensus::stats::Distribution& data) {
4750

4851
class Handler : public opencensus::stats::StatsExporter::Handler {
4952
public:
50-
Handler(std::ostream* stream) : stream_(stream) {}
53+
explicit Handler(std::ostream* stream) : stream_(stream) {}
5154

5255
void ExportViewData(
5356
const std::vector<std::pair<opencensus::stats::ViewDescriptor,
@@ -91,7 +94,7 @@ void Handler::ExportViewDataImpl(
9194
const opencensus::stats::ViewDescriptor& descriptor, absl::Time start_time,
9295
absl::Time end_time,
9396
const opencensus::stats::ViewData::DataMap<DataValueT>& data) {
94-
if (data.size() == 0) {
97+
if (data.empty()) {
9598
*stream_ << absl::StrCat("No data for view \"", descriptor.name(),
9699
"\" from ", absl::FormatTime(start_time), ".\n\n");
97100
return;

0 commit comments

Comments
 (0)