diff --git a/.clang-tidy b/.clang-tidy index 59b47c4ba..32bcfb0a5 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,12 +5,14 @@ Checks: cert-*, modernize-*, -modernize-avoid-c-arrays, + -modernize-use-nodiscard, -modernize-use-trailing-return-type, performance-*, -performance-avoid-endl ' WarningsAsErrors: '*' -HeaderFilterRegex: '' +HeaderFilterRegex: '.*' +ExcludeHeaderFilterRegex: 'include/.*' UseColor: true FormatStyle: 'file' ExtraArgs: ['-std=c++17'] diff --git a/cpp/Ice/async/HelloI.h b/cpp/Ice/async/HelloI.h index a0ff6a90d..57f5e5dd3 100644 --- a/cpp/Ice/async/HelloI.h +++ b/cpp/Ice/async/HelloI.h @@ -12,9 +12,9 @@ class HelloI : public Demo::Hello { public: HelloI(const std::shared_ptr&); - virtual void - sayHelloAsync(int, std::function, std::function, const Ice::Current&); - virtual void shutdown(const Ice::Current&); + void + sayHelloAsync(int, std::function, std::function, const Ice::Current&) override; + void shutdown(const Ice::Current&) override; private: std::shared_ptr _workQueue; diff --git a/cpp/Ice/async/WorkQueue.cpp b/cpp/Ice/async/WorkQueue.cpp index 3fc170c06..eb8ab87cf 100644 --- a/cpp/Ice/async/WorkQueue.cpp +++ b/cpp/Ice/async/WorkQueue.cpp @@ -8,8 +8,6 @@ using namespace std; -WorkQueue::WorkQueue() : _done(false) {} - void WorkQueue::start() { diff --git a/cpp/Ice/async/WorkQueue.h b/cpp/Ice/async/WorkQueue.h index d9a0315f0..953ad788e 100644 --- a/cpp/Ice/async/WorkQueue.h +++ b/cpp/Ice/async/WorkQueue.h @@ -15,8 +15,6 @@ class WorkQueue { public: - WorkQueue(); - void run(); void add(int, std::function, std::function); @@ -31,7 +29,7 @@ class WorkQueue std::condition_variable _condition; std::list _callbacks; - bool _done; + bool _done{false}; std::thread _thread; }; diff --git a/cpp/Ice/asyncInvocation/CalculatorI.h b/cpp/Ice/asyncInvocation/CalculatorI.h index 861a4fa3d..4cd0771c9 100644 --- a/cpp/Ice/asyncInvocation/CalculatorI.h +++ b/cpp/Ice/asyncInvocation/CalculatorI.h @@ -10,12 +10,12 @@ class CalculatorI : public Demo::Calculator { public: - virtual int add(int, int, const Ice::Current&) override; - virtual int subtract(int, int, const Ice::Current&) override; - virtual int divide(int, int, int&, const Ice::Current&) override; - virtual int square(int, const Ice::Current&) override; - virtual double squareRoot(int, const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + int add(int, int, const Ice::Current&) override; + int subtract(int, int, const Ice::Current&) override; + int divide(int, int, int&, const Ice::Current&) override; + int square(int, const Ice::Current&) override; + double squareRoot(int, const Ice::Current&) override; + void shutdown(const Ice::Current&) override; }; #endif diff --git a/cpp/Ice/context/ContextI.h b/cpp/Ice/context/ContextI.h index 375d1addc..68cb0534d 100644 --- a/cpp/Ice/context/ContextI.h +++ b/cpp/Ice/context/ContextI.h @@ -10,8 +10,8 @@ class ContextI : public Demo::Context { public: - virtual void call(const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + void call(const Ice::Current&) override; + void shutdown(const Ice::Current&) override; }; #endif diff --git a/cpp/Ice/hello/HelloI.h b/cpp/Ice/hello/HelloI.h index 4d9fe917b..f82b52662 100644 --- a/cpp/Ice/hello/HelloI.h +++ b/cpp/Ice/hello/HelloI.h @@ -10,8 +10,8 @@ class HelloI : public Demo::Hello { public: - virtual void sayHello(int delay, const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + void sayHello(int delay, const Ice::Current&) override; + void shutdown(const Ice::Current&) override; }; #endif diff --git a/cpp/Ice/interceptor/AuthenticatorI.h b/cpp/Ice/interceptor/AuthenticatorI.h index ee2b3676d..663c8d7f1 100644 --- a/cpp/Ice/interceptor/AuthenticatorI.h +++ b/cpp/Ice/interceptor/AuthenticatorI.h @@ -15,7 +15,7 @@ class AuthenticatorI : public Demo::Authenticator { public: AuthenticatorI(); - virtual std::string getToken(const Ice::Current&) override; + std::string getToken(const Ice::Current&) override; void validateToken(const std::string&); private: diff --git a/cpp/Ice/interceptor/ThermostatI.h b/cpp/Ice/interceptor/ThermostatI.h index df9dde454..8aacf085b 100644 --- a/cpp/Ice/interceptor/ThermostatI.h +++ b/cpp/Ice/interceptor/ThermostatI.h @@ -11,9 +11,9 @@ class ThermostatI : public Demo::Thermostat { public: - virtual float getTemp(const Ice::Current&) override; - virtual void setTemp(float, const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + float getTemp(const Ice::Current&) override; + void setTemp(float, const Ice::Current&) override; + void shutdown(const Ice::Current&) override; private: // Temperature in Celsius. diff --git a/cpp/Ice/locator/HelloI.h b/cpp/Ice/locator/HelloI.h index cc3c37a8b..0719926f3 100644 --- a/cpp/Ice/locator/HelloI.h +++ b/cpp/Ice/locator/HelloI.h @@ -10,8 +10,8 @@ class HelloI : public Demo::Hello { public: - virtual void sayHello(const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + void sayHello(const Ice::Current&) override; + void shutdown(const Ice::Current&) override; }; #endif diff --git a/cpp/Ice/minimal/HelloI.h b/cpp/Ice/minimal/HelloI.h index 8800b5bf3..70284a59a 100644 --- a/cpp/Ice/minimal/HelloI.h +++ b/cpp/Ice/minimal/HelloI.h @@ -10,7 +10,7 @@ class HelloI : public Demo::Hello { public: - virtual void sayHello(const Ice::Current&) override; + void sayHello(const Ice::Current&) override; }; #endif diff --git a/cpp/Ice/session/SessionI.cpp b/cpp/Ice/session/SessionI.cpp index ef2d3fe14..7218ab477 100644 --- a/cpp/Ice/session/SessionI.cpp +++ b/cpp/Ice/session/SessionI.cpp @@ -26,7 +26,7 @@ class HelloI final : public Hello const int _id; }; -SessionI::SessionI(string name) : _name(std::move(name)), _nextId(0), _destroy(false) +SessionI::SessionI(string name) : _name(std::move(name)) { cout << "The session " << _name << " is now created." << endl; } diff --git a/cpp/Ice/session/SessionI.h b/cpp/Ice/session/SessionI.h index 8678a2675..cd0b55671 100644 --- a/cpp/Ice/session/SessionI.h +++ b/cpp/Ice/session/SessionI.h @@ -22,8 +22,8 @@ class SessionI final : public Demo::Session private: std::mutex _mutex; const std::string _name; - int _nextId; // The per-session id of the next hello object. This is used for tracing purposes. + int _nextId{0}; // The per-session id of the next hello object. This is used for tracing purposes. std::list> _objs; // List of per-session allocated hello objects. - bool _destroy; + bool _destroy{false}; }; #endif diff --git a/cpp/Ice/throughput/StringView.h b/cpp/Ice/throughput/StringView.h index b2dde428d..cac260c72 100644 --- a/cpp/Ice/throughput/StringView.h +++ b/cpp/Ice/throughput/StringView.h @@ -93,7 +93,7 @@ namespace Ice template static inline void read(S* stream, Util::string_view& v) { - const char* vdata = 0; + const char* vdata = nullptr; size_t vsize = 0; stream->read(vdata, vsize); diff --git a/cpp/Ice/throughput/ThroughputI.cpp b/cpp/Ice/throughput/ThroughputI.cpp index 38316242e..61b91bf1e 100644 --- a/cpp/Ice/throughput/ThroughputI.cpp +++ b/cpp/Ice/throughput/ThroughputI.cpp @@ -9,8 +9,7 @@ ThroughputI::ThroughputI() : _byteSeq(Demo::ByteSeqSize), _stringSeq(Demo::StringSeqSize, "hello"), _structSeq(Demo::StringDoubleSeqSize, {"hello", 3.14}), - _fixedSeq(Demo::FixedSeqSize, {0, 0, 0.0}), - _warmup(false) + _fixedSeq(Demo::FixedSeqSize, {0, 0, 0.0}) { } diff --git a/cpp/Ice/throughput/ThroughputI.h b/cpp/Ice/throughput/ThroughputI.h index 4cf5b64f3..4d028733f 100644 --- a/cpp/Ice/throughput/ThroughputI.h +++ b/cpp/Ice/throughput/ThroughputI.h @@ -40,7 +40,7 @@ class ThroughputI final : public Demo::Throughput Demo::StringDoubleSeq _structSeq; Demo::FixedSeq _fixedSeq; - bool _warmup; + bool _warmup{false}; }; #endif diff --git a/cpp/IceBox/hello/HelloI.h b/cpp/IceBox/hello/HelloI.h index 8800b5bf3..70284a59a 100644 --- a/cpp/IceBox/hello/HelloI.h +++ b/cpp/IceBox/hello/HelloI.h @@ -10,7 +10,7 @@ class HelloI : public Demo::Hello { public: - virtual void sayHello(const Ice::Current&) override; + void sayHello(const Ice::Current&) override; }; #endif diff --git a/cpp/IceBox/hello/HelloServiceI.h b/cpp/IceBox/hello/HelloServiceI.h index 19e1e1e17..3754948cd 100644 --- a/cpp/IceBox/hello/HelloServiceI.h +++ b/cpp/IceBox/hello/HelloServiceI.h @@ -10,9 +10,9 @@ class HelloServiceI : public IceBox::Service { public: - virtual void start(const std::string&, const std::shared_ptr&, const Ice::StringSeq&) override; + void start(const std::string&, const std::shared_ptr&, const Ice::StringSeq&) override; - virtual void stop() override; + void stop() override; private: std::shared_ptr _adapter; diff --git a/cpp/IceDiscovery/hello/HelloI.h b/cpp/IceDiscovery/hello/HelloI.h index 4d9fe917b..f82b52662 100644 --- a/cpp/IceDiscovery/hello/HelloI.h +++ b/cpp/IceDiscovery/hello/HelloI.h @@ -10,8 +10,8 @@ class HelloI : public Demo::Hello { public: - virtual void sayHello(int delay, const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + void sayHello(int delay, const Ice::Current&) override; + void shutdown(const Ice::Current&) override; }; #endif diff --git a/cpp/IceDiscovery/replication/HelloI.h b/cpp/IceDiscovery/replication/HelloI.h index 1491573e4..347b47dbc 100644 --- a/cpp/IceDiscovery/replication/HelloI.h +++ b/cpp/IceDiscovery/replication/HelloI.h @@ -12,8 +12,8 @@ class HelloI : public Demo::Hello public: HelloI(std::string); - virtual std::string getGreeting(const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + std::string getGreeting(const Ice::Current&) override; + void shutdown(const Ice::Current&) override; private: const std::string _name; diff --git a/cpp/IceGrid/allocate/HelloI.h b/cpp/IceGrid/allocate/HelloI.h index 125e4aac7..18cbd22a0 100644 --- a/cpp/IceGrid/allocate/HelloI.h +++ b/cpp/IceGrid/allocate/HelloI.h @@ -12,8 +12,8 @@ class HelloI : public Demo::Hello public: HelloI(std::string); - virtual void sayHello(const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + void sayHello(const Ice::Current&) override; + void shutdown(const Ice::Current&) override; private: const std::string _name; diff --git a/cpp/IceGrid/customLocator/HelloI.h b/cpp/IceGrid/customLocator/HelloI.h index 125e4aac7..18cbd22a0 100644 --- a/cpp/IceGrid/customLocator/HelloI.h +++ b/cpp/IceGrid/customLocator/HelloI.h @@ -12,8 +12,8 @@ class HelloI : public Demo::Hello public: HelloI(std::string); - virtual void sayHello(const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + void sayHello(const Ice::Current&) override; + void shutdown(const Ice::Current&) override; private: const std::string _name; diff --git a/cpp/IceGrid/icebox/HelloI.h b/cpp/IceGrid/icebox/HelloI.h index 3e054cce9..473687e10 100644 --- a/cpp/IceGrid/icebox/HelloI.h +++ b/cpp/IceGrid/icebox/HelloI.h @@ -12,7 +12,7 @@ class HelloI : public Demo::Hello public: HelloI(std::string); - virtual void sayHello(const Ice::Current&) override; + void sayHello(const Ice::Current&) override; private: const std::string _serviceName; diff --git a/cpp/IceGrid/icebox/HelloServiceI.h b/cpp/IceGrid/icebox/HelloServiceI.h index 19e1e1e17..3754948cd 100644 --- a/cpp/IceGrid/icebox/HelloServiceI.h +++ b/cpp/IceGrid/icebox/HelloServiceI.h @@ -10,9 +10,9 @@ class HelloServiceI : public IceBox::Service { public: - virtual void start(const std::string&, const std::shared_ptr&, const Ice::StringSeq&) override; + void start(const std::string&, const std::shared_ptr&, const Ice::StringSeq&) override; - virtual void stop() override; + void stop() override; private: std::shared_ptr _adapter; diff --git a/cpp/IceGrid/secure/HelloI.h b/cpp/IceGrid/secure/HelloI.h index 125e4aac7..18cbd22a0 100644 --- a/cpp/IceGrid/secure/HelloI.h +++ b/cpp/IceGrid/secure/HelloI.h @@ -12,8 +12,8 @@ class HelloI : public Demo::Hello public: HelloI(std::string); - virtual void sayHello(const Ice::Current&) override; - virtual void shutdown(const Ice::Current&) override; + void sayHello(const Ice::Current&) override; + void shutdown(const Ice::Current&) override; private: const std::string _name; diff --git a/cpp/IceStorm/counter/CounterObserverI.h b/cpp/IceStorm/counter/CounterObserverI.h index e4cafb9d1..9ac099a72 100644 --- a/cpp/IceStorm/counter/CounterObserverI.h +++ b/cpp/IceStorm/counter/CounterObserverI.h @@ -13,8 +13,8 @@ void print(const std::string&); class CounterObserverI : public Demo::CounterObserver { public: - virtual void init(int, const Ice::Current&) override; - virtual void inc(int, const Ice::Current&) override; + void init(int, const Ice::Current&) override; + void inc(int, const Ice::Current&) override; private: int _value = 0; diff --git a/cpp/Manual/simpleFilesystem/FilesystemI.h b/cpp/Manual/simpleFilesystem/FilesystemI.h index c75365e88..54919df75 100644 --- a/cpp/Manual/simpleFilesystem/FilesystemI.h +++ b/cpp/Manual/simpleFilesystem/FilesystemI.h @@ -2,8 +2,8 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#ifndef __FilesystemI_h__ -#define __FilesystemI_h__ +#ifndef FilesystemI_h +#define FilesystemI_h #include #include @@ -21,7 +21,7 @@ namespace Filesystem class NodeI : public virtual Node, public std::enable_shared_from_this { public: - virtual std::string name(const Ice::Current&) override; + std::string name(const Ice::Current&) override; NodeI(std::string, const std::shared_ptr&); void activate(const std::shared_ptr&);