This is an automated email from the ASF dual-hosted git repository. szaszm pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit e8c9a7c426fefc7517899ec52b2502da70ccc7e5 Author: Gabor Gyimesi <[email protected]> AuthorDate: Fri Oct 17 17:16:49 2025 +0200 MINIFICPP-2643 Fix clang tidy issues Closes #2040 Signed-off-by: Marton Szasz <[email protected]> --- .clang-tidy | 1 - core-framework/include/core/ClassLoader.h | 2 +- core-framework/include/core/ObjectFactory.h | 32 ++++++++++----------- core-framework/include/core/extension/Extension.h | 14 ++------- core-framework/include/io/BufferStream.h | 12 ++------ core-framework/include/utils/CollectionUtils.h | 12 ++------ core-framework/include/utils/IntervalSwitch.h | 12 ++------ core-framework/include/utils/JsonCallback.h | 12 ++------ core-framework/include/utils/MapUtils.h | 14 ++------- core-framework/include/utils/StringUtils.h | 6 ++-- core-framework/include/utils/TryMoveCall.h | 12 ++------ .../include/utils/crypto/ciphers/Aes256Ecb.h | 14 ++------- .../include/utils/requirements/Container.h | 12 ++------ .../utils/requirements/EqualityComparable.h | 12 ++------ .../utils/requirements/LegacyForwardIterator.h | 12 ++------ .../utils/requirements/LegacyInputIterator.h | 12 ++------ .../include/utils/requirements/LegacyIterator.h | 12 ++------ .../include/utils/requirements/Swappable.h | 12 ++------ core-framework/src/utils/FifoExecutor.cpp | 2 +- .../src/utils/crypto/ciphers/Aes256Ecb.cpp | 4 +-- core-framework/src/utils/net/AsioSocketUtils.cpp | 2 +- .../src/utils/net/NetworkInterfaceInfo.cpp | 6 ++-- encrypt-config/ConfigFile.h | 13 ++------- encrypt-config/ConfigFileEncryptor.cpp | 12 ++------ encrypt-config/ConfigFileEncryptor.h | 12 ++------ encrypt-config/Utils.h | 12 ++------ .../include/serialization/FlowFileSerializer.h | 10 ++----- .../include/serialization/FlowFileV3Serializer.h | 10 ++----- .../include/serialization/PayloadSerializer.h | 10 ++----- extension-framework/src/utils/net/TcpServer.cpp | 2 +- extensions/aws/AWSCredentialsProvider.h | 12 ++------ extensions/aws/utils/AWSInitializer.h | 14 ++------- .../azure/processors/FetchAzureBlobStorage.cpp | 5 ++-- extensions/expression-language/Driver.h | 12 ++------ extensions/expression-language/Expression.cpp | 5 ++-- extensions/expression-language/Parser.yy | 12 ++------ extensions/pdh/MemoryConsumptionCounter.h | 12 ++------ extensions/pdh/PDHCounters.cpp | 12 ++------ extensions/pdh/PDHCounters.h | 12 ++------ extensions/pdh/PerformanceDataCounter.h | 12 ++------ extensions/pdh/PerformanceDataMonitor.cpp | 12 ++------ extensions/pdh/PerformanceDataMonitor.h | 12 ++------ extensions/procfs/ProcessStat.cpp | 4 +-- extensions/python/PythonBindings.cpp | 4 +-- extensions/rocksdb-repos/ProvenanceRepository.cpp | 1 - extensions/rocksdb-repos/RocksDbStream.h | 12 ++------ extensions/rocksdb-repos/database/WriteBatch.cpp | 12 ++------ extensions/rocksdb-repos/database/WriteBatch.h | 13 ++------- extensions/sftp/tests/tools/SFTPTestServer.cpp | 4 +-- extensions/sql/data/SQLRowSubscriber.h | 12 ++------ extensions/systemd/Common.h | 9 ++---- extensions/windows-event-log/TailEventLog.h | 12 ++------ extensions/windows-event-log/wel/JSONUtils.h | 20 ++++--------- extensions/windows-event-log/wel/XMLString.h | 13 ++------- generateVersion.bat | 10 ++----- generateVersion.sh | 10 ++----- libminifi/include/c2/C2Protocol.h | 5 +--- libminifi/include/c2/C2Trigger.h | 5 +--- libminifi/include/c2/HeartbeatReporter.h | 5 +--- libminifi/include/c2/PayloadSerializer.h | 17 ++--------- libminifi/include/c2/protocols/RESTProtocol.h | 5 +--- .../include/controllers/ThreadManagementService.h | 5 +--- libminifi/include/core/extension/Executable.h | 14 ++------- libminifi/include/core/extension/Module.h | 14 ++------- .../include/core/logging/WindowsEventLogSink.h | 16 ++--------- .../core/logging/internal/CompressionManager.h | 16 ++--------- .../include/core/logging/internal/LogBuffer.h | 16 ++--------- libminifi/include/core/state/UpdatePolicy.h | 21 ++++---------- libminifi/include/io/AtomicEntryStream.h | 17 ++--------- libminifi/include/io/NetworkPrioritizer.h | 17 ++--------- libminifi/include/properties/Decryptor.h | 10 ++----- libminifi/include/utils/StagingQueue.h | 12 ++------ libminifi/include/utils/file/FileSystem.h | 14 ++------- libminifi/include/utils/tls/DistinguishedName.h | 14 ++------- libminifi/include/utils/tls/TLSUtils.h | 14 ++------- libminifi/src/c2/HeartbeatJsonSerializer.cpp | 3 +- libminifi/src/c2/PayloadSerializer.cpp | 12 ++------ .../controllers/UpdatePolicyControllerService.cpp | 2 -- libminifi/src/core/ClassLoader.cpp | 14 ++++----- libminifi/src/core/ParameterContext.cpp | 2 +- libminifi/src/core/ProcessGroup.cpp | 2 +- libminifi/src/core/ProcessSessionFactory.cpp | 12 ++------ libminifi/src/core/flow/CheckRequiredField.cpp | 4 +-- libminifi/src/core/logging/WindowsEventLogSink.cpp | 16 ++--------- .../src/core/logging/internal/LogCompressor.cpp | 17 ++--------- .../src/core/state/nodes/DeviceInformation.cpp | 3 +- .../src/core/state/nodes/RepositoryMetrics.cpp | 2 +- libminifi/src/io/AtomicEntryStream.cpp | 33 ---------------------- libminifi/src/utils/tls/DistinguishedName.cpp | 2 +- .../integration/OnScheduleErrorHandlingTests.cpp | 2 +- .../integration/ConnectionCountingServer.cpp | 6 ++-- .../libtest/integration/HTTPIntegrationBase.cpp | 4 ++- libminifi/test/libtest/unit/TestBase.cpp | 2 +- libminifi/test/libtest/unit/TestBase.h | 2 +- libminifi/test/libtest/unit/TestUtils.cpp | 2 +- libminifi/test/libtest/unit/TestUtils.h | 2 +- libminifi/test/schema-tests/SchemaTests.cpp | 2 +- libminifi/test/unit/BackTraceTests.cpp | 2 +- libminifi/test/unit/CertificateUtilsTests.cpp | 2 +- libminifi/test/unit/CronTests.cpp | 2 ++ libminifi/test/unit/HTTPStreamingCallbackTests.cpp | 2 +- libminifi/test/unit/IdTests.cpp | 1 + libminifi/test/unit/MapUtilsTests.cpp | 4 +-- libminifi/test/unit/NetworkInterfaceInfoTests.cpp | 2 +- libminifi/test/unit/RegexUtilsTests.cpp | 1 - libminifi/test/unit/SiteToSiteTests.cpp | 5 ++-- libminifi/test/unit/StringUtilsTests.cpp | 20 ++++++------- libminifi/test/unit/TimeUtilTests.cpp | 6 ++-- .../minifi-cpp/core/AgentIdentificationProvider.h | 12 ++------ minifi-api/include/minifi-cpp/core/Annotation.h | 14 ++------- minifi-api/include/minifi-cpp/core/ClassLoader.h | 4 +-- minifi-api/include/minifi-cpp/core/ObjectFactory.h | 4 +-- .../include/minifi-cpp/core/TraceableResource.h | 12 ++------ minifi-api/include/minifi-cpp/io/OutputStream.h | 12 ++------ 114 files changed, 235 insertions(+), 831 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3e7311914..9349f5989 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -244,7 +244,6 @@ Checks: > modernize-use-starts-ends-with, modernize-use-std-format, modernize-use-std-numbers, - modernize-use-std-print, performance-noexcept-destructor, performance-noexcept-swap, readability-ambiguous-smartptr-reset-call, diff --git a/core-framework/include/core/ClassLoader.h b/core-framework/include/core/ClassLoader.h index 1f1cb70a1..7786502be 100644 --- a/core-framework/include/core/ClassLoader.h +++ b/core-framework/include/core/ClassLoader.h @@ -37,7 +37,7 @@ std::unique_ptr<T> ClassLoader::instantiate(const std::string &class_name, const } template<class T> -T *ClassLoader::instantiateRaw(const std::string &class_name, const std::string &name) { +gsl::owner<T*> ClassLoader::instantiateRaw(const std::string &class_name, const std::string &name) { return dynamic_cast<T*>(instantiateRaw(class_name, name, [] (CoreComponent* obj) -> bool { return dynamic_cast<T*>(obj) != nullptr; })); diff --git a/core-framework/include/core/ObjectFactory.h b/core-framework/include/core/ObjectFactory.h index 434caee9e..e321a6a1e 100644 --- a/core-framework/include/core/ObjectFactory.h +++ b/core-framework/include/core/ObjectFactory.h @@ -23,11 +23,7 @@ #include "ClassName.h" #include "minifi-cpp/core/ObjectFactory.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { +namespace org::apache::nifi::minifi::core { class ObjectFactoryImpl : public ObjectFactory { public: @@ -76,17 +72,25 @@ class DefaultObjectFactory : public ObjectFactoryImpl { /** * Create a raw pointer to a new processor. */ - CoreComponent* createRaw(const std::string &name) override { - T *ptr = new T(name); - return dynamic_cast<CoreComponent*>(ptr); + gsl::owner<CoreComponent*> createRaw(const std::string &name) override { + const gsl::owner<T*> ptr = new T(name); + if (const auto converted = dynamic_cast<CoreComponent*>(ptr)) { + return converted; + } + delete ptr; + return nullptr; } /** * Create a raw pointer to a new processor. */ - CoreComponent* createRaw(const std::string &name, const utils::Identifier &uuid) override { - T *ptr = new T(name, uuid); - return dynamic_cast<CoreComponent*>(ptr); + gsl::owner<CoreComponent*> createRaw(const std::string &name, const utils::Identifier &uuid) override { + const gsl::owner<T*> ptr = new T(name, uuid); + if (const auto converted = dynamic_cast<CoreComponent*>(ptr)) { + return converted; + } + delete ptr; + return nullptr; } /** @@ -101,8 +105,4 @@ class DefaultObjectFactory : public ObjectFactoryImpl { std::string className; }; -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core diff --git a/core-framework/include/core/extension/Extension.h b/core-framework/include/core/extension/Extension.h index 55ee26b3d..73d437685 100644 --- a/core-framework/include/core/extension/Extension.h +++ b/core-framework/include/core/extension/Extension.h @@ -23,12 +23,7 @@ #include "minifi-cpp/core/extension/Extension.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace extension { +namespace org::apache::nifi::minifi::core::extension { class ExtensionImpl; @@ -96,9 +91,4 @@ class ExtensionInitializer { } \ }) -} // namespace extension -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core::extension diff --git a/core-framework/include/io/BufferStream.h b/core-framework/include/io/BufferStream.h index 340e7a9a0..dcddc9425 100644 --- a/core-framework/include/io/BufferStream.h +++ b/core-framework/include/io/BufferStream.h @@ -25,11 +25,7 @@ #include "BaseStream.h" #include "minifi-cpp/utils/gsl.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace io { +namespace org::apache::nifi::minifi::io { class BufferStream : public BaseStreamImpl { public: @@ -100,8 +96,4 @@ class BufferStream : public BaseStreamImpl { uint64_t readOffset_ = 0; }; -} // namespace io -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::io diff --git a/core-framework/include/utils/CollectionUtils.h b/core-framework/include/utils/CollectionUtils.h index 46b3f4f83..74957ff2f 100644 --- a/core-framework/include/utils/CollectionUtils.h +++ b/core-framework/include/utils/CollectionUtils.h @@ -20,11 +20,7 @@ #include <algorithm> #include <utility> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { namespace internal { @@ -52,8 +48,4 @@ bool haveCommonItem(const T& a, const U& b) { }); } -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/include/utils/IntervalSwitch.h b/core-framework/include/utils/IntervalSwitch.h index a776feb23..4931f4e44 100644 --- a/core-framework/include/utils/IntervalSwitch.h +++ b/core-framework/include/utils/IntervalSwitch.h @@ -23,11 +23,7 @@ #include "minifi-cpp/utils/gsl.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { enum class IntervalSwitchState { LOWER, @@ -67,8 +63,4 @@ class IntervalSwitch { IntervalSwitchState state_; }; -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/include/utils/JsonCallback.h b/core-framework/include/utils/JsonCallback.h index c455e6c34..37d922bd5 100644 --- a/core-framework/include/utils/JsonCallback.h +++ b/core-framework/include/utils/JsonCallback.h @@ -27,11 +27,7 @@ #include "io/StreamPipe.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { class JsonInputCallback { public: @@ -93,8 +89,4 @@ class PrettyJsonOutputCallback { std::optional<uint8_t> decimal_places_; }; -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/include/utils/MapUtils.h b/core-framework/include/utils/MapUtils.h index 55011d78d..50d5f5efd 100644 --- a/core-framework/include/utils/MapUtils.h +++ b/core-framework/include/utils/MapUtils.h @@ -18,12 +18,7 @@ #include <set> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { -namespace MapUtils { +namespace org::apache::nifi::minifi::utils::MapUtils { /** * Return a set of keys from a map @@ -37,9 +32,4 @@ std::set<T> getKeys(const Map<T, U>& m) { return keys; } -} /* namespace MapUtils */ -} /* namespace utils */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::utils::MapUtils diff --git a/core-framework/include/utils/StringUtils.h b/core-framework/include/utils/StringUtils.h index 8929f1123..30b2a1495 100644 --- a/core-framework/include/utils/StringUtils.h +++ b/core-framework/include/utils/StringUtils.h @@ -386,13 +386,13 @@ inline std::string to_base64(std::string_view str, bool url = false, bool padded std::string replaceMap(std::string source_string, const std::map<std::string, std::string> &replace_map); -constexpr std::pair<size_t, int> countOccurrences(std::string_view str, std::string_view pattern) { +constexpr std::pair<size_t, size_t> countOccurrences(std::string_view str, std::string_view pattern) { if (pattern.empty()) { - return {str.size(), gsl::narrow<int>(str.size() + 1)}; + return {str.size(), str.size() + 1}; } size_t last_pos = 0; - int occurrences = 0; + size_t occurrences = 0; for (size_t pos = 0; (pos = str.find(pattern, pos)) != std::string_view::npos; pos += pattern.size()) { last_pos = pos; ++occurrences; diff --git a/core-framework/include/utils/TryMoveCall.h b/core-framework/include/utils/TryMoveCall.h index 7f5a596a4..a430375d7 100644 --- a/core-framework/include/utils/TryMoveCall.h +++ b/core-framework/include/utils/TryMoveCall.h @@ -19,11 +19,7 @@ #include <type_traits> #include <utility> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { // TryMoveCall calls an // - unary function of a lvalue reference-type argument by passing a ref @@ -53,8 +49,4 @@ struct TryMoveCall<FunType, T, std::void_t<decltype(std::declval<FunType>()(std: template<typename Fun> static auto call(Fun&& fun, T& elem) -> decltype(std::forward<Fun>(fun)(std::move(elem))) { return std::forward<Fun>(fun)(std::move(elem)); } }; -} /* namespace utils */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/include/utils/crypto/ciphers/Aes256Ecb.h b/core-framework/include/utils/crypto/ciphers/Aes256Ecb.h index c45f1f37d..427c84cb4 100644 --- a/core-framework/include/utils/crypto/ciphers/Aes256Ecb.h +++ b/core-framework/include/utils/crypto/ciphers/Aes256Ecb.h @@ -25,12 +25,7 @@ #include "minifi-cpp/Exception.h" #include "minifi-cpp/core/logging/Logger.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { -namespace crypto { +namespace org::apache::nifi::minifi::utils::crypto { class CipherError : public Exception { public: @@ -68,9 +63,4 @@ class Aes256EcbCipher { const Bytes encryption_key_; }; -} // namespace crypto -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils::crypto diff --git a/core-framework/include/utils/requirements/Container.h b/core-framework/include/utils/requirements/Container.h index 62b7aeba5..59460f63a 100644 --- a/core-framework/include/utils/requirements/Container.h +++ b/core-framework/include/utils/requirements/Container.h @@ -24,11 +24,7 @@ #include "LegacyForwardIterator.h" #include "EqualityComparable.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { template<typename T> struct assert_container : @@ -70,8 +66,4 @@ struct assert_container : static_assert(std::is_convertible<decltype(std::declval<T&>().empty()), bool>::value, ""); }; -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/include/utils/requirements/EqualityComparable.h b/core-framework/include/utils/requirements/EqualityComparable.h index 8c41800d1..431622732 100644 --- a/core-framework/include/utils/requirements/EqualityComparable.h +++ b/core-framework/include/utils/requirements/EqualityComparable.h @@ -20,11 +20,7 @@ #include <type_traits> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { template<typename T, typename = void> struct is_equality_comparable : std::false_type {}; @@ -35,8 +31,4 @@ struct is_equality_comparable<T, std::is_convertible<decltype(std::declval<const T>() == std::declval<const T>()), bool>::value >::type> : std::true_type {}; -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/include/utils/requirements/LegacyForwardIterator.h b/core-framework/include/utils/requirements/LegacyForwardIterator.h index 389ce33c9..2a90b3ea4 100644 --- a/core-framework/include/utils/requirements/LegacyForwardIterator.h +++ b/core-framework/include/utils/requirements/LegacyForwardIterator.h @@ -21,11 +21,7 @@ #include <iterator> #include "LegacyInputIterator.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { template<typename T> struct assert_legacy_forward_iterator : assert_legacy_input_iterator<T> { @@ -39,8 +35,4 @@ struct assert_legacy_forward_iterator : assert_legacy_input_iterator<T> { static_assert(std::is_same<decltype(*std::declval<T>()++), typename std::iterator_traits<T>::reference>::value, "Expected a reference"); }; -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/include/utils/requirements/LegacyInputIterator.h b/core-framework/include/utils/requirements/LegacyInputIterator.h index d5a067574..2ede77b3a 100644 --- a/core-framework/include/utils/requirements/LegacyInputIterator.h +++ b/core-framework/include/utils/requirements/LegacyInputIterator.h @@ -23,11 +23,7 @@ #include "LegacyIterator.h" #include "EqualityComparable.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { template<typename T> struct assert_legacy_input_iterator : assert_legacy_iterator<T> { @@ -41,8 +37,4 @@ struct assert_legacy_input_iterator : assert_legacy_iterator<T> { using _ = decltype(true || (std::declval<const T>() != std::declval<const T>())); }; -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/include/utils/requirements/LegacyIterator.h b/core-framework/include/utils/requirements/LegacyIterator.h index fea38bb3b..bb55b016b 100644 --- a/core-framework/include/utils/requirements/LegacyIterator.h +++ b/core-framework/include/utils/requirements/LegacyIterator.h @@ -24,11 +24,7 @@ #include "utils/GeneralUtils.h" #include "Swappable.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { namespace detail { @@ -66,8 +62,4 @@ struct assert_legacy_iterator { using iterator_category = typename std::iterator_traits<T>::iterator_category; }; -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/include/utils/requirements/Swappable.h b/core-framework/include/utils/requirements/Swappable.h index 9369004eb..b291b2f28 100644 --- a/core-framework/include/utils/requirements/Swappable.h +++ b/core-framework/include/utils/requirements/Swappable.h @@ -21,11 +21,7 @@ #include <utility> #include "utils/GeneralUtils.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { namespace detail { @@ -73,8 +69,4 @@ struct is_swappable<T, detail::is_referenceable<T>::value >::type> : is_swappable_with<T&, T&> {}; -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/core-framework/src/utils/FifoExecutor.cpp b/core-framework/src/utils/FifoExecutor.cpp index f7bf0a807..0d485902f 100644 --- a/core-framework/src/utils/FifoExecutor.cpp +++ b/core-framework/src/utils/FifoExecutor.cpp @@ -28,7 +28,7 @@ WorkerThread::~WorkerThread() { void WorkerThread::run() noexcept { while (task_queue_.isRunning()) { - task_queue_.consumeWait([](std::packaged_task<void()>&& f) { f(); }); + task_queue_.consumeWait([](std::packaged_task<void()>& f) { f(); }); } } } // namespace org::apache::nifi::minifi::utils::detail diff --git a/core-framework/src/utils/crypto/ciphers/Aes256Ecb.cpp b/core-framework/src/utils/crypto/ciphers/Aes256Ecb.cpp index d7fc0425e..3daf0a4c8 100644 --- a/core-framework/src/utils/crypto/ciphers/Aes256Ecb.cpp +++ b/core-framework/src/utils/crypto/ciphers/Aes256Ecb.cpp @@ -79,7 +79,7 @@ void Aes256EcbCipher::encrypt(std::span<unsigned char, BLOCK_SIZE> data) const { } ciphertext_len += len; - gsl_Expects(ciphertext_len == BLOCK_SIZE); + gsl_Expects(gsl::narrow<size_t>(ciphertext_len) == BLOCK_SIZE); } void Aes256EcbCipher::decrypt(std::span<unsigned char, BLOCK_SIZE> data) const { @@ -111,7 +111,7 @@ void Aes256EcbCipher::decrypt(std::span<unsigned char, BLOCK_SIZE> data) const { } plaintext_len += len; - gsl_Expects(plaintext_len == BLOCK_SIZE); + gsl_Expects(gsl::narrow<size_t>(plaintext_len) == BLOCK_SIZE); } bool Aes256EcbCipher::operator==(const Aes256EcbCipher &other) const { diff --git a/core-framework/src/utils/net/AsioSocketUtils.cpp b/core-framework/src/utils/net/AsioSocketUtils.cpp index 36e7fd0af..2d3934d8e 100644 --- a/core-framework/src/utils/net/AsioSocketUtils.cpp +++ b/core-framework/src/utils/net/AsioSocketUtils.cpp @@ -81,7 +81,7 @@ bool AsioSocketConnection::connectTcpSocketOverSsl() { logger_->log_error("Connecting to host '{}' on port '{}' failed with the following message: '{}'", socket_data_.host, socket_data_.port, err.message()); return false; } - socket.handshake(asio::ssl::stream_base::client, err); + std::ignore = socket.handshake(asio::ssl::stream_base::client, err); if (err) { logger_->log_error("SSL handshake failed while connecting to host '{}' on port '{}' with the following message: '{}'", socket_data_.host, socket_data_.port, err.message()); return false; diff --git a/core-framework/src/utils/net/NetworkInterfaceInfo.cpp b/core-framework/src/utils/net/NetworkInterfaceInfo.cpp index bc1c1d0b1..f9295672e 100644 --- a/core-framework/src/utils/net/NetworkInterfaceInfo.cpp +++ b/core-framework/src/utils/net/NetworkInterfaceInfo.cpp @@ -131,7 +131,7 @@ std::vector<NetworkInterfaceInfo> NetworkInterfaceInfo::getNetworkInterfaceInfos } namespace { -void move_append(std::vector<std::string> &&source, std::vector<std::string> &destination) { +void move_append(std::vector<std::string>& source, std::vector<std::string>& destination) { destination.reserve(destination.size() + source.size()); std::move(std::begin(source), std::end(source), std::back_inserter(destination)); source.clear(); @@ -139,8 +139,8 @@ void move_append(std::vector<std::string> &&source, std::vector<std::string> &de } // namespace void NetworkInterfaceInfo::moveAddressesInto(NetworkInterfaceInfo& destination) { - move_append(std::move(ip_v4_addresses_), destination.ip_v4_addresses_); - move_append(std::move(ip_v6_addresses_), destination.ip_v6_addresses_); + move_append(ip_v4_addresses_, destination.ip_v4_addresses_); + move_append(ip_v6_addresses_, destination.ip_v6_addresses_); } } // namespace org::apache::nifi::minifi::utils diff --git a/encrypt-config/ConfigFile.h b/encrypt-config/ConfigFile.h index 634c9a89c..56079c9ff 100644 --- a/encrypt-config/ConfigFile.h +++ b/encrypt-config/ConfigFile.h @@ -22,11 +22,7 @@ #include "utils/crypto/EncryptionUtils.h" #include "properties/PropertiesFile.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace encrypt_config { +namespace org::apache::nifi::minifi::encrypt_config { class ConfigFile : public PropertiesFile { public: @@ -38,9 +34,4 @@ class ConfigFile : public PropertiesFile { friend bool operator==(const ConfigFile&, const ConfigFile&); }; -} // namespace encrypt_config -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org - +} // namespace org::apache::nifi::minifi::encrypt_config diff --git a/encrypt-config/ConfigFileEncryptor.cpp b/encrypt-config/ConfigFileEncryptor.cpp index 4e8d287f5..c5eacbbe9 100644 --- a/encrypt-config/ConfigFileEncryptor.cpp +++ b/encrypt-config/ConfigFileEncryptor.cpp @@ -23,11 +23,7 @@ #include "utils/StringUtils.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace encrypt_config { +namespace org::apache::nifi::minifi::encrypt_config { bool isEncrypted(const std::optional<std::string>& encryption_type) { return encryption_type && !encryption_type->empty() && *encryption_type != "plaintext"; @@ -82,8 +78,4 @@ uint32_t encryptSensitivePropertiesInFile(ConfigFile& config_file, const Encrypt return num_properties_encrypted; } -} // namespace encrypt_config -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::encrypt_config diff --git a/encrypt-config/ConfigFileEncryptor.h b/encrypt-config/ConfigFileEncryptor.h index aecd42f68..04941a4d2 100644 --- a/encrypt-config/ConfigFileEncryptor.h +++ b/encrypt-config/ConfigFileEncryptor.h @@ -20,18 +20,10 @@ #include "utils/crypto/EncryptionUtils.h" #include "Utils.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace encrypt_config { +namespace org::apache::nifi::minifi::encrypt_config { uint32_t encryptSensitivePropertiesInFile(ConfigFile& config_file, const utils::crypto::Bytes& encryption_key); uint32_t encryptSensitivePropertiesInFile(ConfigFile& config_file, const EncryptionKeys& keys); -} // namespace encrypt_config -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::encrypt_config diff --git a/encrypt-config/Utils.h b/encrypt-config/Utils.h index fd645e2af..e4609af03 100644 --- a/encrypt-config/Utils.h +++ b/encrypt-config/Utils.h @@ -20,19 +20,11 @@ #include "utils/crypto/EncryptionUtils.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace encrypt_config { +namespace org::apache::nifi::minifi::encrypt_config { struct EncryptionKeys { std::optional<utils::crypto::Bytes> old_key; utils::crypto::Bytes encryption_key; }; -} // namespace encrypt_config -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::encrypt_config diff --git a/extension-framework/include/serialization/FlowFileSerializer.h b/extension-framework/include/serialization/FlowFileSerializer.h index e8a612799..85362931f 100644 --- a/extension-framework/include/serialization/FlowFileSerializer.h +++ b/extension-framework/include/serialization/FlowFileSerializer.h @@ -23,10 +23,7 @@ #include <functional> #include "minifi-cpp/io/StreamCallback.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { +namespace org::apache::nifi::minifi { namespace io { class OutputStream; @@ -53,7 +50,4 @@ class FlowFileSerializer { FlowFileReader reader_; }; -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi diff --git a/extension-framework/include/serialization/FlowFileV3Serializer.h b/extension-framework/include/serialization/FlowFileV3Serializer.h index 656422a89..64c9ce691 100644 --- a/extension-framework/include/serialization/FlowFileV3Serializer.h +++ b/extension-framework/include/serialization/FlowFileV3Serializer.h @@ -24,10 +24,7 @@ #include "io/OutputStream.h" #include "FlowFileSerializer.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { +namespace org::apache::nifi::minifi { class FlowFileV3Serializer : public FlowFileSerializer { static constexpr uint8_t MAGIC_HEADER[] = {'N', 'i', 'F', 'i', 'F', 'F', '3'}; @@ -44,7 +41,4 @@ class FlowFileV3Serializer : public FlowFileSerializer { int64_t serialize(const std::shared_ptr<core::FlowFile>& flowFile, const std::shared_ptr<io::OutputStream>& out) override; }; -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi diff --git a/extension-framework/include/serialization/PayloadSerializer.h b/extension-framework/include/serialization/PayloadSerializer.h index e1089a7e8..b6f843ca5 100644 --- a/extension-framework/include/serialization/PayloadSerializer.h +++ b/extension-framework/include/serialization/PayloadSerializer.h @@ -22,10 +22,7 @@ #include "minifi-cpp/io/OutputStream.h" #include "FlowFileSerializer.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { +namespace org::apache::nifi::minifi { class PayloadSerializer : public FlowFileSerializer { public: @@ -34,7 +31,4 @@ class PayloadSerializer : public FlowFileSerializer { int64_t serialize(const std::shared_ptr<core::FlowFile>& flowFile, const std::shared_ptr<io::OutputStream>& out) override; }; -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi diff --git a/extension-framework/src/utils/net/TcpServer.cpp b/extension-framework/src/utils/net/TcpServer.cpp index 651c55ed8..1c51fa265 100644 --- a/extension-framework/src/utils/net/TcpServer.cpp +++ b/extension-framework/src/utils/net/TcpServer.cpp @@ -107,7 +107,7 @@ asio::awaitable<void> TcpServer::secureSession(asio::ip::tcp::socket socket, asi co_await readLoop(ssl_socket, remote_address, local_port); // NOLINT asio::error_code ec; - ssl_socket.lowest_layer().cancel(ec); + std::ignore = ssl_socket.lowest_layer().cancel(ec); if (ec) { logger_->log_error("Cancelling asynchronous operations of SSL socket failed with: {}", ec.message()); } diff --git a/extensions/aws/AWSCredentialsProvider.h b/extensions/aws/AWSCredentialsProvider.h index 302a8407d..9dcafcc37 100644 --- a/extensions/aws/AWSCredentialsProvider.h +++ b/extensions/aws/AWSCredentialsProvider.h @@ -27,11 +27,7 @@ #include "minifi-cpp/core/logging/Logger.h" #include "core/logging/LoggerFactory.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace aws { +namespace org::apache::nifi::minifi::aws { class AWSCredentialsProvider { public: @@ -56,8 +52,4 @@ class AWSCredentialsProvider { std::shared_ptr<core::logging::Logger> logger_{core::logging::LoggerFactory<AWSCredentialsProvider>::getLogger()}; }; -} // namespace aws -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::aws diff --git a/extensions/aws/utils/AWSInitializer.h b/extensions/aws/utils/AWSInitializer.h index 34b3f2f38..dc0aab0e3 100755 --- a/extensions/aws/utils/AWSInitializer.h +++ b/extensions/aws/utils/AWSInitializer.h @@ -32,12 +32,7 @@ #undef GetObject // windows.h #defines GetObject = GetObjectA or GetObjectW, which conflicts with rapidjson #endif -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace aws { -namespace utils { +namespace org::apache::nifi::minifi::aws::utils { class AWSInitializer { public: @@ -50,9 +45,4 @@ class AWSInitializer { Aws::SDKOptions options_; }; -} /* namespace utils */ -} /* namespace aws */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::aws::utils diff --git a/extensions/azure/processors/FetchAzureBlobStorage.cpp b/extensions/azure/processors/FetchAzureBlobStorage.cpp index fa0a065f2..b96da5b5c 100644 --- a/extensions/azure/processors/FetchAzureBlobStorage.cpp +++ b/extensions/azure/processors/FetchAzureBlobStorage.cpp @@ -39,14 +39,13 @@ std::optional<storage::FetchAzureBlobStorageParameters> FetchAzureBlobStorage::b return std::nullopt; } - std::string value; if (auto range_start = utils::parseOptionalU64Property(context, RangeStart, &flow_file)) { - params.range_start = *range_start; + params.range_start = range_start; logger_->log_debug("Range Start property set to {}", *params.range_start); } if (auto range_length = utils::parseOptionalU64Property(context, RangeLength, &flow_file)) { - params.range_length = *range_length; + params.range_length = range_length; logger_->log_debug("Range Length property set to {}", *params.range_length); } diff --git a/extensions/expression-language/Driver.h b/extensions/expression-language/Driver.h index c04d78c41..6d511dd7e 100644 --- a/extensions/expression-language/Driver.h +++ b/extensions/expression-language/Driver.h @@ -29,11 +29,7 @@ #define YY_DECL int org::apache::nifi::minifi::expression::Driver::lex(org::apache::nifi::minifi::expression::Parser::semantic_type* yylval, \ org::apache::nifi::minifi::expression::Parser::location_type* yylloc) -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace expression { +namespace org::apache::nifi::minifi::expression { class Driver : public yyFlexLexer { public: @@ -50,8 +46,4 @@ class Driver : public yyFlexLexer { Expression result; }; -} /* namespace expression */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::expression diff --git a/extensions/expression-language/Expression.cpp b/extensions/expression-language/Expression.cpp index cb3d03de3..7a6cc8308 100644 --- a/extensions/expression-language/Expression.cpp +++ b/extensions/expression-language/Expression.cpp @@ -387,13 +387,13 @@ Value expr_getDelimitedField(const std::vector<Value> &args) { Value expr_startsWith(const std::vector<Value> &args) { const std::string &arg_0 = args[0].asString(); const std::string &arg_1 = args[1].asString(); - return Value(arg_0.substr(0, arg_1.length()) == arg_1); + return Value(arg_0.starts_with(arg_1)); } Value expr_endsWith(const std::vector<Value> &args) { const std::string &arg_0 = args[0].asString(); const std::string &arg_1 = args[1].asString(); - return Value(arg_0.substr(arg_0.length() - arg_1.length()) == arg_1); + return Value(arg_0.ends_with(arg_1)); } Value expr_contains(const std::vector<Value> &args) { @@ -633,7 +633,6 @@ Value expr_format(const std::vector<Value> &args) { using std::chrono::milliseconds; date::sys_time<milliseconds> utc_time_point{milliseconds(args[0].asUnsignedLong())}; - auto format_string = args[1].asString(); auto zone = args.size() > 2 ? date::locate_zone(args[2].asString()) : date::current_zone(); auto zoned_time_point = date::make_zoned(zone, utc_time_point); diff --git a/extensions/expression-language/Parser.yy b/extensions/expression-language/Parser.yy index 3a1f4d67a..17b98200f 100644 --- a/extensions/expression-language/Parser.yy +++ b/extensions/expression-language/Parser.yy @@ -38,17 +38,9 @@ #undef S_FALSE // winerror.h #defines S_FALSE, which conflicts with the generated token #endif - namespace org { - namespace apache { - namespace nifi { - namespace minifi { - namespace expression { + namespace org::apache::nifi::minifi::expression { class Driver; - } /* namespace expression */ - } /* namespace minifi */ - } /* namespace nifi */ - } /* namespace apache */ - } /* namespace org */ + } // namespace org::apache::nifi::minifi::expression } %code diff --git a/extensions/pdh/MemoryConsumptionCounter.h b/extensions/pdh/MemoryConsumptionCounter.h index f04fbccb0..93c60d353 100644 --- a/extensions/pdh/MemoryConsumptionCounter.h +++ b/extensions/pdh/MemoryConsumptionCounter.h @@ -21,11 +21,7 @@ #include <string> #include "utils/OsUtils.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace processors { +namespace org::apache::nifi::minifi::processors { class MemoryConsumptionCounter : public PerformanceDataCounter { public: @@ -63,8 +59,4 @@ class MemoryConsumptionCounter : public PerformanceDataCounter { int64_t available_physical_memory_; int64_t total_paging_file_size_; }; -} // namespace processors -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::processors diff --git a/extensions/pdh/PDHCounters.cpp b/extensions/pdh/PDHCounters.cpp index 34fbfe7a3..e83e11ad0 100644 --- a/extensions/pdh/PDHCounters.cpp +++ b/extensions/pdh/PDHCounters.cpp @@ -19,11 +19,7 @@ #include "PDHCounters.h" #include "utils/StringUtils.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace processors { +namespace org::apache::nifi::minifi::processors { DWORD PDHCounter::getDWFormat() const { return is_double_format_ ? PDH_FMT_DOUBLE : PDH_FMT_LARGE; @@ -125,8 +121,4 @@ rapidjson::Value PDHCounterArray::getValue(const DWORD i) const { return value; } -} // namespace processors -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::processors diff --git a/extensions/pdh/PDHCounters.h b/extensions/pdh/PDHCounters.h index 2a0d3e72a..26a8e6545 100644 --- a/extensions/pdh/PDHCounters.h +++ b/extensions/pdh/PDHCounters.h @@ -25,11 +25,7 @@ #include "PerformanceDataCounter.h" #include <memory> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace processors { +namespace org::apache::nifi::minifi::processors { class PDHCounter : public PerformanceDataCounter { public: @@ -92,8 +88,4 @@ class PDHCounterArray : public PDHCounter { }; -} // namespace processors -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::processors diff --git a/extensions/pdh/PerformanceDataCounter.h b/extensions/pdh/PerformanceDataCounter.h index 8962451e9..841d51285 100644 --- a/extensions/pdh/PerformanceDataCounter.h +++ b/extensions/pdh/PerformanceDataCounter.h @@ -20,11 +20,7 @@ #include "rapidjson/document.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace processors { +namespace org::apache::nifi::minifi::processors { class PerformanceDataCounter { public: @@ -45,8 +41,4 @@ class PerformanceDataCounter { } }; -} // namespace processors -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::processors diff --git a/extensions/pdh/PerformanceDataMonitor.cpp b/extensions/pdh/PerformanceDataMonitor.cpp index 6f8055a41..0b57a6067 100644 --- a/extensions/pdh/PerformanceDataMonitor.cpp +++ b/extensions/pdh/PerformanceDataMonitor.cpp @@ -28,11 +28,7 @@ #include "core/ProcessSession.h" #include "core/Resource.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace processors { +namespace org::apache::nifi::minifi::processors { PerformanceDataMonitor::~PerformanceDataMonitor() { PdhCloseQuery(pdh_query_); @@ -297,8 +293,4 @@ void PerformanceDataMonitor::setupMembersFromProperties(core::ProcessContext& co REGISTER_RESOURCE(PerformanceDataMonitor, Processor); -} // namespace processors -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::processors diff --git a/extensions/pdh/PerformanceDataMonitor.h b/extensions/pdh/PerformanceDataMonitor.h index 274d4a977..9c3b082e7 100644 --- a/extensions/pdh/PerformanceDataMonitor.h +++ b/extensions/pdh/PerformanceDataMonitor.h @@ -36,11 +36,7 @@ #include "PerformanceDataCounter.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace processors { +namespace org::apache::nifi::minifi::processors { class PerformanceDataMonitor final : public core::ProcessorImpl { public: @@ -128,8 +124,4 @@ class PerformanceDataMonitor final : public core::ProcessorImpl { std::vector<std::unique_ptr<PerformanceDataCounter>> resource_consumption_counters_; }; -} // namespace processors -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::processors diff --git a/extensions/procfs/ProcessStat.cpp b/extensions/procfs/ProcessStat.cpp index 900c92c3c..2f9c72941 100644 --- a/extensions/procfs/ProcessStat.cpp +++ b/extensions/procfs/ProcessStat.cpp @@ -34,8 +34,8 @@ std::optional<ProcessStatData> ProcessStatData::parseProcessStatFile(std::istrea size_t comm_end = stat_stream_string.find_last_of(')'); if (comm_start == std::string::npos || comm_end == std::string::npos) return std::nullopt; - process_stat_data.comm_ = stat_stream_string.substr(comm_start+1, comm_end-comm_start-1); - stat_stream.seekg(comm_end+2); // seek to the start of the next field (after the space that follows (<comm>)) + process_stat_data.comm_ = stat_stream_string.substr(comm_start + 1, comm_end-comm_start - 1); + stat_stream.seekg(gsl::narrow<std::streampos>(comm_end + 2)); // seek to the start of the next field (after the space that follows (<comm>)) stat_stream >> process_stat_data.state_ >> process_stat_data.ppid_ >> process_stat_data.pgrp_ >> process_stat_data.session_ >> process_stat_data.tty_nr_ >> process_stat_data.tpgid_ >> process_stat_data.flags_ >> process_stat_data.minflt_ >> process_stat_data.cminflt_ >> process_stat_data.majflt_ >> process_stat_data.cmajflt_ >> process_stat_data.utime_ diff --git a/extensions/python/PythonBindings.cpp b/extensions/python/PythonBindings.cpp index 873188faf..8895c4a94 100644 --- a/extensions/python/PythonBindings.cpp +++ b/extensions/python/PythonBindings.cpp @@ -54,7 +54,7 @@ struct PyModuleDef minifi_module = { PyMODINIT_FUNC PyInit_minifi_native(void) { - const std::array types = std::to_array<std::pair<PyTypeObject*, std::string_view>>({ + const std::array types = std::to_array<std::pair<PyTypeObject*, std::string>>({ std::make_pair(PyLogger::typeObject(), "Logger"), std::make_pair(PyProcessSessionObject::typeObject(), "ProcessSession"), std::make_pair(PyProcessContext::typeObject(), "ProcessContext"), @@ -83,7 +83,7 @@ PyInit_minifi_native(void) { for (const auto& type : types) { Py_INCREF(type.first); } - const auto result = std::all_of(std::begin(types), std::end(types), [&](std::pair<PyTypeObject*, std::string_view> type) { + const auto result = std::all_of(std::begin(types), std::end(types), [&](const std::pair<PyTypeObject*, std::string>& type) { return PyModule_AddObject(minifi_module_instance, type.second.data(), reinterpret_cast<PyObject*>(type.first)) == 0; }); diff --git a/extensions/rocksdb-repos/ProvenanceRepository.cpp b/extensions/rocksdb-repos/ProvenanceRepository.cpp index 9b5571fc0..bd4ae8260 100644 --- a/extensions/rocksdb-repos/ProvenanceRepository.cpp +++ b/extensions/rocksdb-repos/ProvenanceRepository.cpp @@ -87,7 +87,6 @@ bool ProvenanceRepository::getElements(std::vector<std::shared_ptr<core::Seriali if (max_size >= requested_batch) break; auto eventRead = ProvenanceEventRecord::create(); - std::string key = it->key().ToString(); io::BufferStream stream(gsl::make_span(it->value()).as_span<const std::byte>()); if (eventRead->deserialize(stream)) { max_size++; diff --git a/extensions/rocksdb-repos/RocksDbStream.h b/extensions/rocksdb-repos/RocksDbStream.h index 1076f0b51..d5c52b024 100644 --- a/extensions/rocksdb-repos/RocksDbStream.h +++ b/extensions/rocksdb-repos/RocksDbStream.h @@ -25,11 +25,7 @@ #include "io/BaseStream.h" #include "core/logging/LoggerFactory.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace io { +namespace org::apache::nifi::minifi::io { /** * Purpose: File Stream Base stream extension. This is intended to be a thread safe access to @@ -96,8 +92,4 @@ class RocksDbStream : public io::BaseStreamImpl { std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<RocksDbStream>::getLogger(); }; -} /* namespace io */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::io diff --git a/extensions/rocksdb-repos/database/WriteBatch.cpp b/extensions/rocksdb-repos/database/WriteBatch.cpp index 785edb1b9..3fe1dd3ad 100644 --- a/extensions/rocksdb-repos/database/WriteBatch.cpp +++ b/extensions/rocksdb-repos/database/WriteBatch.cpp @@ -18,11 +18,7 @@ #include "WriteBatch.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace internal { +namespace org::apache::nifi::minifi::internal { rocksdb::Status WriteBatch::Put(const rocksdb::Slice &key, const rocksdb::Slice &value) { return impl_.Put(column_, key, value); @@ -36,8 +32,4 @@ rocksdb::Status WriteBatch::Merge(const rocksdb::Slice &key, const rocksdb::Slic return impl_.Merge(column_, key, value); } -} // namespace internal -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::internal diff --git a/extensions/rocksdb-repos/database/WriteBatch.h b/extensions/rocksdb-repos/database/WriteBatch.h index 65e925b88..b4c2412ba 100644 --- a/extensions/rocksdb-repos/database/WriteBatch.h +++ b/extensions/rocksdb-repos/database/WriteBatch.h @@ -20,11 +20,7 @@ #include "rocksdb/db.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace internal { +namespace org::apache::nifi::minifi::internal { class WriteBatch { friend class OpenRocksDb; @@ -38,9 +34,4 @@ class WriteBatch { rocksdb::ColumnFamilyHandle* column_; }; -} // namespace internal -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org - +} // namespace org::apache::nifi::minifi::internal diff --git a/extensions/sftp/tests/tools/SFTPTestServer.cpp b/extensions/sftp/tests/tools/SFTPTestServer.cpp index 387be14cd..e74249b8e 100644 --- a/extensions/sftp/tests/tools/SFTPTestServer.cpp +++ b/extensions/sftp/tests/tools/SFTPTestServer.cpp @@ -99,7 +99,7 @@ bool SFTPTestServer::start() { for (size_t i = 0; i < 15; i++) { std::ifstream port_file(port_file_path_); if (port_file.is_open() && port_file.good()) { - uint16_t port; + uint16_t port = 0; if (port_file >> port) { port_ = port; started_ = true; @@ -128,7 +128,7 @@ bool SFTPTestServer::stop() { logger_->log_error("Failed to kill child process, error: {}", strerror(errno)); return false; } - int wstatus; + int wstatus = 0; if (::waitpid(server_pid_, &wstatus, 0) == -1) { logger_->log_error("Failed to waitpid for child process, error: {}", strerror(errno)); return false; diff --git a/extensions/sql/data/SQLRowSubscriber.h b/extensions/sql/data/SQLRowSubscriber.h index 94614468e..d870a8673 100644 --- a/extensions/sql/data/SQLRowSubscriber.h +++ b/extensions/sql/data/SQLRowSubscriber.h @@ -21,11 +21,7 @@ #include <string> #include <vector> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace sql { +namespace org::apache::nifi::minifi::sql { struct SQLRowSubscriber { virtual ~SQLRowSubscriber() = default; @@ -44,8 +40,4 @@ struct SQLRowSubscriber { virtual void processColumn(const std::string& name, const char* value) = 0; }; -} /* namespace sql */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::sql diff --git a/extensions/systemd/Common.h b/extensions/systemd/Common.h index 73d90a281..8d8bf1bee 100644 --- a/extensions/systemd/Common.h +++ b/extensions/systemd/Common.h @@ -18,13 +18,8 @@ #pragma once -namespace org { namespace apache { namespace nifi { namespace minifi { namespace extensions { namespace systemd { +namespace org::apache::nifi::minifi::extensions::systemd { enum class JournalType { User, System, Both }; -} // namespace systemd -} // namespace extensions -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::extensions::systemd diff --git a/extensions/windows-event-log/TailEventLog.h b/extensions/windows-event-log/TailEventLog.h index 9ba18378e..db7e81e84 100644 --- a/extensions/windows-event-log/TailEventLog.h +++ b/extensions/windows-event-log/TailEventLog.h @@ -32,11 +32,7 @@ #include "core/PropertyDefinitionBuilder.h" #include "minifi-cpp/core/RelationshipDefinition.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace processors { +namespace org::apache::nifi::minifi::processors { #define MAX_RECORD_BUFFER_SIZE 0x10000 // 64k const LPCWSTR pEventTypeNames[] = { L"Error", L"Warning", L"Informational", L"Audit Success", L"Audit Failure" }; @@ -129,8 +125,4 @@ class TailEventLog : public core::ProcessorImpl { HANDLE log_handle_; }; -} /* namespace processors */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::processors diff --git a/extensions/windows-event-log/wel/JSONUtils.h b/extensions/windows-event-log/wel/JSONUtils.h index 5e5b43f25..119f2da3c 100644 --- a/extensions/windows-event-log/wel/JSONUtils.h +++ b/extensions/windows-event-log/wel/JSONUtils.h @@ -24,11 +24,7 @@ #include "rapidjson/document.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace wel { +namespace org::apache::nifi::minifi::wel { /** * * !!WARNING!! The json document must not outlive the xml argument. For better performance, @@ -62,14 +58,14 @@ rapidjson::Document toSimpleJSON(const pugi::xml_node& root); * Flattens most of the structure, i.e. removes intermediate * objects and lifts innermost string-valued keys to the root. * e.g. {System: {Provider: {Name: String}}} => {Name: String} - * + * * Moreover it also flattens each named data element where the - * name does not conflict with already existing members + * name does not conflict with already existing members * (e.g. a data with name "Guid" won't be flattened as it would * overwrite the existing "Guid" field). - * + * * e.g. {EventData: [{Name: "Test", Content: "X"}]} => {Test: "X"} - * + * * In order to mitigate data loss, it preserves the EventData * array in its entirety as well. * (otherwise a "Guid" data would be lost) @@ -78,8 +74,4 @@ rapidjson::Document toFlattenedJSON(const pugi::xml_node& root); std::string jsonToString(const rapidjson::Document& doc); -} // namespace wel -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::wel diff --git a/extensions/windows-event-log/wel/XMLString.h b/extensions/windows-event-log/wel/XMLString.h index b8d53117c..6995fb44c 100644 --- a/extensions/windows-event-log/wel/XMLString.h +++ b/extensions/windows-event-log/wel/XMLString.h @@ -37,11 +37,7 @@ #include "pugixml.hpp" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace wel { +namespace org::apache::nifi::minifi::wel { class XmlString : public pugi::xml_writer { public: @@ -52,9 +48,4 @@ class XmlString : public pugi::xml_writer { } }; -} /* namespace wel */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ - +} // namespace org::apache::nifi::minifi::wel diff --git a/generateVersion.bat b/generateVersion.bat index 8b11dd7ca..0f46da4e9 100644 --- a/generateVersion.bat +++ b/generateVersion.bat @@ -49,10 +49,7 @@ for %%i in (%extensions%) do ( echo #include ^<vector^> echo #include "minifi-cpp/agent/agent_version.h" - echo namespace org { - echo namespace apache { - echo namespace nifi { - echo namespace minifi { + echo namespace org::apache::nifi::minifi { echo const char* const AgentBuild::VERSION = "%version%"; echo const char* const AgentBuild::BUILD_IDENTIFIER = "%buildident%"; @@ -79,10 +76,7 @@ for %%i in (%extensions%) do ( echo return extensions; echo } - echo } /* namespace minifi */ - echo } /* namespace nifi */ - echo } /* namespace apache */ - echo } /* namespace org */ + echo } // namespace org::apache::nifi::minifi ) >> "%out_dir%/agent_version.cpp" goto :EOF diff --git a/generateVersion.sh b/generateVersion.sh index 78ceb2687..0977e3553 100755 --- a/generateVersion.sh +++ b/generateVersion.sh @@ -60,10 +60,7 @@ cat >"$out_dir/agent_version.cpp" <<EOF #include <vector> #include "minifi-cpp/agent/agent_version.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { +namespace org::apache::nifi::minifi { const char* const AgentBuild::VERSION = "$version"; const char* const AgentBuild::BUILD_IDENTIFIER = "$buildident"; @@ -91,9 +88,6 @@ cat <<EOF >> "$out_dir/agent_version.cpp" return extensions; } -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi EOF diff --git a/libminifi/include/c2/C2Protocol.h b/libminifi/include/c2/C2Protocol.h index 18c7e9894..87de2220d 100644 --- a/libminifi/include/c2/C2Protocol.h +++ b/libminifi/include/c2/C2Protocol.h @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_C2_C2PROTOCOL_H_ -#define LIBMINIFI_INCLUDE_C2_C2PROTOCOL_H_ +#pragma once #include <memory> #include <string> @@ -111,5 +110,3 @@ class C2Protocol : public core::ConnectableImpl { }; } // namespace org::apache::nifi::minifi::c2 - -#endif // LIBMINIFI_INCLUDE_C2_C2PROTOCOL_H_ diff --git a/libminifi/include/c2/C2Trigger.h b/libminifi/include/c2/C2Trigger.h index eb774a650..7db6c4004 100644 --- a/libminifi/include/c2/C2Trigger.h +++ b/libminifi/include/c2/C2Trigger.h @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_C2_C2TRIGGER_H_ -#define LIBMINIFI_INCLUDE_C2_C2TRIGGER_H_ +#pragma once #include <memory> #include <utility> @@ -71,5 +70,3 @@ class C2Trigger : public core::ConnectableImpl { }; } // namespace org::apache::nifi::minifi::c2 - -#endif // LIBMINIFI_INCLUDE_C2_C2TRIGGER_H_ diff --git a/libminifi/include/c2/HeartbeatReporter.h b/libminifi/include/c2/HeartbeatReporter.h index b9b85a109..cd866db23 100644 --- a/libminifi/include/c2/HeartbeatReporter.h +++ b/libminifi/include/c2/HeartbeatReporter.h @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_C2_HEARTBEATREPORTER_H_ -#define LIBMINIFI_INCLUDE_C2_HEARTBEATREPORTER_H_ +#pragma once #include <memory> #include <string> @@ -89,5 +88,3 @@ class HeartbeatReporter : public core::ConnectableImpl { }; } // namespace org::apache::nifi::minifi::c2 - -#endif // LIBMINIFI_INCLUDE_C2_HEARTBEATREPORTER_H_ diff --git a/libminifi/include/c2/PayloadSerializer.h b/libminifi/include/c2/PayloadSerializer.h index 097aa9773..35590c072 100644 --- a/libminifi/include/c2/PayloadSerializer.h +++ b/libminifi/include/c2/PayloadSerializer.h @@ -16,8 +16,7 @@ * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_C2_PAYLOADSERIALIZER_H_ -#define LIBMINIFI_INCLUDE_C2_PAYLOADSERIALIZER_H_ +#pragma once #include <memory> #include <string> @@ -31,11 +30,7 @@ #include "io/BufferStream.h" #include "minifi-cpp/utils/gsl.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace c2 { +namespace org::apache::nifi::minifi::c2 { class PayloadSerializer { public: @@ -333,10 +328,4 @@ class PayloadSerializer { virtual ~PayloadSerializer(); }; -} // namespace c2 -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org - -#endif // LIBMINIFI_INCLUDE_C2_PAYLOADSERIALIZER_H_ +} // namespace org::apache::nifi::minifi::c2 diff --git a/libminifi/include/c2/protocols/RESTProtocol.h b/libminifi/include/c2/protocols/RESTProtocol.h index 8f45f7de2..35e3b57a6 100644 --- a/libminifi/include/c2/protocols/RESTProtocol.h +++ b/libminifi/include/c2/protocols/RESTProtocol.h @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_C2_PROTOCOLS_RESTPROTOCOL_H_ -#define LIBMINIFI_INCLUDE_C2_PROTOCOLS_RESTPROTOCOL_H_ +#pragma once #include <map> #include <memory> @@ -56,5 +55,3 @@ class RESTProtocol : public HeartbeatJsonSerializer { }; } // namespace org::apache::nifi::minifi::c2 - -#endif // LIBMINIFI_INCLUDE_C2_PROTOCOLS_RESTPROTOCOL_H_ diff --git a/libminifi/include/controllers/ThreadManagementService.h b/libminifi/include/controllers/ThreadManagementService.h index bd13a99b6..6dba08434 100644 --- a/libminifi/include/controllers/ThreadManagementService.h +++ b/libminifi/include/controllers/ThreadManagementService.h @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_CONTROLLERS_THREADMANAGEMENTSERVICE_H_ -#define LIBMINIFI_INCLUDE_CONTROLLERS_THREADMANAGEMENTSERVICE_H_ +#pragma once #include <iostream> #include <string> @@ -81,5 +80,3 @@ class ThreadManagementServiceImpl : public core::controller::ControllerServiceIm }; } // namespace org::apache::nifi::minifi::controllers - -#endif // LIBMINIFI_INCLUDE_CONTROLLERS_THREADMANAGEMENTSERVICE_H_ diff --git a/libminifi/include/core/extension/Executable.h b/libminifi/include/core/extension/Executable.h index 29ef191b1..f6f59c6c9 100644 --- a/libminifi/include/core/extension/Executable.h +++ b/libminifi/include/core/extension/Executable.h @@ -19,12 +19,7 @@ #include "Module.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace extension { +namespace org::apache::nifi::minifi::core::extension { class Executable : public Module { public: @@ -32,9 +27,4 @@ class Executable : public Module { ~Executable() override = default; }; -} // namespace extension -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core::extension diff --git a/libminifi/include/core/extension/Module.h b/libminifi/include/core/extension/Module.h index f531b4114..2b39e010b 100644 --- a/libminifi/include/core/extension/Module.h +++ b/libminifi/include/core/extension/Module.h @@ -26,12 +26,7 @@ #include "properties/Configure.h" #include "minifi-cpp/core/extension/Extension.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace extension { +namespace org::apache::nifi::minifi::core::extension { /** * Represents an initializable component of the agent. @@ -63,9 +58,4 @@ class Module { static std::shared_ptr<logging::Logger> logger_; }; -} // namespace extension -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core::extension diff --git a/libminifi/include/core/logging/WindowsEventLogSink.h b/libminifi/include/core/logging/WindowsEventLogSink.h index 10f4581f6..ded240b2c 100644 --- a/libminifi/include/core/logging/WindowsEventLogSink.h +++ b/libminifi/include/core/logging/WindowsEventLogSink.h @@ -29,13 +29,7 @@ #include "spdlog/details/null_mutex.h" #include "spdlog/sinks/base_sink.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace logging { -namespace internal { +namespace org::apache::nifi::minifi::core::logging::internal { class windowseventlog_sink : public spdlog::sinks::base_sink<spdlog::details::null_mutex> { private: @@ -59,12 +53,6 @@ class windowseventlog_sink : public spdlog::sinks::base_sink<spdlog::details::nu windowseventlog_sink& operator=(windowseventlog_sink&&) = delete; }; -} // namespace internal -} // namespace logging -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core::logging::internal #endif diff --git a/libminifi/include/core/logging/internal/CompressionManager.h b/libminifi/include/core/logging/internal/CompressionManager.h index 669480905..e768fdbe1 100644 --- a/libminifi/include/core/logging/internal/CompressionManager.h +++ b/libminifi/include/core/logging/internal/CompressionManager.h @@ -34,13 +34,7 @@ class LoggerTestAccessor; -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace logging { -namespace internal { +namespace org::apache::nifi::minifi::core::logging::internal { class CompressionManager { friend class ::LoggerTestAccessor; @@ -76,10 +70,4 @@ class CompressionManager { std::shared_ptr<LogCompressorSink> sink_; }; -} // namespace internal -} // namespace logging -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core::logging::internal diff --git a/libminifi/include/core/logging/internal/LogBuffer.h b/libminifi/include/core/logging/internal/LogBuffer.h index bfc63eba2..2180bcddc 100644 --- a/libminifi/include/core/logging/internal/LogBuffer.h +++ b/libminifi/include/core/logging/internal/LogBuffer.h @@ -23,13 +23,7 @@ #include "io/BufferStream.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace logging { -namespace internal { +namespace org::apache::nifi::minifi::core::logging::internal { class LogBuffer { public: @@ -53,10 +47,4 @@ class LogBuffer { std::unique_ptr<io::BufferStream> buffer_; }; -} // namespace internal -} // namespace logging -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core::logging::internal diff --git a/libminifi/include/core/state/UpdatePolicy.h b/libminifi/include/core/state/UpdatePolicy.h index 8e9eae419..9fa9b12b9 100644 --- a/libminifi/include/core/state/UpdatePolicy.h +++ b/libminifi/include/core/state/UpdatePolicy.h @@ -15,19 +15,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_CORE_STATE_UPDATEPOLICY_H_ -#define LIBMINIFI_INCLUDE_CORE_STATE_UPDATEPOLICY_H_ +#pragma once #include <memory> #include <string> #include <utility> #include <unordered_map> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace state { +namespace org::apache::nifi::minifi::state { enum UPDATE_POLICY { PERM_ALLOWED, @@ -94,7 +89,7 @@ class UpdatePolicy { class UpdatePolicyBuilder { public: static std::unique_ptr<UpdatePolicyBuilder> newBuilder(bool enable_all = false) { - std::unique_ptr<UpdatePolicyBuilder> policy = std::unique_ptr<UpdatePolicyBuilder>( new UpdatePolicyBuilder(enable_all)); + std::unique_ptr<UpdatePolicyBuilder> policy = std::unique_ptr<UpdatePolicyBuilder>( new UpdatePolicyBuilder(enable_all)); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) return policy; } @@ -107,7 +102,7 @@ class UpdatePolicyBuilder { } std::unique_ptr<UpdatePolicy> build() { - std::unique_ptr<UpdatePolicy> new_policy = std::unique_ptr<UpdatePolicy>(new UpdatePolicy(*(current_policy_.get()))); + std::unique_ptr<UpdatePolicy> new_policy = std::unique_ptr<UpdatePolicy>(new UpdatePolicy(*(current_policy_.get()))); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) return new_policy; } @@ -122,10 +117,4 @@ class UpdatePolicyBuilder { std::shared_ptr<UpdatePolicy> current_policy_; }; -} // namespace state -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org - -#endif // LIBMINIFI_INCLUDE_CORE_STATE_UPDATEPOLICY_H_ +} // namespace org::apache::nifi::minifi::state diff --git a/libminifi/include/io/AtomicEntryStream.h b/libminifi/include/io/AtomicEntryStream.h index f43fed659..eb30227e7 100644 --- a/libminifi/include/io/AtomicEntryStream.h +++ b/libminifi/include/io/AtomicEntryStream.h @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_IO_ATOMICENTRYSTREAM_H_ -#define LIBMINIFI_INCLUDE_IO_ATOMICENTRYSTREAM_H_ +#pragma once #include <memory> #include <vector> @@ -30,11 +29,7 @@ #include "core/logging/LoggerFactory.h" #include "minifi-cpp/utils/gsl.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace io { +namespace org::apache::nifi::minifi::io { template<typename T> class AtomicEntryStream : public BaseStreamImpl { @@ -158,10 +153,4 @@ size_t AtomicEntryStream<T>::read(std::span<std::byte> buf) { return STREAM_ERROR; } -} // namespace io -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org - -#endif // LIBMINIFI_INCLUDE_IO_ATOMICENTRYSTREAM_H_ +} // namespace org::apache::nifi::minifi::io diff --git a/libminifi/include/io/NetworkPrioritizer.h b/libminifi/include/io/NetworkPrioritizer.h index 7ccf0fd15..8f755d1fc 100644 --- a/libminifi/include/io/NetworkPrioritizer.h +++ b/libminifi/include/io/NetworkPrioritizer.h @@ -15,19 +15,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_IO_NETWORKPRIORITIZER_H_ -#define LIBMINIFI_INCLUDE_IO_NETWORKPRIORITIZER_H_ +#pragma once #include <string> #include <iostream> #include <memory> #include <utility> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace io { +namespace org::apache::nifi::minifi::io { class NetworkInterface; @@ -105,10 +100,4 @@ class NetworkPrioritizerFactory { std::shared_ptr<NetworkPrioritizer> np_; }; -} // namespace io -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org - -#endif // LIBMINIFI_INCLUDE_IO_NETWORKPRIORITIZER_H_ +} // namespace org::apache::nifi::minifi::io diff --git a/libminifi/include/properties/Decryptor.h b/libminifi/include/properties/Decryptor.h index 822d338e0..8caa65df2 100644 --- a/libminifi/include/properties/Decryptor.h +++ b/libminifi/include/properties/Decryptor.h @@ -23,10 +23,7 @@ #include "utils/crypto/EncryptionUtils.h" #include "utils/crypto/EncryptionProvider.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { +namespace org::apache::nifi::minifi { class Decryptor { public: @@ -50,7 +47,4 @@ class Decryptor { const utils::crypto::EncryptionProvider provider_; }; -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi diff --git a/libminifi/include/utils/StagingQueue.h b/libminifi/include/utils/StagingQueue.h index f0dc3b8b3..7f63ab8c2 100644 --- a/libminifi/include/utils/StagingQueue.h +++ b/libminifi/include/utils/StagingQueue.h @@ -22,11 +22,7 @@ #include <utility> #include "utils/MinifiConcurrentQueue.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { +namespace org::apache::nifi::minifi::utils { namespace internal { template<typename T> @@ -183,8 +179,4 @@ class StagingQueue { ConditionConcurrentQueue<Item> queue_; }; -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils diff --git a/libminifi/include/utils/file/FileSystem.h b/libminifi/include/utils/file/FileSystem.h index 828e6262a..0c4bc1bea 100644 --- a/libminifi/include/utils/file/FileSystem.h +++ b/libminifi/include/utils/file/FileSystem.h @@ -23,12 +23,7 @@ #include "utils/crypto/EncryptionProvider.h" #include "core/logging/LoggerFactory.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { -namespace file { +namespace org::apache::nifi::minifi::utils::file { class FileSystem { public: @@ -49,9 +44,4 @@ class FileSystem { std::shared_ptr<core::logging::Logger> logger_{core::logging::LoggerFactory<FileSystem>::getLogger()}; }; -} // namespace file -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils::file diff --git a/libminifi/include/utils/tls/DistinguishedName.h b/libminifi/include/utils/tls/DistinguishedName.h index c122092ce..7fe0323af 100644 --- a/libminifi/include/utils/tls/DistinguishedName.h +++ b/libminifi/include/utils/tls/DistinguishedName.h @@ -21,12 +21,7 @@ #include <utility> #include <vector> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { -namespace tls { +namespace org::apache::nifi::minifi::utils::tls { class DistinguishedName { public: @@ -44,9 +39,4 @@ class DistinguishedName { std::vector<std::string> components_; }; -} // namespace tls -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils::tls diff --git a/libminifi/include/utils/tls/TLSUtils.h b/libminifi/include/utils/tls/TLSUtils.h index d8abd89ff..c56c5c7ec 100644 --- a/libminifi/include/utils/tls/TLSUtils.h +++ b/libminifi/include/utils/tls/TLSUtils.h @@ -20,18 +20,8 @@ #include <atomic> #include <cstdint> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace utils { -namespace tls { +namespace org::apache::nifi::minifi::utils::tls { int pemPassWordCb(char *buf, int size, int rwflag, void *userdata); -} // namespace tls -} // namespace utils -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::utils::tls diff --git a/libminifi/src/c2/HeartbeatJsonSerializer.cpp b/libminifi/src/c2/HeartbeatJsonSerializer.cpp index 1b937715c..1cddcd1c8 100644 --- a/libminifi/src/c2/HeartbeatJsonSerializer.cpp +++ b/libminifi/src/c2/HeartbeatJsonSerializer.cpp @@ -28,7 +28,8 @@ namespace org::apache::nifi::minifi::c2 { static void serializeOperationInfo(rapidjson::Value& target, const C2Payload& payload, rapidjson::Document::AllocatorType& alloc) { gsl_Expects(target.IsObject()); - target.AddMember("operation", rapidjson::Value(magic_enum::enum_name<Operation>(payload.getOperation()).data(), alloc), alloc); + // magic_enum::enum_name() returns a string_view that is a null-terminated string literal + target.AddMember("operation", rapidjson::Value(magic_enum::enum_name<Operation>(payload.getOperation()).data(), alloc), alloc); // NOLINT(bugprone-suspicious-stringview-data-usage) std::string id = payload.getIdentifier(); if (id.empty()) { diff --git a/libminifi/src/c2/PayloadSerializer.cpp b/libminifi/src/c2/PayloadSerializer.cpp index fa7713e50..a5d5d0441 100644 --- a/libminifi/src/c2/PayloadSerializer.cpp +++ b/libminifi/src/c2/PayloadSerializer.cpp @@ -17,18 +17,10 @@ */ #include "c2/PayloadSerializer.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace c2 { +namespace org::apache::nifi::minifi::c2 { PayloadSerializer::PayloadSerializer() = default; PayloadSerializer::~PayloadSerializer() = default; -} /* namespace c2 */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::c2 diff --git a/libminifi/src/controllers/UpdatePolicyControllerService.cpp b/libminifi/src/controllers/UpdatePolicyControllerService.cpp index a011bdbef..a4edd2668 100644 --- a/libminifi/src/controllers/UpdatePolicyControllerService.cpp +++ b/libminifi/src/controllers/UpdatePolicyControllerService.cpp @@ -51,8 +51,6 @@ bool UpdatePolicyControllerService::isWorkAvailable() { } void UpdatePolicyControllerService::onEnable() { - std::string persistStr; - const bool enable_all = (getProperty(AllowAllProperties.name) | utils::andThen(parsing::parseBool)).value_or(false); persist_updates_ = (getProperty(PersistUpdates.name) | utils::andThen(parsing::parseBool)).value_or(false); diff --git a/libminifi/src/core/ClassLoader.cpp b/libminifi/src/core/ClassLoader.cpp index 4f3c8d344..67d241f9d 100644 --- a/libminifi/src/core/ClassLoader.cpp +++ b/libminifi/src/core/ClassLoader.cpp @@ -53,7 +53,7 @@ class ClassLoaderImpl : public ClassLoader { [[nodiscard]] std::unique_ptr<CoreComponent> instantiate(const std::string &class_name, const std::string &name, const utils::Identifier &uuid, std::function<bool(CoreComponent*)> filter) override; - [[nodiscard]] CoreComponent* instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) override; + [[nodiscard]] gsl::owner<CoreComponent*> instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) override; ~ClassLoaderImpl() override = default; @@ -116,13 +116,13 @@ class ProcessorFactoryWrapper : public ObjectFactoryImpl { return std::unique_ptr<CoreComponent>{createRaw(name, uuid)}; } - [[nodiscard]] CoreComponent* createRaw(const std::string &name) override { + [[nodiscard]] gsl::owner<CoreComponent*> createRaw(const std::string &name) override { return createRaw(name, utils::IdGenerator::getIdGenerator()->generate()); } - [[nodiscard]] CoreComponent* createRaw(const std::string &name, const utils::Identifier &uuid) override { + [[nodiscard]] gsl::owner<CoreComponent*> createRaw(const std::string &name, const utils::Identifier &uuid) override { auto logger = logging::LoggerFactoryBase::getAliasedLogger(getClassName(), uuid); - return new Processor(name, uuid, factory_->create({.uuid = uuid, .name = name, .logger = logger})); // NOLINT(cppcoreguidelines-owning-memory) + return new Processor(name, uuid, factory_->create({.uuid = uuid, .name = name, .logger = std::move(logger)})); } [[nodiscard]] std::string getGroupName() const override { @@ -146,7 +146,6 @@ void ClassLoaderImpl::unregisterClass(const std::string& clazz) { std::lock_guard<std::mutex> lock(internal_mutex_); if (loaded_factories_.erase(clazz) == 0) { logger_->log_error("Could not unregister non-registered class '{}' at '{}'", clazz, name_); - return; } else { logger_->log_trace("Unregistered class '{}' at '{}'", clazz, name_); } @@ -221,11 +220,11 @@ std::unique_ptr<CoreComponent> ClassLoaderImpl::instantiate(const std::string &c return nullptr; } -CoreComponent* ClassLoaderImpl::instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) { +gsl::owner<CoreComponent*> ClassLoaderImpl::instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) { std::lock_guard<std::mutex> lock(internal_mutex_); // allow subsequent classes to override functionality (like ProcessContextBuilder) for (auto& child_loader : class_loaders_) { - if (auto* result = child_loader.second.instantiateRaw(class_name, name, filter)) { + if (gsl::owner<CoreComponent*> result = child_loader.second.instantiateRaw(class_name, name, filter)) { return result; } } @@ -235,6 +234,7 @@ CoreComponent* ClassLoaderImpl::instantiateRaw(const std::string &class_name, co if (filter(obj)) { return obj; } + delete obj; } return nullptr; } diff --git a/libminifi/src/core/ParameterContext.cpp b/libminifi/src/core/ParameterContext.cpp index 460507c92..9e175266f 100644 --- a/libminifi/src/core/ParameterContext.cpp +++ b/libminifi/src/core/ParameterContext.cpp @@ -20,7 +20,7 @@ namespace org::apache::nifi::minifi::core { void ParameterContext::addParameter(const Parameter ¶meter) { - if (parameters_.find(parameter.name) != parameters_.end()) { + if (parameters_.contains(parameter.name)) { throw ParameterException("Parameter name '" + parameter.name + "' already exists, parameter names must be unique within a parameter context!"); } parameters_.emplace(parameter.name, parameter); diff --git a/libminifi/src/core/ProcessGroup.cpp b/libminifi/src/core/ProcessGroup.cpp index 254f4ca20..d8e8ea066 100644 --- a/libminifi/src/core/ProcessGroup.cpp +++ b/libminifi/src/core/ProcessGroup.cpp @@ -109,7 +109,7 @@ void ProcessGroup::addPort(std::unique_ptr<Port> port) { void ProcessGroup::addProcessGroup(std::unique_ptr<ProcessGroup> child) { std::lock_guard<std::recursive_mutex> lock(mutex_); - if (child_process_groups_.find(child) == child_process_groups_.end()) { + if (!child_process_groups_.contains(child)) { // We do not have the same child process group in this process group yet logger_->log_debug("Add child process group {} into process group {}", child->getName(), name_); child_process_groups_.emplace(std::move(child)); diff --git a/libminifi/src/core/ProcessSessionFactory.cpp b/libminifi/src/core/ProcessSessionFactory.cpp index 148a3f4fd..d4f6c6d7b 100644 --- a/libminifi/src/core/ProcessSessionFactory.cpp +++ b/libminifi/src/core/ProcessSessionFactory.cpp @@ -21,18 +21,10 @@ #include "core/ProcessSessionFactory.h" #include <memory> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { +namespace org::apache::nifi::minifi::core { std::shared_ptr<ProcessSession> ProcessSessionFactoryImpl::createSession() { return std::make_shared<ProcessSessionImpl>(process_context_); } -} /* namespace core */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::core diff --git a/libminifi/src/core/flow/CheckRequiredField.cpp b/libminifi/src/core/flow/CheckRequiredField.cpp index eab0b1b36..600ad4f75 100644 --- a/libminifi/src/core/flow/CheckRequiredField.cpp +++ b/libminifi/src/core/flow/CheckRequiredField.cpp @@ -50,7 +50,7 @@ void checkRequiredField(const Node &node, const std::vector<std::string>& field_ if (error_message.empty()) { throw std::invalid_argument(buildErrorMessage(node, field_names)); } - throw std::invalid_argument(error_message.data()); + throw std::invalid_argument(std::string{error_message}); } } @@ -63,7 +63,7 @@ std::string getRequiredField(const Node &node, const std::vector<std::string> &a if (error_message.empty()) { throw std::invalid_argument(buildErrorMessage(node, alternate_names)); } - throw std::invalid_argument(error_message.data()); + throw std::invalid_argument(std::string{error_message}); } } // namespace org::apache::nifi::minifi::core::flow diff --git a/libminifi/src/core/logging/WindowsEventLogSink.cpp b/libminifi/src/core/logging/WindowsEventLogSink.cpp index b9c512345..a211fce35 100644 --- a/libminifi/src/core/logging/WindowsEventLogSink.cpp +++ b/libminifi/src/core/logging/WindowsEventLogSink.cpp @@ -28,13 +28,7 @@ #include "spdlog/sinks/sink.h" #include "spdlog/details/log_msg.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace logging { -namespace internal { +namespace org::apache::nifi::minifi::core::logging::internal { WORD windowseventlog_sink::type_from_level(const spdlog::details::log_msg& msg) const { switch (static_cast<int>(msg.level)) { @@ -82,12 +76,6 @@ windowseventlog_sink::~windowseventlog_sink() { } } -} // namespace internal -} // namespace logging -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core::logging::internal #endif diff --git a/libminifi/src/core/logging/internal/LogCompressor.cpp b/libminifi/src/core/logging/internal/LogCompressor.cpp index 4dd23c090..560e26b01 100644 --- a/libminifi/src/core/logging/internal/LogCompressor.cpp +++ b/libminifi/src/core/logging/internal/LogCompressor.cpp @@ -19,13 +19,7 @@ #include "core/logging/internal/LogCompressor.h" #include "core/logging/LoggerConfiguration.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace logging { -namespace internal { +namespace org::apache::nifi::minifi::core::logging::internal { LogCompressor::LogCompressor(gsl::not_null<OutputStream *> output, std::shared_ptr<logging::Logger> logger) : ZlibCompressStream(output, io::ZlibCompressionFormat::GZIP, Z_DEFAULT_COMPRESSION, std::move(logger)) {} @@ -37,11 +31,4 @@ LogCompressor::FlushResult LogCompressor::flush() { return FlushResult::Error; } -} // namespace internal -} // namespace logging -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org - +} // namespace org::apache::nifi::minifi::core::logging::internal diff --git a/libminifi/src/core/state/nodes/DeviceInformation.cpp b/libminifi/src/core/state/nodes/DeviceInformation.cpp index d1b2d4aab..6468b93b9 100644 --- a/libminifi/src/core/state/nodes/DeviceInformation.cpp +++ b/libminifi/src/core/state/nodes/DeviceInformation.cpp @@ -54,10 +54,9 @@ Device::Device() { canonical_hostname_ = hostname.data(); - std::stringstream ips; auto ipaddressess = getIpAddresses(); for (const auto& ip : ipaddressess) { - if (ipaddressess.size() > 1 && (ip.find("127") == 0 || ip.find("192") == 0)) + if (ipaddressess.size() > 1 && (ip.starts_with("127") || ip.starts_with("192"))) continue; ip_ = ip; break; diff --git a/libminifi/src/core/state/nodes/RepositoryMetrics.cpp b/libminifi/src/core/state/nodes/RepositoryMetrics.cpp index 40748e20c..a9f56de38 100644 --- a/libminifi/src/core/state/nodes/RepositoryMetrics.cpp +++ b/libminifi/src/core/state/nodes/RepositoryMetrics.cpp @@ -22,7 +22,7 @@ namespace org::apache::nifi::minifi::state::response { void RepositoryMetrics::addRepository(const std::shared_ptr<core::RepositoryMetricsSource> &repo) { - return repository_metrics_source_store_.addRepository(repo); + repository_metrics_source_store_.addRepository(repo); } std::vector<SerializedResponseNode> RepositoryMetrics::serialize() { diff --git a/libminifi/src/io/AtomicEntryStream.cpp b/libminifi/src/io/AtomicEntryStream.cpp deleted file mode 100644 index 388fc8fd9..000000000 --- a/libminifi/src/io/AtomicEntryStream.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "io/AtomicEntryStream.h" -#include <vector> -#include <mutex> -#include <string> - -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace io { - -} /* namespace io */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ diff --git a/libminifi/src/utils/tls/DistinguishedName.cpp b/libminifi/src/utils/tls/DistinguishedName.cpp index f611e4759..d14fe8f9e 100644 --- a/libminifi/src/utils/tls/DistinguishedName.cpp +++ b/libminifi/src/utils/tls/DistinguishedName.cpp @@ -39,7 +39,7 @@ DistinguishedName DistinguishedName::fromSlashSeparated(const std::string &slash std::optional<std::string> DistinguishedName::getCN() const { const auto it = std::find_if(components_.begin(), components_.end(), - [](const std::string& component) { return component.compare(0, 3, "CN=") == 0; }); + [](const std::string& component) { return component.starts_with("CN="); }); if (it != components_.end()) { return it->substr(3); } else { diff --git a/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp b/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp index 56b9b04d3..ae18fcd27 100644 --- a/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp +++ b/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp @@ -37,7 +37,7 @@ class KamikazeErrorHandlingTests : public IntegrationBase { REQUIRE(verifyEventHappenedInPollTime(wait_time_, [&] { const std::string logs = LogTestController::getInstance().getLogs(); const auto result = minifi::utils::string::countOccurrences(logs, minifi::processors::KamikazeProcessor::OnScheduleExceptionStr); - const int occurrences = result.second; + const auto occurrences = result.second; return 1 < occurrences; })); flowController_->updatePropertyValue("kamikaze", std::string(minifi::processors::KamikazeProcessor::ThrowInOnSchedule.name), "false"); diff --git a/libminifi/test/libtest/integration/ConnectionCountingServer.cpp b/libminifi/test/libtest/integration/ConnectionCountingServer.cpp index 41ac99dca..86baee859 100644 --- a/libminifi/test/libtest/integration/ConnectionCountingServer.cpp +++ b/libminifi/test/libtest/integration/ConnectionCountingServer.cpp @@ -68,7 +68,7 @@ bool ReverseBodyPostHandler::handlePost(CivetServer* /*server*/, struct mg_conne request_body.reserve(2048); size_t read_size = mg_read(conn, request_body.data(), 2048); assert(read_size < 2048); - std::string response_body{request_body.begin(), request_body.begin() + read_size}; + std::string response_body{request_body.begin(), request_body.begin() + gsl::narrow<std::vector<char>::difference_type>(read_size)}; std::reverse(std::begin(response_body), std::end(response_body)); mg_printf(conn, "HTTP/1.1 200 OK\r\n"); mg_printf(conn, "Content-length: %zu\r\n", read_size); @@ -85,14 +85,14 @@ void ReverseBodyPostHandler::saveConnectionId(struct mg_connection* conn) { AddIdToUserConnectionData::AddIdToUserConnectionData() { init_connection = [](const struct mg_connection*, void** user_connection_data) -> int { - minifi::utils::SmallString<36>* id = new minifi::utils::SmallString<36>(minifi::utils::IdGenerator::getIdGenerator()->generate().to_string()); + auto id = new minifi::utils::SmallString<36>(minifi::utils::IdGenerator::getIdGenerator()->generate().to_string()); *user_connection_data = reinterpret_cast<void*>(id); return 0; }; connection_close = [](const struct mg_connection* conn) -> void { auto user_connection_data = reinterpret_cast<minifi::utils::SmallString<36>*>(mg_get_user_connection_data(conn)); - delete user_connection_data; + delete user_connection_data; // NOLINT(cppcoreguidelines-owning-memory) }; } } // namespace details diff --git a/libminifi/test/libtest/integration/HTTPIntegrationBase.cpp b/libminifi/test/libtest/integration/HTTPIntegrationBase.cpp index c6439f9bb..62f2dc84a 100644 --- a/libminifi/test/libtest/integration/HTTPIntegrationBase.cpp +++ b/libminifi/test/libtest/integration/HTTPIntegrationBase.cpp @@ -43,7 +43,9 @@ std::string HTTPIntegrationBase::getC2RestUrl() const { } void HTTPIntegrationBase::setUrl(const std::string &url, ServerAwareHandler *handler) { - std::string url_port, url_scheme, url_path; + std::string url_port; + std::string url_scheme; + std::string url_path; minifi::utils::parse_http_components(url, url_port, url_scheme, url_path); if (server) { if (url_port != "0" && url_port != port) { diff --git a/libminifi/test/libtest/unit/TestBase.cpp b/libminifi/test/libtest/unit/TestBase.cpp index 11d2811fb..193885d62 100644 --- a/libminifi/test/libtest/unit/TestBase.cpp +++ b/libminifi/test/libtest/unit/TestBase.cpp @@ -148,7 +148,7 @@ std::optional<std::smatch> LogTestController::matchesRegex(const std::string& re return found ? std::make_optional<std::smatch>(match) : std::nullopt; } -int LogTestController::countOccurrences(const std::string& pattern) const { +size_t LogTestController::countOccurrences(const std::string& pattern) const { return minifi::utils::string::countOccurrences(getLogs(), pattern).second; } diff --git a/libminifi/test/libtest/unit/TestBase.h b/libminifi/test/libtest/unit/TestBase.h index dd5f0b9fb..133f97e38 100644 --- a/libminifi/test/libtest/unit/TestBase.h +++ b/libminifi/test/libtest/unit/TestBase.h @@ -139,7 +139,7 @@ class LogTestController { std::chrono::milliseconds timeout = std::chrono::seconds(3), std::chrono::milliseconds sleep_interval = std::chrono::milliseconds(200)) const; - int countOccurrences(const std::string& pattern) const; + size_t countOccurrences(const std::string& pattern) const; void reset(); diff --git a/libminifi/test/libtest/unit/TestUtils.cpp b/libminifi/test/libtest/unit/TestUtils.cpp index c1f18ba6b..b479281e8 100644 --- a/libminifi/test/libtest/unit/TestUtils.cpp +++ b/libminifi/test/libtest/unit/TestUtils.cpp @@ -158,7 +158,7 @@ void verifyJSON(const std::string& actual_str, const std::string& expected_str, } bool countLogOccurrencesUntil(const std::string& pattern, - const int occurrences, + const size_t occurrences, const std::chrono::milliseconds max_duration, const std::chrono::milliseconds wait_time) { auto start_time = std::chrono::steady_clock::now(); diff --git a/libminifi/test/libtest/unit/TestUtils.h b/libminifi/test/libtest/unit/TestUtils.h index 3a1223b85..d2ca10d83 100644 --- a/libminifi/test/libtest/unit/TestUtils.h +++ b/libminifi/test/libtest/unit/TestUtils.h @@ -167,7 +167,7 @@ class ExceptionSubStringMatcher : public Catch::Matchers::MatcherBase<T> { }; bool countLogOccurrencesUntil(const std::string& pattern, - const int occurrences, + const size_t occurrences, const std::chrono::milliseconds max_duration, const std::chrono::milliseconds wait_time = 50ms); std::error_code sendMessagesViaTCP(const std::vector<std::string_view>& contents, const asio::ip::tcp::endpoint& remote_endpoint, const std::optional<std::string_view> delimiter = std::nullopt); diff --git a/libminifi/test/schema-tests/SchemaTests.cpp b/libminifi/test/schema-tests/SchemaTests.cpp index 3a3f7dc58..5615d62a4 100644 --- a/libminifi/test/schema-tests/SchemaTests.cpp +++ b/libminifi/test/schema-tests/SchemaTests.cpp @@ -233,7 +233,7 @@ TEST_CASE("The JSON schema detects invalid values in the json flow") { std::unordered_map<std::string, std::string> errors; extractExpectedErrors(config_json, "", errors); - ErrorHandler err_handler{[&] (auto err) { + ErrorHandler err_handler{[&] (const auto& err) { auto it = errors.find(err.path); if (it == errors.end()) { throw std::logic_error("Unexpected error in json flow at " + err.path + ": " + err.error); diff --git a/libminifi/test/unit/BackTraceTests.cpp b/libminifi/test/unit/BackTraceTests.cpp index 51eaa59d4..8dc26803a 100644 --- a/libminifi/test/unit/BackTraceTests.cpp +++ b/libminifi/test/unit/BackTraceTests.cpp @@ -52,7 +52,7 @@ TEST_CASE("BT2", "[TPT2]") { constexpr std::string_view thread_pool_name = "Winnie the pool"; constexpr size_t number_of_worker_threads = 3; - utils::ThreadPool pool(number_of_worker_threads, nullptr, thread_pool_name.data()); + utils::ThreadPool pool(number_of_worker_threads, nullptr, std::string{thread_pool_name}); utils::Worker worker([&]() -> utils::TaskRescheduleInfo { outer_function(ready_for_checking, done_with_checking); return utils::TaskRescheduleInfo::Done(); diff --git a/libminifi/test/unit/CertificateUtilsTests.cpp b/libminifi/test/unit/CertificateUtilsTests.cpp index 3700a7513..88b82b2c0 100644 --- a/libminifi/test/unit/CertificateUtilsTests.cpp +++ b/libminifi/test/unit/CertificateUtilsTests.cpp @@ -33,7 +33,7 @@ TEST_CASE("getCertificateExpiration() works correctly") { const auto cert_location = executable_dir / "resources" / "ca_A.crt"; size_t num_times_called = 0; - utils::tls::processPEMCertificate(cert_location, {}, {[&](utils::tls::X509_unique_ptr cert) { + std::ignore = utils::tls::processPEMCertificate(cert_location, {}, {[&](utils::tls::X509_unique_ptr cert) { ++num_times_called; CHECK(utils::tls::getCertificateExpiration(cert) == date::sys_days(date::year_month_day(2033_y / 6 / 26)) + 12h + 26min + 48s); return std::error_code{}; diff --git a/libminifi/test/unit/CronTests.cpp b/libminifi/test/unit/CronTests.cpp index fa70ac206..1f3800577 100644 --- a/libminifi/test/unit/CronTests.cpp +++ b/libminifi/test/unit/CronTests.cpp @@ -25,7 +25,9 @@ using std::chrono::system_clock; using std::chrono::seconds; using org::apache::nifi::minifi::utils::Cron; +#ifdef WIN32 namespace timeutils = org::apache::nifi::minifi::utils::timeutils; +#endif void checkNext(const std::string& expr, const date::zoned_time<seconds>& from, const date::zoned_time<seconds>& next) { diff --git a/libminifi/test/unit/HTTPStreamingCallbackTests.cpp b/libminifi/test/unit/HTTPStreamingCallbackTests.cpp index ae8618b57..3ed8a1d35 100644 --- a/libminifi/test/unit/HTTPStreamingCallbackTests.cpp +++ b/libminifi/test/unit/HTTPStreamingCallbackTests.cpp @@ -111,7 +111,7 @@ TEST_CASE_METHOD(HttpStreamingCallbackTestsFixture, "HttpStreamingCallback empty std::string content = waitForCompletionAndGetContent(); - REQUIRE(0U == content.length()); + REQUIRE(content.empty()); } TEST_CASE_METHOD(HttpStreamingCallbackTestsFixture, "HttpStreamingCallback one buffer", "[basic]") { diff --git a/libminifi/test/unit/IdTests.cpp b/libminifi/test/unit/IdTests.cpp index fa3711535..048072b5d 100644 --- a/libminifi/test/unit/IdTests.cpp +++ b/libminifi/test/unit/IdTests.cpp @@ -333,6 +333,7 @@ TEST_CASE("Collision", "[collision]") { std::vector<utils::Identifier> uuids(16 * 1024U); std::vector<std::thread> threads; + threads.reserve(16); for (size_t i = 0U; i < 16U; i++) { threads.emplace_back([&generator, &uuids, i](){ for (size_t j = 0U; j < 1024U; j++) { diff --git a/libminifi/test/unit/MapUtilsTests.cpp b/libminifi/test/unit/MapUtilsTests.cpp index e0d7cedbf..88e33418c 100644 --- a/libminifi/test/unit/MapUtilsTests.cpp +++ b/libminifi/test/unit/MapUtilsTests.cpp @@ -28,8 +28,8 @@ namespace MapUtils = org::apache::nifi::minifi::utils::MapUtils; TEST_CASE("TestMapUtils::getKeys", "[getKeys]") { - REQUIRE(MapUtils::getKeys(std::map<int, int>()) == std::set<int>()); - REQUIRE(MapUtils::getKeys(std::unordered_map<int, int>()) == std::set<int>()); + REQUIRE(MapUtils::getKeys(std::map<int, int>()).empty()); + REQUIRE(MapUtils::getKeys(std::unordered_map<int, int>()).empty()); std::map<int, std::string> test_map{ std::make_pair(1, "one"), diff --git a/libminifi/test/unit/NetworkInterfaceInfoTests.cpp b/libminifi/test/unit/NetworkInterfaceInfoTests.cpp index bb57e294d..47f4c8b74 100644 --- a/libminifi/test/unit/NetworkInterfaceInfoTests.cpp +++ b/libminifi/test/unit/NetworkInterfaceInfoTests.cpp @@ -23,7 +23,7 @@ namespace utils = org::apache::nifi::minifi::utils; TEST_CASE("NetworkInterfaceInfo test", "[testnetworkinterfaceinfo]") { auto network_interface_infos = utils::NetworkInterfaceInfo::getNetworkInterfaceInfos(); - REQUIRE(network_interface_infos.size() > 0); + REQUIRE_FALSE(network_interface_infos.empty()); auto valid_interface_name = network_interface_infos.begin()->getName(); auto filter = [&valid_interface_name](const utils::NetworkInterfaceInfo& interface_info) -> bool { return interface_info.getName() == valid_interface_name; }; diff --git a/libminifi/test/unit/RegexUtilsTests.cpp b/libminifi/test/unit/RegexUtilsTests.cpp index 7b0195df7..4913c7099 100644 --- a/libminifi/test/unit/RegexUtilsTests.cpp +++ b/libminifi/test/unit/RegexUtilsTests.cpp @@ -37,7 +37,6 @@ TEST_CASE("TestRegexUtils::single_match", "[regex1]") { } TEST_CASE("TestRegexUtils::invalid_construction", "[regex2]") { - std::string pat = "Speed limit 130 | Speed limit 80"; std::string rgx1 = "Speed limit ([0-9]+)"; std::string rgx2 = "[Invalid)A(F)"; std::vector<Regex::Mode> mode = {Regex::Mode::ICASE}; diff --git a/libminifi/test/unit/SiteToSiteTests.cpp b/libminifi/test/unit/SiteToSiteTests.cpp index 3f2d8b98c..2a0c36cd5 100644 --- a/libminifi/test/unit/SiteToSiteTests.cpp +++ b/libminifi/test/unit/SiteToSiteTests.cpp @@ -266,9 +266,8 @@ TEST_CASE("TestSiteToSiteVerifyNegotiationFail", "[S2S]") { initializeLogging(); auto collector = std::make_unique<SiteToSiteResponder>(); - const char negotiated_abort_code = magic_enum::enum_underlying(sitetosite::ResourceNegotiationStatusCode::NEGOTIATED_ABORT); - std::string resp_code; - resp_code.insert(resp_code.begin(), negotiated_abort_code); + const auto negotiated_abort_code = magic_enum::enum_underlying(sitetosite::ResourceNegotiationStatusCode::NEGOTIATED_ABORT); + const std::string resp_code{static_cast<char>(negotiated_abort_code)}; collector->push_response(resp_code); collector->push_response(resp_code); diff --git a/libminifi/test/unit/StringUtilsTests.cpp b/libminifi/test/unit/StringUtilsTests.cpp index f194a6a1e..b074e9381 100644 --- a/libminifi/test/unit/StringUtilsTests.cpp +++ b/libminifi/test/unit/StringUtilsTests.cpp @@ -178,7 +178,7 @@ TEST_CASE("test string::testJoin", "[test string join]") { TEST_CASE("Test the join function with a projection", "[join][projection]") { std::vector<std::string> fruits = {"APPLE", "OrAnGe"}; - CHECK(string::join(", ", fruits, [](auto fruit) { return string::toLower(fruit); }) == "apple, orange"); + CHECK(string::join(", ", fruits, [](const auto& fruit) { return string::toLower(fruit); }) == "apple, orange"); std::set numbers_set = {3, 2, 1}; CHECK(string::join(", ", numbers_set, [](auto x) { return std::to_string(x); }) == "1, 2, 3"); @@ -523,15 +523,15 @@ TEST_CASE("string::replaceAll works correctly", "[replaceAll]") { } TEST_CASE("string::countOccurrences works correctly", "[countOccurrences]") { - REQUIRE(string::countOccurrences("", "a") == std::make_pair(size_t{0}, 0)); - REQUIRE(string::countOccurrences("abc", "a") == std::make_pair(size_t{0}, 1)); - REQUIRE(string::countOccurrences("abc", "b") == std::make_pair(size_t{1}, 1)); - REQUIRE(string::countOccurrences("abc", "x") == std::make_pair(size_t{0}, 0)); - REQUIRE(string::countOccurrences("banana", "a") == std::make_pair(size_t{5}, 3)); - REQUIRE(string::countOccurrences("banana", "an") == std::make_pair(size_t{3}, 2)); - REQUIRE(string::countOccurrences("aaaaaaaa", "aaa") == std::make_pair(size_t{3}, 2)); // overlapping occurrences are not counted - REQUIRE(string::countOccurrences("abc", "") == std::make_pair(size_t{3}, 4)); // "" occurs at the start, between chars, and at the end - REQUIRE(string::countOccurrences("", "") == std::make_pair(size_t{0}, 1)); + REQUIRE(string::countOccurrences("", "a") == std::make_pair(size_t{0}, size_t{0})); + REQUIRE(string::countOccurrences("abc", "a") == std::make_pair(size_t{0}, size_t{1})); + REQUIRE(string::countOccurrences("abc", "b") == std::make_pair(size_t{1}, size_t{1})); + REQUIRE(string::countOccurrences("abc", "x") == std::make_pair(size_t{0}, size_t{0})); + REQUIRE(string::countOccurrences("banana", "a") == std::make_pair(size_t{5}, size_t{3})); + REQUIRE(string::countOccurrences("banana", "an") == std::make_pair(size_t{3}, size_t{2})); + REQUIRE(string::countOccurrences("aaaaaaaa", "aaa") == std::make_pair(size_t{3}, size_t{2})); // overlapping occurrences are not counted + REQUIRE(string::countOccurrences("abc", "") == std::make_pair(size_t{3}, size_t{4})); // "" occurs at the start, between chars, and at the end + REQUIRE(string::countOccurrences("", "") == std::make_pair(size_t{0}, size_t{1})); } TEST_CASE("string::removeFramingCharacters works correctly", "[removeFramingCharacters]") { diff --git a/libminifi/test/unit/TimeUtilTests.cpp b/libminifi/test/unit/TimeUtilTests.cpp index ae479df06..6aac7eefb 100644 --- a/libminifi/test/unit/TimeUtilTests.cpp +++ b/libminifi/test/unit/TimeUtilTests.cpp @@ -140,9 +140,9 @@ TEST_CASE("Test windows FILETIME epoch") { #endif TEST_CASE("Test clock resolutions", "[clockresolutiontests]") { - CHECK(std::is_constructible<std::chrono::system_clock::duration, std::chrono::microseconds>::value); // The resolution of the system_clock is at least microseconds - CHECK(std::is_constructible<std::chrono::steady_clock::duration, std::chrono::microseconds>::value); // The resolution of the steady_clock is at least microseconds - CHECK(std::is_constructible<std::chrono::high_resolution_clock::duration, std::chrono::nanoseconds>::value); // The resolution of the high_resolution_clock is at least nanoseconds + CHECK(std::is_constructible_v<std::chrono::system_clock::duration, std::chrono::microseconds>); // The resolution of the system_clock is at least microseconds + CHECK(std::is_constructible_v<std::chrono::steady_clock::duration, std::chrono::microseconds>); // The resolution of the steady_clock is at least microseconds + CHECK(std::is_constructible_v<std::chrono::high_resolution_clock::duration, std::chrono::nanoseconds>); // The resolution of the high_resolution_clock is at least nanoseconds } TEST_CASE("Test string to duration conversion", "[timedurationtests]") { diff --git a/minifi-api/include/minifi-cpp/core/AgentIdentificationProvider.h b/minifi-api/include/minifi-cpp/core/AgentIdentificationProvider.h index 6e297b634..c014325bb 100644 --- a/minifi-api/include/minifi-cpp/core/AgentIdentificationProvider.h +++ b/minifi-api/include/minifi-cpp/core/AgentIdentificationProvider.h @@ -21,11 +21,7 @@ #include <optional> #include <string> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { +namespace org::apache::nifi::minifi::core { /** * Provides a single source of truth for the agent's class and identifier. @@ -39,8 +35,4 @@ class AgentIdentificationProvider { virtual ~AgentIdentificationProvider() = default; }; -} /* namespace core */ -} /* namespace minifi */ -} /* namespace nifi */ -} /* namespace apache */ -} /* namespace org */ +} // namespace org::apache::nifi::minifi::core diff --git a/minifi-api/include/minifi-cpp/core/Annotation.h b/minifi-api/include/minifi-cpp/core/Annotation.h index e61117715..3f9014f60 100644 --- a/minifi-api/include/minifi-cpp/core/Annotation.h +++ b/minifi-api/include/minifi-cpp/core/Annotation.h @@ -21,12 +21,7 @@ #include <cstdint> #include <string> -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace annotation { +namespace org::apache::nifi::minifi::core::annotation { enum class Input : uint8_t { /** @@ -64,9 +59,4 @@ inline std::string toString(Input input_requirement) { return "ERROR_no_such_input_requirement"; } -} // namespace annotation -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core::annotation diff --git a/minifi-api/include/minifi-cpp/core/ClassLoader.h b/minifi-api/include/minifi-cpp/core/ClassLoader.h index 5413e74e5..7956083ff 100644 --- a/minifi-api/include/minifi-cpp/core/ClassLoader.h +++ b/minifi-api/include/minifi-cpp/core/ClassLoader.h @@ -78,7 +78,7 @@ class ClassLoader { [[nodiscard]] virtual std::unique_ptr<CoreComponent> instantiate( const std::string &class_name, const std::string &name, const utils::Identifier &uuid, std::function<bool(CoreComponent*)> filter) = 0; - [[nodiscard]] virtual CoreComponent* instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) = 0; + [[nodiscard]] virtual gsl::owner<CoreComponent*> instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) = 0; /** * Instantiate object based on class_name @@ -105,7 +105,7 @@ class ClassLoader { * @return nullptr or object created from class_name definition. */ template<class T = CoreComponent> - [[nodiscard]] T *instantiateRaw(const std::string &class_name, const std::string &name); + [[nodiscard]] gsl::owner<T*> instantiateRaw(const std::string &class_name, const std::string &name); template<class T = CoreComponent> [[nodiscard]] std::unique_ptr<T> instantiate(const std::string &class_name, const std::string &name, const utils::Identifier &uuid); diff --git a/minifi-api/include/minifi-cpp/core/ObjectFactory.h b/minifi-api/include/minifi-cpp/core/ObjectFactory.h index 9f247b2a2..8058151ee 100644 --- a/minifi-api/include/minifi-cpp/core/ObjectFactory.h +++ b/minifi-api/include/minifi-cpp/core/ObjectFactory.h @@ -27,9 +27,9 @@ namespace org::apache::nifi::minifi::core { class ObjectFactory { public: virtual std::unique_ptr<CoreComponent> create(const std::string& /*name*/) = 0; - virtual CoreComponent *createRaw(const std::string& /*name*/) = 0; + virtual gsl::owner<CoreComponent*> createRaw(const std::string& /*name*/) = 0; virtual std::unique_ptr<CoreComponent> create(const std::string& /*name*/, const utils::Identifier& /*uuid*/) = 0; - virtual CoreComponent* createRaw(const std::string& /*name*/, const utils::Identifier& /*uuid*/) = 0; + virtual gsl::owner<CoreComponent*> createRaw(const std::string& /*name*/, const utils::Identifier& /*uuid*/) = 0; virtual std::string getGroupName() const = 0; virtual std::string getClassName() = 0; diff --git a/minifi-api/include/minifi-cpp/core/TraceableResource.h b/minifi-api/include/minifi-cpp/core/TraceableResource.h index 805ee51a9..828bab679 100644 --- a/minifi-api/include/minifi-cpp/core/TraceableResource.h +++ b/minifi-api/include/minifi-cpp/core/TraceableResource.h @@ -19,11 +19,7 @@ #include "utils/BackTrace.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { +namespace org::apache::nifi::minifi::core { /** * Purpose: Defines a resource eligible for tracing @@ -42,8 +38,4 @@ class TraceableResource { virtual BackTrace getTraces() = 0; }; -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::core diff --git a/minifi-api/include/minifi-cpp/io/OutputStream.h b/minifi-api/include/minifi-cpp/io/OutputStream.h index 9784f10f8..d0e7f3d55 100644 --- a/minifi-api/include/minifi-cpp/io/OutputStream.h +++ b/minifi-api/include/minifi-cpp/io/OutputStream.h @@ -26,11 +26,7 @@ #include "utils/SmallString.h" #include "utils/Id.h" -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace io { +namespace org::apache::nifi::minifi::io { /** * Serializable instances provide base functionality to @@ -118,8 +114,4 @@ class OutputStream : public virtual Stream { size_t write_str(const char* str, uint32_t len, bool widen); }; -} // namespace io -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org +} // namespace org::apache::nifi::minifi::io
