Skip to content

Commit

Permalink
Fixed all lint errors (vesoft-inc#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
dutor authored Jan 18, 2019
1 parent db2300b commit c06b682
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/console/NebulaConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DEFINE_string(password, "", "Password used to authenticate");
int main(int argc, char *argv[]) {
folly::init(&argc, &argv, true);

using namespace nebula::graph;
using nebula::graph::CliManager;

CliManager cli;
if (!cli.connect(FLAGS_addr, FLAGS_port, FLAGS_username, FLAGS_password)) {
Expand Down
2 changes: 1 addition & 1 deletion src/meta/HostManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class HostManager final {
}

private:
HostManager(GraphSpaceID space) : space_(space) {}
explicit HostManager(GraphSpaceID space) : space_(space) {}

private:
static std::unordered_map<GraphSpaceID, std::shared_ptr<HostManager>> hostManagers_;
Expand Down
6 changes: 3 additions & 3 deletions src/raftex/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ DEFINE_uint32(max_outstanding_requests, 1024,
namespace nebula {
namespace raftex {

using namespace nebula::network;
using namespace nebula::thrift;
using nebula::network::NetworkUtils;
using nebula::thrift::ThriftClientManager;

Host::Host(const HostAddr& addr, std::shared_ptr<RaftPart> part)
: part_(std::move(part))
Expand Down Expand Up @@ -194,7 +194,7 @@ folly::Future<cpp2::AppendLogResponse> Host::appendLogsInternal(
}

cpp2::AppendLogResponse resp = std::move(t).value();
switch(resp.get_error_code()) {
switch (resp.get_error_code()) {
case cpp2::ErrorCode::SUCCEEDED: {
VLOG(2) << self->idStr_
<< "AppendLog request sent successfully";
Expand Down
26 changes: 13 additions & 13 deletions src/raftex/RaftPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ DEFINE_uint32(max_batch_size, 256, "The max number of logs in a batch");
namespace nebula {
namespace raftex {

using namespace nebula::network;
using namespace nebula::thrift;
using namespace nebula::thread;
using namespace nebula::wal;
using nebula::network::NetworkUtils;
using nebula::thrift::ThriftClientManager;
using nebula::wal::FileBasedWal;
using nebula::wal::FileBasedWalPolicy;
using nebula::wal::BufferFlusher;

class AppendLogsIterator final : public LogIterator {
public:
AppendLogsIterator(LogID firstLogId,
RaftPart::LogCache logs,
std::function<std::string (const std::string&)> casCB)
std::function<std::string(const std::string&)> casCB)
: firstLogId_(firstLogId)
, logId_(firstLogId)
, logs_(std::move(logs))
Expand Down Expand Up @@ -164,7 +165,7 @@ class AppendLogsIterator final : public LogIterator {
LogID firstLogId_;
LogID logId_;
RaftPart::LogCache logs_;
std::function<std::string (const std::string&)> casCB_;
std::function<std::string(const std::string&)> casCB_;
};


Expand Down Expand Up @@ -265,13 +266,13 @@ void RaftPart::stop() {
status_ = Status::STOPPED;

hosts = std::move(peerHosts_);
for (auto& h: *hosts) {
for (auto& h : *hosts) {
h.second->stop();
}
VLOG(2) << idStr_ << "Invoked stop() on all peer hosts";
}

for (auto& h: *hosts) {
for (auto& h : *hosts) {
VLOG(2) << idStr_ << "Waiting " << h.second->idStr() << " to stop";
h.second->waitForStop();
VLOG(2) << idStr_ << h.second->idStr() << "has stopped";
Expand Down Expand Up @@ -451,7 +452,7 @@ RaftPart::replicateLogs(
LogID committedId,
TermID prevLogTerm,
LogID prevLogId) {
using namespace folly;
using namespace folly; // NOLINT since the fancy overload of | operator

decltype(peerHosts_) hosts;
{
Expand Down Expand Up @@ -725,8 +726,7 @@ typename RaftPart::Role RaftPart::processElectionResponses(

bool RaftPart::leaderElection() {
VLOG(2) << idStr_ << "Start leader election...";
using namespace apache::thrift;
using namespace folly;
using namespace folly; // NOLINT since the fancy overload of | operator

cpp2::AskForVoteRequest voteReq;
if (!prepareElectionRequest(voteReq)) {
Expand Down Expand Up @@ -1153,7 +1153,7 @@ cpp2::ErrorCode RaftPart::verifyLeader(


folly::Future<RaftPart::AppendLogResult> RaftPart::sendHeartbeat() {
using namespace folly;
using namespace folly; // NOLINT since the fancy overload of | operator

VLOG(2) << idStr_ << "Sending heartbeat to all other hosts";

Expand Down Expand Up @@ -1237,7 +1237,7 @@ folly::Future<RaftPart::AppendLogResult> RaftPart::sendHeartbeat() {
CHECK(self->replicatingLogs_);
if (self->logs_.size() > 0) {
// continue to replicate the logs
self->sendingPromise_= std::move(self->cachingPromise_);
self->sendingPromise_ = std::move(self->cachingPromise_);
self->cachingPromise_.reset();
std::swap(swappedOutLogs, self->logs_);
firstId = lastLogId_ + 1;
Expand Down
2 changes: 1 addition & 1 deletion src/raftex/RaftPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace folly {
class IOThreadPoolExecutor;
class EventBase;
} // namespace folly;
} // namespace folly

namespace nebula {

Expand Down
2 changes: 0 additions & 2 deletions src/raftex/RaftexService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace nebula {
namespace raftex {

using namespace folly;

/*******************************************************
*
* Implementation of RaftexService
Expand Down
3 changes: 2 additions & 1 deletion src/raftex/test/LeaderElectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ int main(int argc, char** argv) {
folly::init(&argc, &argv, true);
google::SetStderrLogging(google::INFO);

using namespace nebula::raftex;
// `flusher' is extern-declared in RaftexTestBase.h, defined in RaftexTestBase.cpp
using nebula::raftex::flusher;
flusher = std::make_unique<nebula::wal::BufferFlusher>();

return RUN_ALL_TESTS();
Expand Down
3 changes: 2 additions & 1 deletion src/raftex/test/LogAppendTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ int main(int argc, char** argv) {
folly::init(&argc, &argv, true);
google::SetStderrLogging(google::INFO);

using namespace nebula::raftex;
// `flusher' is extern-declared in RaftexTestBase.h, defined in RaftexTestBase.cpp
using nebula::raftex::flusher;
flusher = std::make_unique<nebula::wal::BufferFlusher>();

return RUN_ALL_TESTS();
Expand Down
3 changes: 2 additions & 1 deletion src/raftex/test/LogCASTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ int main(int argc, char** argv) {
folly::init(&argc, &argv, true);
google::SetStderrLogging(google::INFO);

using namespace nebula::raftex;
// `flusher' is extern-declared in RaftexTestBase.h, defined in RaftexTestBase.cpp
using nebula::raftex::flusher;
flusher = std::make_unique<nebula::wal::BufferFlusher>();

return RUN_ALL_TESTS();
Expand Down
6 changes: 3 additions & 3 deletions src/raftex/test/RaftexTestBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
namespace nebula {
namespace raftex {

using namespace network;
using namespace fs;
using namespace wal;
using network::NetworkUtils;
using fs::FileUtils;
using wal::BufferFlusher;

std::unique_ptr<BufferFlusher> flusher;

Expand Down
2 changes: 1 addition & 1 deletion src/raftex/test/RaftexTestBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void checkLeadership(std::vector<std::shared_ptr<test::TestShard>>& copies,

class RaftexTestFixture : public ::testing::Test {
public:
RaftexTestFixture(const std::string& testName)
explicit RaftexTestFixture(const std::string& testName)
: testName_(testName) {}
~RaftexTestFixture() = default;

Expand Down
4 changes: 2 additions & 2 deletions src/raftex/test/TestShard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ TestShard::TestShard(size_t idx,
wal::BufferFlusher* flusher,
std::shared_ptr<folly::IOThreadPoolExecutor> ioPool,
std::shared_ptr<thread::GenericThreadPool> workers,
std::function<void (size_t idx, const char*, TermID)>
std::function<void(size_t idx, const char*, TermID)>
leadershipLostCB,
std::function<void (size_t idx, const char*, TermID)>
std::function<void(size_t idx, const char*, TermID)>
becomeLeaderCB)
: RaftPart(1, // clusterId
1, // spaceId
Expand Down
8 changes: 4 additions & 4 deletions src/raftex/test/TestShard.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class TestShard : public RaftPart {
wal::BufferFlusher* flusher,
std::shared_ptr<folly::IOThreadPoolExecutor> ioPool,
std::shared_ptr<thread::GenericThreadPool> workers,
std::function<void (size_t idx, const char*, TermID)>
std::function<void(size_t idx, const char*, TermID)>
leadershipLostCB,
std::function<void (size_t idx, const char*, TermID)>
std::function<void(size_t idx, const char*, TermID)>
becomeLeaderCB);

std::shared_ptr<RaftexService> getService() const {
Expand All @@ -56,9 +56,9 @@ class TestShard : public RaftPart {

std::unordered_map<LogID, std::string> data_;

std::function<void (size_t idx, const char*, TermID)>
std::function<void(size_t idx, const char*, TermID)>
leadershipLostCB_;
std::function<void (size_t idx, const char*, TermID)>
std::function<void(size_t idx, const char*, TermID)>
becomeLeaderCB_;
};

Expand Down
2 changes: 1 addition & 1 deletion src/storage/CompactionFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NebulaCompactionFilter final : public rocksdb::CompactionFilter {
return false;
}

const char* Name() const override {
const char* Name() const override {
return "NebulaCompactionFilter";
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/storage/QueryBaseProcessor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace storage {
template<typename REQ, typename RESP>
bool QueryBaseProcessor<REQ, RESP>::validOperation(cpp2::SupportedType vType,
cpp2::StatType statType) {
switch(statType) {
switch (statType) {
case cpp2::StatType::SUM:
case cpp2::StatType::AVG: {
return vType == cpp2::SupportedType::INT
Expand All @@ -43,7 +43,7 @@ void QueryBaseProcessor<REQ, RESP>::collectProps(
for (auto& prop : props) {
const auto& name = prop.prop_.get_name();
VLOG(3) << "collect " << name;
switch(prop.type_.type) {
switch (prop.type_.type) {
case cpp2::SupportedType::INT: {
int64_t v;
auto ret = reader.getInt<int64_t>(name, v);
Expand Down Expand Up @@ -78,8 +78,8 @@ void QueryBaseProcessor<REQ, RESP>::collectProps(
VLOG(1) << "Unsupport stats!";
break;
}
} // switch
} // for
} // switch
} // for
}

template<typename REQ, typename RESP>
Expand Down

0 comments on commit c06b682

Please sign in to comment.