You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by sz...@apache.org on 2022/06/15 15:24:51 UTC
[nifi-minifi-cpp] branch main updated: MINIFICPP-1833 Integrate misc and modernize clang-tidy checks in CI
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
The following commit(s) were added to refs/heads/main by this push:
new 6ded58d24 MINIFICPP-1833 Integrate misc and modernize clang-tidy checks in CI
6ded58d24 is described below
commit 6ded58d24b8b3b226652d9eed136ca9d5005bcd1
Author: Gabor Gyimesi <ga...@gmail.com>
AuthorDate: Wed Jun 15 17:12:07 2022 +0200
MINIFICPP-1833 Integrate misc and modernize clang-tidy checks in CI
misc and modernize category checks of clang-tidy are fixed and added to
CI. A few checks are only fixed in the changed files, as fixing them in
the whole codebase would have blown up the PR significantly, but can be
fixed over time when changing the problematic file in a PR. These checks
are:
- modernize-concat-nested-namespaces
- modernize-use-auto
- modernize-use-nullptr
- modernize-pass-by-value
Enabled and fixed (or already working) checks:
- hicpp-avoid-goto
- hicpp-exception-baseclass
- hicpp-multiway-paths-covered
- hicpp-no-assembler
- misc-definitions-in-headers
- misc-misleading-bidirectional
- misc-misleading-identifier
- misc-misplaced-const
- misc-new-delete-overloads
- misc-non-copyable-objects
- misc-redundant-expression
- misc-static-assert
- misc-throw-by-value-catch-by-reference
- misc-unconventional-assign-operator
- misc-uniqueptr-reset-release
- misc-unused-alias-decls
- misc-unused-parameters
- misc-unused-using-decls
- modernize-avoid-bind
- modernize-avoid-c-ar
- modernize-deprecated-headers
- modernize-deprecated-ios-base-aliases
- modernize-loop-convert
- modernize-macro-to-enum
- modernize-make-shared
- modernize-make-unique
- modernize-raw-string-literal
- modernize-redundant-void-arg
- modernize-replace-auto-ptr
- modernize-replace-disallow-copy-and-assign-macro
- modernize-replace-random-shuffle
- modernize-return-braced-init-list
- modernize-shrink-to-fit
- modernize-unary-static-assert
- modernize-use-bool-literals
- modernize-use-default-member-init
- modernize-use-equals-default
- modernize-use-equals-delete
- modernize-use-nodiscard
- modernize-use-noexcept
- modernize-use-override
- modernize-use-transparent-functors
- modernize-use-uncaught-exceptions
- modernize-use-using
Closes #1348
Signed-off-by: Marton Szasz <sz...@apache.org>
---
.clang-tidy | 62 +++++++++++++++++++++-
controller/MiNiFiController.cpp | 4 +-
.../azure/storage/AzureBlobStorageClient.cpp | 2 +-
extensions/civetweb/processors/ListenHTTP.cpp | 16 ++----
extensions/civetweb/processors/ListenHTTP.h | 12 +----
extensions/civetweb/protocols/RESTReceiver.cpp | 8 +--
extensions/civetweb/tests/ListenHTTPTests.cpp | 4 +-
extensions/coap/protocols/CoapC2Protocol.cpp | 22 ++++----
extensions/coap/tests/CoapC2VerifyHeartbeat.cpp | 8 +--
extensions/coap/tests/CoapIntegrationBase.h | 2 +-
extensions/expression-language/Expression.cpp | 38 ++++++-------
.../impl/expression/Expression.h | 12 +----
.../tests/ExpressionLanguageTests.cpp | 6 +--
extensions/gcp/tests/FetchGCSObjectTests.cpp | 2 -
.../tests/GCPCredentialsControllerServiceTests.cpp | 2 -
extensions/gcp/tests/ListGCSBucketTests.cpp | 1 -
extensions/http-curl/protocols/RESTSender.cpp | 4 +-
extensions/http-curl/sitetosite/HTTPProtocol.cpp | 4 +-
extensions/http-curl/tests/C2ConfigEncryption.cpp | 2 +-
extensions/http-curl/tests/C2DebugBundleTest.cpp | 2 +-
extensions/http-curl/tests/C2FailedUpdateTest.cpp | 2 +-
.../http-curl/tests/C2FetchFlowIfMissingTest.cpp | 2 +-
.../http-curl/tests/C2PropertiesUpdateTests.cpp | 6 +--
extensions/http-curl/tests/C2UpdateTest.cpp | 2 +-
extensions/http-curl/tests/HTTPSiteToSiteTests.cpp | 40 ++++++--------
.../http-curl/tests/HttpPostIntegrationTest.cpp | 2 +-
.../http-curl/tests/TimeoutHTTPSiteToSiteTests.cpp | 2 +-
extensions/http-curl/tests/VerifyInvokeHTTP.h | 2 +-
.../http-curl/tests/VerifyInvokeHTTPGetTest.cpp | 2 +-
.../http-curl/tests/unit/HTTPClientTests.cpp | 4 +-
.../tests/unit/HTTPStreamingCallbackTests.cpp | 2 +-
extensions/jni/jvm/JavaControllerService.cpp | 16 ++----
extensions/jni/jvm/JavaControllerService.h | 14 +----
extensions/libarchive/BinFiles.cpp | 20 ++++---
extensions/libarchive/CompressContent.cpp | 14 ++---
extensions/libarchive/CompressContent.h | 12 +----
extensions/libarchive/FocusArchiveEntry.cpp | 18 ++-----
extensions/libarchive/FocusArchiveEntry.h | 12 +----
extensions/libarchive/MergeContent.cpp | 10 ++--
extensions/libarchive/MergeContent.h | 2 +-
extensions/libarchive/UnfocusArchiveEntry.cpp | 20 +++----
extensions/libarchive/UnfocusArchiveEntry.h | 12 +----
extensions/librdkafka/ConsumeKafka.cpp | 5 +-
extensions/librdkafka/KafkaConnection.cpp | 16 +++---
extensions/librdkafka/KafkaConnection.h | 17 ++----
extensions/librdkafka/PublishKafka.cpp | 2 +-
extensions/librdkafka/PublishKafka.h | 5 +-
.../mqtt/processors/AbstractMQTTProcessor.cpp | 4 +-
extensions/mqtt/processors/AbstractMQTTProcessor.h | 1 -
extensions/mqtt/processors/ConsumeMQTT.cpp | 2 +-
extensions/mqtt/processors/ConvertHeartBeat.cpp | 13 +----
extensions/mqtt/processors/ConvertHeartBeat.h | 12 +----
extensions/mqtt/protocol/MQTTC2Protocol.cpp | 6 +--
extensions/opc/include/opc.h | 12 +----
extensions/opc/src/fetchopc.cpp | 2 +-
extensions/opc/src/opc.cpp | 18 ++-----
.../SourceInitiatedSubscriptionListener.cpp | 4 +-
.../rocksdb-repos/database/StringAppender.cpp | 16 ++----
extensions/rocksdb-repos/database/StringAppender.h | 14 +----
.../encryption/RocksDbEncryptionProvider.cpp | 18 ++-----
.../encryption/RocksDbEncryptionProvider.h | 14 +----
extensions/script/python/PyBaseStream.cpp | 14 ++---
extensions/script/python/PyBaseStream.h | 12 +----
extensions/script/python/PythonProcessor.cpp | 13 +----
extensions/script/python/PythonProcessor.h | 12 +----
extensions/script/python/PythonScriptEngine.cpp | 15 ++----
extensions/script/python/PythonScriptEngine.h | 12 +----
.../script/tests/ExecutePythonProcessorTests.cpp | 3 +-
extensions/sftp/client/SFTPClient.cpp | 20 +++----
extensions/sftp/client/SFTPClient.h | 14 ++---
extensions/sftp/processors/FetchSFTP.cpp | 2 +-
extensions/sftp/processors/ListSFTP.cpp | 4 +-
extensions/sftp/processors/SFTPProcessorBase.cpp | 6 +--
extensions/sftp/processors/SFTPProcessorBase.h | 12 +----
extensions/sftp/tests/FetchSFTPTests.cpp | 2 +-
extensions/sftp/tests/ListSFTPTests.cpp | 2 +-
extensions/sftp/tests/ListThenFetchSFTPTests.cpp | 2 +-
extensions/sftp/tests/PutSFTPTests.cpp | 2 +-
extensions/sftp/tests/tools/SFTPTestServer.cpp | 7 +--
extensions/sftp/tests/tools/SFTPTestServer.h | 2 +-
...UnorderedMapPersistableKeyValueStoreService.cpp | 8 +--
.../standard-processors/processors/FetchFile.cpp | 2 +-
.../processors/GenerateFlowFile.cpp | 16 ++----
.../processors/GenerateFlowFile.h | 16 ++----
.../standard-processors/processors/GetTCP.cpp | 14 ++---
extensions/standard-processors/processors/GetTCP.h | 17 ++----
.../processors/LogAttribute.cpp | 16 ++----
.../standard-processors/processors/LogAttribute.h | 17 ++----
.../tests/integration/SecureSocketGetTCPTest.cpp | 2 +-
.../TLSClientSocketSupportedProtocolsTest.cpp | 6 +--
.../TLSServerSocketSupportedProtocolsTest.cpp | 12 ++---
.../tests/integration/TailFileTest.cpp | 2 +-
.../tests/unit/ConfigurationTests.cpp | 2 -
.../tests/unit/FetchFileTests.cpp | 2 +-
.../tests/unit/GetFileTests.cpp | 4 +-
.../tests/unit/ProcessorTests.cpp | 2 -
.../tests/unit/RetryFlowFileTests.cpp | 2 +-
libminifi/include/Connection.h | 22 +++-----
libminifi/include/FlowFileRecord.h | 5 +-
libminifi/include/c2/HeartbeatJsonSerializer.h | 12 +----
libminifi/include/core/ProcessSession.h | 16 ++----
.../include/core/logging/LoggerConfiguration.h | 19 ++-----
libminifi/include/sitetosite/Peer.h | 17 ++----
libminifi/include/sitetosite/RawSocketProtocol.h | 16 ++----
libminifi/include/utils/Id.h | 17 ++----
libminifi/include/utils/RegexUtils.h | 7 +--
libminifi/include/utils/ThreadPool.h | 17 ++----
libminifi/include/utils/file/PathUtils.h | 19 ++-----
libminifi/src/Connection.cpp | 37 ++++++-------
libminifi/src/FlowFileRecord.cpp | 12 ++---
libminifi/src/c2/ControllerSocketProtocol.cpp | 2 +
libminifi/src/c2/HeartbeatJsonSerializer.cpp | 14 ++---
libminifi/src/c2/protocols/RESTProtocol.cpp | 4 +-
.../src/controllers/NetworkPrioritizerService.cpp | 8 +--
.../controllers/UpdatePolicyControllerService.cpp | 4 +-
libminifi/src/core/ProcessSession.cpp | 14 ++---
libminifi/src/core/Processor.cpp | 14 ++---
libminifi/src/core/logging/LoggerConfiguration.cpp | 17 ++----
libminifi/src/core/state/Value.cpp | 2 +-
libminifi/src/sitetosite/Peer.cpp | 14 ++---
libminifi/src/sitetosite/RawSocketProtocol.cpp | 24 +++------
libminifi/src/utils/BackTrace.cpp | 1 -
libminifi/src/utils/Id.cpp | 19 +++----
libminifi/src/utils/RegexUtils.cpp | 13 +++--
libminifi/src/utils/ThreadPool.cpp | 16 ++----
libminifi/src/utils/file/PathUtils.cpp | 18 ++-----
.../test/archive-tests/CompressContentTests.cpp | 10 ++--
.../test/archive-tests/ManipulateArchiveTests.cpp | 2 +-
libminifi/test/archive-tests/MergeFileTests.cpp | 10 ++--
.../test/aws-tests/AWSCredentialsServiceTest.cpp | 2 +-
.../PersistableKeyValueStoreServiceTest.cpp | 2 +-
.../rocksdb-tests/DBProvenanceRepositoryTests.cpp | 2 +-
libminifi/test/rocksdb-tests/RocksDBTests.cpp | 2 +-
libminifi/test/sql-tests/mocks/MockConnectors.cpp | 18 ++-----
libminifi/test/sql-tests/mocks/MockConnectors.h | 12 +----
libminifi/test/unit/BackTraceTests.cpp | 7 +--
libminifi/test/unit/CollectionUtilsTests.cpp | 2 +-
libminifi/test/unit/ControllerTests.cpp | 15 +++---
libminifi/test/unit/DynamicPropertyTests.cpp | 12 +----
libminifi/test/unit/EnvironmentUtilsTests.cpp | 4 ++
libminifi/test/unit/ExpectedTest.cpp | 8 +--
libminifi/test/unit/GeneralUtilsTest.cpp | 38 ++++++-------
libminifi/test/unit/IdTests.cpp | 16 ++----
libminifi/test/unit/IntervalSwitchTest.cpp | 2 +-
libminifi/test/unit/LoggerTests.cpp | 4 +-
libminifi/test/unit/PropertyTests.cpp | 3 --
libminifi/test/unit/RegexUtilsTests.cpp | 2 -
libminifi/test/unit/Site2SiteTests.cpp | 13 ++---
libminifi/test/unit/StagingQueueTests.cpp | 2 +-
libminifi/test/unit/StringUtilsTests.cpp | 4 +-
libminifi/test/unit/ThreadPoolTests.cpp | 7 +--
main/MiNiFiMain.cpp | 4 +-
152 files changed, 499 insertions(+), 1010 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index 16e1a2ee6..39f9721d6 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,2 +1,62 @@
-Checks: 'boost*,bugprone*,cert*,portability*,-clang-analyzer-optin.cplusplus.VirtualCall,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result,-bugprone-macro-parentheses,-bugprone-easily-swappable-parameters,-bugprone-exception-escape,-cert-err58-cpp,-cert-err33-c'
+Checks: >
+ -clang-analyzer-optin.cplusplus.VirtualCall,
+ boost*,
+ portability*,
+ bugprone*,
+ -bugprone-narrowing-conversions,
+ -bugprone-implicit-widening-of-multiplication-result,
+ -bugprone-macro-parentheses,
+ -bugprone-easily-swappable-parameters,
+ -bugprone-exception-escape,
+ cert*,
+ -cert-err58-cpp,
+ -cert-err33-c,
+ hicpp-avoid-goto,
+ hicpp-exception-baseclass,
+ hicpp-multiway-paths-covered,
+ hicpp-no-assembler,
+ misc-definitions-in-headers,
+ misc-misleading-bidirectional,
+ misc-misleading-identifier,
+ misc-misplaced-const,
+ misc-new-delete-overloads,
+ misc-non-copyable-objects,
+ misc-redundant-expression,
+ misc-static-assert,
+ misc-throw-by-value-catch-by-reference,
+ misc-unconventional-assign-operator,
+ misc-uniqueptr-reset-release,
+ misc-unused-alias-decls,
+ misc-unused-parameters,
+ misc-unused-using-decls,
+ modernize-avoid-bind,
+ modernize-avoid-c-ar,
+ modernize-concat-nested-namespaces,
+ modernize-deprecated-headers,
+ modernize-deprecated-ios-base-aliases,
+ modernize-loop-convert,
+ modernize-macro-to-enum,
+ modernize-make-shared,
+ modernize-make-unique,
+ modernize-pass-by-value,
+ modernize-raw-string-literal,
+ modernize-redundant-void-arg,
+ modernize-replace-auto-ptr,
+ modernize-replace-disallow-copy-and-assign-macro,
+ modernize-replace-random-shuffle,
+ modernize-return-braced-init-list,
+ modernize-shrink-to-fit,
+ modernize-unary-static-assert,
+ modernize-use-auto,
+ modernize-use-bool-literals,
+ modernize-use-default-member-init,
+ modernize-use-equals-default,
+ modernize-use-equals-delete,
+ modernize-use-nodiscard,
+ modernize-use-noexcept,
+ modernize-use-nullptr,
+ modernize-use-override,
+ modernize-use-transparent-functors,
+ modernize-use-uncaught-exceptions,
+ modernize-use-using
FormatStyle: 'file'
diff --git a/controller/MiNiFiController.cpp b/controller/MiNiFiController.cpp
index 9cf682dc9..ae0303b50 100644
--- a/controller/MiNiFiController.cpp
+++ b/controller/MiNiFiController.cpp
@@ -16,9 +16,9 @@
* limitations under the License.
*/
#include <fcntl.h>
-#include <stdio.h>
+#include <cstdio>
#include <semaphore.h>
-#include <signal.h>
+#include <csignal>
#include <vector>
#include <queue>
#include <map>
diff --git a/extensions/azure/storage/AzureBlobStorageClient.cpp b/extensions/azure/storage/AzureBlobStorageClient.cpp
index 99ade0805..6b7ee3388 100644
--- a/extensions/azure/storage/AzureBlobStorageClient.cpp
+++ b/extensions/azure/storage/AzureBlobStorageClient.cpp
@@ -36,7 +36,7 @@ class AzureBlobStorageInputStream : public io::InputStream {
: result_(std::move(result)) {
}
- size_t size() const override {
+ [[nodiscard]] size_t size() const override {
return result_.BodyStream->Length();
}
diff --git a/extensions/civetweb/processors/ListenHTTP.cpp b/extensions/civetweb/processors/ListenHTTP.cpp
index a7f99b675..a9d554570 100644
--- a/extensions/civetweb/processors/ListenHTTP.cpp
+++ b/extensions/civetweb/processors/ListenHTTP.cpp
@@ -30,11 +30,7 @@
#include "core/Resource.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
const uint64_t ListenHTTP::DEFAULT_BUFFER_SIZE = 20000;
@@ -200,12 +196,12 @@ void ListenHTTP::onSchedule(core::ProcessContext *context, core::ProcessSessionF
}
}
- server_.reset(new CivetServer(options, &callbacks_, &logger_));
+ server_ = std::make_unique<CivetServer>(options, &callbacks_, &logger_);
context->getProperty(BatchSize.getName(), batch_size_);
logger_->log_debug("ListenHTTP using %s: %zu", BatchSize.getName(), batch_size_);
- handler_.reset(new Handler(basePath, context, std::move(authDNPattern), std::move(headersAsAttributesPattern)));
+ handler_ = std::make_unique<Handler>(basePath, context, std::move(authDNPattern), std::move(headersAsAttributesPattern));
server_->addHandler(basePath, handler_.get());
if (randomPort) {
@@ -510,8 +506,4 @@ void ListenHTTP::notifyStop() {
REGISTER_RESOURCE(ListenHTTP, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/civetweb/processors/ListenHTTP.h b/extensions/civetweb/processors/ListenHTTP.h
index cefd2da1b..7bb82af5c 100644
--- a/extensions/civetweb/processors/ListenHTTP.h
+++ b/extensions/civetweb/processors/ListenHTTP.h
@@ -36,11 +36,7 @@
#include "utils/Export.h"
#include "utils/RegexUtils.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
class ListenHTTP : public core::Processor {
public:
@@ -200,8 +196,4 @@ class ListenHTTP : public core::Processor {
uint64_t batch_size_;
};
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/civetweb/protocols/RESTReceiver.cpp b/extensions/civetweb/protocols/RESTReceiver.cpp
index 4cb544dfb..c40504479 100644
--- a/extensions/civetweb/protocols/RESTReceiver.cpp
+++ b/extensions/civetweb/protocols/RESTReceiver.cpp
@@ -79,13 +79,13 @@ std::unique_ptr<CivetServer> RESTReceiver::start_webserver(const std::string &po
my_port += "s";
callback.log_message = log_message;
const char *options[] = { "listening_ports", port.c_str(), "ssl_certificate", ca_cert.c_str(), "ssl_protocol_version", "4", "ssl_cipher_list", "ALL",
- "ssl_verify_peer", "no", "num_threads", "1", 0 };
+ "ssl_verify_peer", "no", "num_threads", "1", nullptr };
std::vector<std::string> cpp_options;
for (uint32_t i = 0; i < (sizeof(options) / sizeof(options[0]) - 1); i++) {
cpp_options.push_back(options[i]);
}
- std::unique_ptr<CivetServer> server = std::unique_ptr<CivetServer>(new CivetServer(cpp_options));
+ auto server = std::make_unique<CivetServer>(cpp_options);
server->addHandler(rooturi, handler);
@@ -93,13 +93,13 @@ std::unique_ptr<CivetServer> RESTReceiver::start_webserver(const std::string &po
}
std::unique_ptr<CivetServer> RESTReceiver::start_webserver(const std::string &port, std::string &rooturi, CivetHandler *handler) {
- const char *options[] = { "document_root", ".", "listening_ports", port.c_str(), "num_threads", "1", 0 };
+ const char *options[] = { "document_root", ".", "listening_ports", port.c_str(), "num_threads", "1", nullptr };
std::vector<std::string> cpp_options;
for (uint32_t i = 0; i < (sizeof(options) / sizeof(options[0]) - 1); i++) {
cpp_options.push_back(options[i]);
}
- std::unique_ptr<CivetServer> server = std::unique_ptr<CivetServer>(new CivetServer(cpp_options));
+ auto server = std::make_unique<CivetServer>(cpp_options);
server->addHandler(rooturi, handler);
diff --git a/extensions/civetweb/tests/ListenHTTPTests.cpp b/extensions/civetweb/tests/ListenHTTPTests.cpp
index 9538cd371..f8aa0dc8c 100644
--- a/extensions/civetweb/tests/ListenHTTPTests.cpp
+++ b/extensions/civetweb/tests/ListenHTTPTests.cpp
@@ -143,7 +143,7 @@ class ListenHTTPTestsFixture {
return;
}
- client = std::unique_ptr<utils::HTTPClient>(new utils::HTTPClient());
+ client = std::make_unique<utils::HTTPClient>();
client->initialize(method, url, ssl_context_service);
client->setVerbose();
for (const auto &header : headers) {
@@ -643,7 +643,7 @@ TEST_CASE_METHOD(ListenHTTPTestsFixture, "HTTPS minimum SSL version", "[https]")
run_server();
- client = std::unique_ptr<utils::HTTPClient>(new utils::HTTPClient());
+ client = std::make_unique<utils::HTTPClient>();
client->setVerbose();
client->initialize(method, url, ssl_context_service);
if (method == "POST") {
diff --git a/extensions/coap/protocols/CoapC2Protocol.cpp b/extensions/coap/protocols/CoapC2Protocol.cpp
index e6210d4c0..d2539afd9 100644
--- a/extensions/coap/protocols/CoapC2Protocol.cpp
+++ b/extensions/coap/protocols/CoapC2Protocol.cpp
@@ -21,6 +21,7 @@
#include "coap_message.h"
#include "io/BaseStream.h"
#include "core/Resource.h"
+#include "utils/gsl.h"
namespace org::apache::nifi::minifi::coap::c2 {
@@ -84,9 +85,9 @@ int CoapProtocol::writeHeartbeat(io::BaseStream *stream, const minifi::c2::C2Pay
logger_->log_trace("Writing heartbeat");
try {
- const std::string deviceIdent = minifi::c2::PayloadParser::getInstance(payload).in("deviceInfo").getAs<std::string>("identifier");
+ const auto deviceIdent = minifi::c2::PayloadParser::getInstance(payload).in("deviceInfo").getAs<std::string>("identifier");
- const std::string agentIdent = minifi::c2::PayloadParser::getInstance(payload).in("agentInfo").getAs<std::string>("identifier");
+ const auto agentIdent = minifi::c2::PayloadParser::getInstance(payload).in("agentInfo").getAs<std::string>("identifier");
stream->write(deviceIdent, false);
@@ -180,15 +181,16 @@ minifi::c2::Operation CoapProtocol::getOperation(int type) const {
return minifi::c2::Operation::PAUSE;
case 9:
return minifi::c2::Operation::RESUME;
+ default:
+ gsl_FailFast();
}
- return minifi::c2::Operation::ACKNOWLEDGE;
}
minifi::c2::C2Payload CoapProtocol::serialize(const minifi::c2::C2Payload &payload) {
if (nullptr == coap_service_) {
// return an error if we don't have a coap service
logger_->log_error("CoAP service requested without any configured hostname or port");
- return minifi::c2::C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR);
+ return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
if (require_registration_) {
@@ -196,13 +198,13 @@ minifi::c2::C2Payload CoapProtocol::serialize(const minifi::c2::C2Payload &paylo
auto response = minifi::c2::RESTSender::consumePayload(rest_uri_, payload, minifi::c2::TRANSMIT, false);
if (response.getStatus().getState() == state::UpdateState::READ_ERROR) {
logger_->log_trace("Could not register");
- return minifi::c2::C2Payload(payload.getOperation(), state::UpdateState::READ_COMPLETE);
+ return {payload.getOperation(), state::UpdateState::READ_COMPLETE};
} else {
logger_->log_trace("Registered agent.");
}
require_registration_ = false;
- return minifi::c2::C2Payload(payload.getOperation(), state::UpdateState::READ_COMPLETE);
+ return {payload.getOperation(), state::UpdateState::READ_COMPLETE};
}
uint16_t version = 0;
@@ -218,7 +220,7 @@ minifi::c2::C2Payload CoapProtocol::serialize(const minifi::c2::C2Payload &paylo
payload_type = 0;
stream.write(&payload_type, 1);
if (writeAcknowledgement(&stream, payload) != 0) {
- return minifi::c2::C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR);
+ return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
break;
case minifi::c2::Operation::HEARTBEAT:
@@ -226,12 +228,12 @@ minifi::c2::C2Payload CoapProtocol::serialize(const minifi::c2::C2Payload &paylo
stream.write(&payload_type, 1);
if (writeHeartbeat(&stream, payload) != 0) {
logger_->log_error("Could not write heartbeat");
- return minifi::c2::C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR);
+ return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
break;
default:
logger_->log_error("Could not identify operation");
- return minifi::c2::C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR);
+ return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
size_t bsize = stream.size();
@@ -283,7 +285,7 @@ minifi::c2::C2Payload CoapProtocol::serialize(const minifi::c2::C2Payload &paylo
return new_payload;
}
- return minifi::c2::C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR);
+ return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
REGISTER_RESOURCE(CoapProtocol, InternalResource);
diff --git a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp
index ed3acea28..e8748eeca 100644
--- a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp
+++ b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp
@@ -108,11 +108,11 @@ class VerifyCoAPServer : public CoapIntegrationBase {
uint16_t newport = std::stoi(port) + 2;
auto new_port_str = std::to_string(newport);
- server = std::unique_ptr<minifi::coap::CoapServer>(new minifi::coap::CoapServer("127.0.0.1", newport));
+ server = std::make_unique<minifi::coap::CoapServer>("127.0.0.1", newport);
server->add_endpoint(minifi::coap::Method::Post, [](minifi::coap::CoapQuery)->minifi::coap::CoapResponse {
- minifi::coap::CoapResponse response(205, 0x00, 0);
+ minifi::coap::CoapResponse response(205, nullptr, 0);
return response;
});
@@ -149,11 +149,11 @@ class VerifyCoAPServer : public CoapIntegrationBase {
server->add_endpoint("heartbeat", minifi::coap::Method::Post, [&](minifi::coap::CoapQuery)-> minifi::coap::CoapResponse {
if (responses.size_approx() > 0) {
- minifi::coap::CoapResponse resp(500, 0, 0);;
+ minifi::coap::CoapResponse resp(500, nullptr, 0);;
responses.try_dequeue(resp);
return resp;
}
- minifi::coap::CoapResponse response(500, 0, 0);
+ minifi::coap::CoapResponse response(500, nullptr, 0);
return response;
});
server->start();
diff --git a/extensions/coap/tests/CoapIntegrationBase.h b/extensions/coap/tests/CoapIntegrationBase.h
index 520aaaf76..964b0de1a 100644
--- a/extensions/coap/tests/CoapIntegrationBase.h
+++ b/extensions/coap/tests/CoapIntegrationBase.h
@@ -26,7 +26,7 @@
#include "CivetServer.h"
#include "integration/IntegrationBase.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
int log_message(const struct mg_connection* /*conn*/, const char *message) {
puts(message);
diff --git a/extensions/expression-language/Expression.cpp b/extensions/expression-language/Expression.cpp
index 09a42c8f2..f856bff20 100644
--- a/extensions/expression-language/Expression.cpp
+++ b/extensions/expression-language/Expression.cpp
@@ -65,11 +65,7 @@
#include "date/tz.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace expression {
+namespace org::apache::nifi::minifi::expression {
Expression compile(const std::string &expr_str) {
std::stringstream expr_str_stream(expr_str);
@@ -99,7 +95,7 @@ Expression make_dynamic_attr(const std::string &attribute_id) {
return Value(result);
}
}
- return Value();
+ return {};
});
}
@@ -180,7 +176,7 @@ Value expr_ip(const std::vector<Value>& /*args*/) {
}
freeaddrinfo(result);
- return Value();
+ return {};
}
Value expr_uuid(const std::vector<Value>& /*args*/) {
@@ -201,12 +197,12 @@ Value expr_toLower(const std::vector<Value> &args) {
Value expr_substring(const std::vector<Value> &args) {
if (args.size() < 3) {
- size_t offset = gsl::narrow<size_t>(args[1].asUnsignedLong());
- return Value(args[0].asString().substr(offset));
+ auto offset = gsl::narrow<size_t>(args[1].asUnsignedLong());
+ return Value{args[0].asString().substr(offset)};
} else {
- size_t offset = gsl::narrow<size_t>(args[1].asUnsignedLong());
- size_t count = gsl::narrow<size_t>(args[2].asUnsignedLong());
- return Value(args[0].asString().substr(offset, count));
+ auto offset = gsl::narrow<size_t>(args[1].asUnsignedLong());
+ auto count = gsl::narrow<size_t>(args[2].asUnsignedLong());
+ return Value{args[0].asString().substr(offset, count)};
}
}
@@ -434,7 +430,7 @@ Value expr_unescapeJson(const std::vector<Value> &args) {
if (doc.IsArray() && doc.Size() == 1 && doc[0].IsString()) {
return Value(std::string(doc[0].GetString()));
} else {
- return Value();
+ return {};
}
}
@@ -808,7 +804,7 @@ Value expr_binary_op(const std::vector<Value> &args, long double (*ldop)(long do
return Value(ldop(args[0].asLongDouble(), args[1].asLongDouble()));
}
} catch (const std::exception &) {
- return Value();
+ return {};
}
}
@@ -1048,7 +1044,7 @@ Expression make_allAttributes(const std::string &function_name, const std::vecto
if (cur_flow_file && cur_flow_file->getAttribute(attr_id, attr_val)) {
return Value(attr_val);
} else {
- return Value();
+ return {};
}
}));
}
@@ -1093,7 +1089,7 @@ Expression make_anyAttribute(const std::string &function_name, const std::vector
if (cur_flow_file && cur_flow_file->getAttribute(attr_id, attr_val)) {
return Value(attr_val);
} else {
- return Value();
+ return {};
}
}));
}
@@ -1144,7 +1140,7 @@ Expression make_allMatchingAttributes(const std::string &function_name, const st
if (cur_flow_file && cur_flow_file->getAttribute(attr.first, attr_val)) {
return Value(attr_val);
} else {
- return Value();
+ return {};
}
}));
}
@@ -1197,7 +1193,7 @@ Expression make_anyMatchingAttribute(const std::string &function_name, const std
if (cur_flow_file && cur_flow_file->getAttribute(attr.first, attr_val)) {
return Value(attr_val);
} else {
- return Value();
+ return {};
}
}));
}
@@ -1609,8 +1605,4 @@ void dateSetInstall(const std::string& install) {
}
#endif
-} /* namespace expression */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::expression
diff --git a/extensions/expression-language/impl/expression/Expression.h b/extensions/expression-language/impl/expression/Expression.h
index dd94a59fc..b9187f2ec 100644
--- a/extensions/expression-language/impl/expression/Expression.h
+++ b/extensions/expression-language/impl/expression/Expression.h
@@ -27,11 +27,7 @@
#include "FlowFile.h"
#include "VariableRegistry.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace expression {
+namespace org::apache::nifi::minifi::expression {
struct Parameters {
std::weak_ptr<core::FlowFile> flow_file;
@@ -184,8 +180,4 @@ Expression make_function_composition(const Expression &arg, const std::vector<st
void dateSetInstall(const std::string& install);
#endif
-} /* namespace expression */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::expression
diff --git a/extensions/expression-language/tests/ExpressionLanguageTests.cpp b/extensions/expression-language/tests/ExpressionLanguageTests.cpp
index 7b03fb5d1..efb0f33ab 100644
--- a/extensions/expression-language/tests/ExpressionLanguageTests.cpp
+++ b/extensions/expression-language/tests/ExpressionLanguageTests.cpp
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-#include <time.h>
+#include <ctime>
#include <memory>
#include <string>
@@ -311,7 +311,7 @@ TEST_CASE("Get Delimited 2", "[expressionLanguageGetDelimited2]") {
}
TEST_CASE("Get Delimited 3", "[expressionLanguageGetDelimited3]") {
- auto expr = expression::compile("${attr:getDelimitedField(1, ',', '\\\"', '\\\\', 'true')}");
+ auto expr = expression::compile(R"(${attr:getDelimitedField(1, ',', '\"', '\\', 'true')})");
auto flow_file_a = std::make_shared<core::FlowFile>();
flow_file_a->addAttribute("attr", "\"Jacobson, John\", 32, Mr.");
@@ -1057,7 +1057,7 @@ TEST_CASE("Decode JSON", "[expressionDecodeJSON]") {
auto expr = expression::compile("${message:unescapeJson()}");
auto flow_file_a = std::make_shared<core::FlowFile>();
- flow_file_a->addAttribute("message", "This is a \\\"test!\\\"");
+ flow_file_a->addAttribute("message", R"(This is a \"test!\")");
REQUIRE("This is a \"test!\"" == expr(expression::Parameters{ flow_file_a }).asString());
}
diff --git a/extensions/gcp/tests/FetchGCSObjectTests.cpp b/extensions/gcp/tests/FetchGCSObjectTests.cpp
index 5b46033b7..bd1bd17c8 100644
--- a/extensions/gcp/tests/FetchGCSObjectTests.cpp
+++ b/extensions/gcp/tests/FetchGCSObjectTests.cpp
@@ -28,8 +28,6 @@ namespace minifi_gcp = org::apache::nifi::minifi::extensions::gcp;
using FetchGCSObject = org::apache::nifi::minifi::extensions::gcp::FetchGCSObject;
using GCPCredentialsControllerService = org::apache::nifi::minifi::extensions::gcp::GCPCredentialsControllerService;
-using ::google::cloud::storage::testing::canonical_errors::TransientError;
-using ::google::cloud::storage::testing::canonical_errors::PermanentError;
namespace {
class FetchGCSObjectMocked : public FetchGCSObject {
diff --git a/extensions/gcp/tests/GCPCredentialsControllerServiceTests.cpp b/extensions/gcp/tests/GCPCredentialsControllerServiceTests.cpp
index 3f5051cac..9254d0902 100644
--- a/extensions/gcp/tests/GCPCredentialsControllerServiceTests.cpp
+++ b/extensions/gcp/tests/GCPCredentialsControllerServiceTests.cpp
@@ -27,8 +27,6 @@
#include "rapidjson/writer.h"
#include "google/cloud/internal/setenv.h"
-namespace gcs = ::google::cloud::storage;
-
using GCPCredentialsControllerService = org::apache::nifi::minifi::extensions::gcp::GCPCredentialsControllerService;
namespace {
diff --git a/extensions/gcp/tests/ListGCSBucketTests.cpp b/extensions/gcp/tests/ListGCSBucketTests.cpp
index a1e7e92d7..534df31b6 100644
--- a/extensions/gcp/tests/ListGCSBucketTests.cpp
+++ b/extensions/gcp/tests/ListGCSBucketTests.cpp
@@ -23,7 +23,6 @@
#include "google/cloud/storage/testing/canonical_errors.h"
namespace gcs = ::google::cloud::storage;
-namespace minifi_gcp = org::apache::nifi::minifi::extensions::gcp;
using ListGCSBucket = org::apache::nifi::minifi::extensions::gcp::ListGCSBucket;
using ListObjectsRequest = gcs::internal::ListObjectsRequest;
diff --git a/extensions/http-curl/protocols/RESTSender.cpp b/extensions/http-curl/protocols/RESTSender.cpp
index f00bd34e3..6e87809e1 100644
--- a/extensions/http-curl/protocols/RESTSender.cpp
+++ b/extensions/http-curl/protocols/RESTSender.cpp
@@ -93,7 +93,7 @@ void RESTSender::setSecurityContext(utils::HTTPClient &client, const std::string
C2Payload RESTSender::sendPayload(const std::string url, const Direction direction, const C2Payload &payload, std::optional<std::string> data) {
if (url.empty()) {
- return C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR);
+ return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
// Callback for transmit. Declared in order to destruct in proper order - take care!
@@ -196,7 +196,7 @@ C2Payload RESTSender::sendPayload(const std::string url, const Direction directi
}
return parseJsonResponse(payload, response_body_bytes);
} else {
- return C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR);
+ return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
}
diff --git a/extensions/http-curl/sitetosite/HTTPProtocol.cpp b/extensions/http-curl/sitetosite/HTTPProtocol.cpp
index c80bd328c..34f818121 100644
--- a/extensions/http-curl/sitetosite/HTTPProtocol.cpp
+++ b/extensions/http-curl/sitetosite/HTTPProtocol.cpp
@@ -16,7 +16,7 @@
*/
#include "HTTPProtocol.h"
-#include <stdio.h>
+#include <cstdio>
#include <chrono>
#include <map>
#include <string>
@@ -225,7 +225,7 @@ void HttpSiteToSiteClient::tearDown() {
}
void HttpSiteToSiteClient::closeTransaction(const utils::Identifier &transactionID) {
- std::shared_ptr<Transaction> transaction = NULL;
+ std::shared_ptr<Transaction> transaction;
auto it = this->known_transactions_.find(transactionID);
diff --git a/extensions/http-curl/tests/C2ConfigEncryption.cpp b/extensions/http-curl/tests/C2ConfigEncryption.cpp
index 5084b0d31..90552f614 100644
--- a/extensions/http-curl/tests/C2ConfigEncryption.cpp
+++ b/extensions/http-curl/tests/C2ConfigEncryption.cpp
@@ -24,7 +24,7 @@
#include "utils/IntegrationTestUtils.h"
#include "utils/crypto/EncryptionProvider.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
int main(int argc, char **argv) {
const cmd_args args = parse_cmdline_args(argc, argv, "update");
diff --git a/extensions/http-curl/tests/C2DebugBundleTest.cpp b/extensions/http-curl/tests/C2DebugBundleTest.cpp
index 5af36a5ae..1119770bb 100644
--- a/extensions/http-curl/tests/C2DebugBundleTest.cpp
+++ b/extensions/http-curl/tests/C2DebugBundleTest.cpp
@@ -30,7 +30,7 @@
#include "EmptyFlow.h"
#include "properties/Configuration.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
class VerifyDebugInfo : public VerifyC2Base {
public:
diff --git a/extensions/http-curl/tests/C2FailedUpdateTest.cpp b/extensions/http-curl/tests/C2FailedUpdateTest.cpp
index 58da6180e..a4cd425b8 100644
--- a/extensions/http-curl/tests/C2FailedUpdateTest.cpp
+++ b/extensions/http-curl/tests/C2FailedUpdateTest.cpp
@@ -21,7 +21,7 @@
#include "HTTPHandlers.h"
#include "utils/IntegrationTestUtils.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
int main(int argc, char **argv) {
const cmd_args args = parse_cmdline_args(argc, argv, "update");
diff --git a/extensions/http-curl/tests/C2FetchFlowIfMissingTest.cpp b/extensions/http-curl/tests/C2FetchFlowIfMissingTest.cpp
index 21072f31d..63a52ab63 100644
--- a/extensions/http-curl/tests/C2FetchFlowIfMissingTest.cpp
+++ b/extensions/http-curl/tests/C2FetchFlowIfMissingTest.cpp
@@ -22,7 +22,7 @@
#include "utils/IntegrationTestUtils.h"
#include "utils/file/PathUtils.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
int main(int argc, char **argv) {
TestController controller;
diff --git a/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp b/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp
index 761475fb8..f06c8d9a4 100644
--- a/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp
+++ b/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp
@@ -94,9 +94,9 @@ class VerifyPropertyUpdate : public HTTPIntegrationBase {
VerifyPropertyUpdate& operator=(const VerifyPropertyUpdate&) = delete;
VerifyPropertyUpdate& operator=(VerifyPropertyUpdate&&) = default;
- void testSetup() {}
+ void testSetup() override {}
- void runAssertions() {
+ void runAssertions() override {
fn_();
}
@@ -115,7 +115,7 @@ static const std::string properties_file =
static const std::string log_properties_file =
"logger.root=INFO,ostream\n";
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
struct DummyClass1 {};
struct DummyClass2 {};
diff --git a/extensions/http-curl/tests/C2UpdateTest.cpp b/extensions/http-curl/tests/C2UpdateTest.cpp
index 8cb17d98d..d82989c24 100644
--- a/extensions/http-curl/tests/C2UpdateTest.cpp
+++ b/extensions/http-curl/tests/C2UpdateTest.cpp
@@ -22,7 +22,7 @@
#include "utils/gsl.h"
#include "utils/IntegrationTestUtils.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
int main(int argc, char **argv) {
const cmd_args args = parse_cmdline_args(argc, argv, "update");
diff --git a/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp b/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp
index 74209118a..fbb33db7b 100644
--- a/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp
+++ b/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp
@@ -36,7 +36,7 @@
#include "client/HTTPStream.h"
#include "properties/Configuration.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
class SiteToSiteTestHarness : public HTTPIntegrationBase {
public:
@@ -77,28 +77,20 @@ class SiteToSiteTestHarness : public HTTPIntegrationBase {
};
struct test_profile {
- test_profile()
- : flow_url_broken(false),
- transaction_url_broken(false),
- empty_transaction_url(false),
- no_delete(false),
- invalid_checksum(false) {
- }
-
- bool allFalse() const {
+ [[nodiscard]] bool allFalse() const {
return !flow_url_broken && !transaction_url_broken &&
!empty_transaction_url && !no_delete && !invalid_checksum;
}
// tests for a broken flow file url
- bool flow_url_broken;
+ bool flow_url_broken{false};
// transaction url will return incorrect information
- bool transaction_url_broken;
+ bool transaction_url_broken{false};
// Location will be absent within the
- bool empty_transaction_url;
+ bool empty_transaction_url{false};
// delete url is not supported.
- bool no_delete;
+ bool no_delete{false};
// invalid checksum error
- bool invalid_checksum;
+ bool invalid_checksum{false};
};
void run_variance(std::string test_file_location, bool isSecure, std::string url, const struct test_profile &profile) {
@@ -107,9 +99,9 @@ void run_variance(std::string test_file_location, bool isSecure, std::string url
std::string in_port = "471deef6-2a6e-4a7d-912a-81cc17e3a204";
std::string out_port = "471deef6-2a6e-4a7d-912a-81cc17e3a203";
- SiteToSiteLocationResponder *responder = new SiteToSiteLocationResponder(isSecure);
+ auto *responder = new SiteToSiteLocationResponder(isSecure);
- TransactionResponder *transaction_response = new TransactionResponder(url, in_port,
+ auto *transaction_response = new TransactionResponder(url, in_port,
true, profile.transaction_url_broken, profile.empty_transaction_url);
std::string transaction_id = transaction_response->getTransactionId();
@@ -119,7 +111,7 @@ void run_variance(std::string test_file_location, bool isSecure, std::string url
std::string controller_loc = url + "/controller";
std::string basesitetosite = url + "/site-to-site";
- SiteToSiteBaseResponder *base = new SiteToSiteBaseResponder(basesitetosite);
+ auto *base = new SiteToSiteBaseResponder(basesitetosite);
harness.setUrl(basesitetosite, base);
@@ -135,17 +127,17 @@ void run_variance(std::string test_file_location, bool isSecure, std::string url
std::string peer_url = url + "/site-to-site/peers";
- PeerResponder *peer_response = new PeerResponder(url);
+ auto *peer_response = new PeerResponder(url);
harness.setUrl(peer_url, peer_response);
std::string flow_url = action_url + "/" + transaction_id + "/flow-files";
- FlowFileResponder *flowResponder = new FlowFileResponder(true, profile.flow_url_broken, profile.invalid_checksum);
+ auto *flowResponder = new FlowFileResponder(true, profile.flow_url_broken, profile.invalid_checksum);
flowResponder->setFlowUrl(flow_url);
auto producedFlows = flowResponder->getFlows();
- TransactionResponder *transaction_response_output = new TransactionResponder(url, out_port,
+ auto *transaction_response_output = new TransactionResponder(url, out_port,
false, profile.transaction_url_broken, profile.empty_transaction_url);
std::string transaction_output_id = transaction_response_output->getTransactionId();
transaction_response_output->setFeed(producedFlows);
@@ -154,7 +146,7 @@ void run_variance(std::string test_file_location, bool isSecure, std::string url
std::string flow_output_url = action_output_url + "/" + transaction_output_id + "/flow-files";
- FlowFileResponder* flowOutputResponder = new FlowFileResponder(false, profile.flow_url_broken, profile.invalid_checksum);
+ auto* flowOutputResponder = new FlowFileResponder(false, profile.flow_url_broken, profile.invalid_checksum);
flowOutputResponder->setFlowUrl(flow_output_url);
flowOutputResponder->setFeed(producedFlows);
@@ -163,11 +155,11 @@ void run_variance(std::string test_file_location, bool isSecure, std::string url
if (!profile.no_delete) {
std::string delete_url = transaction_url + "/" + transaction_id;
- DeleteTransactionResponder *deleteResponse = new DeleteTransactionResponder(delete_url, "201 OK", 12);
+ auto *deleteResponse = new DeleteTransactionResponder(delete_url, "201 OK", 12);
harness.setUrl(delete_url, deleteResponse);
std::string delete_output_url = transaction_output_url + "/" + transaction_output_id;
- DeleteTransactionResponder *deleteOutputResponse = new DeleteTransactionResponder(delete_output_url, "201 OK", producedFlows);
+ auto *deleteOutputResponse = new DeleteTransactionResponder(delete_output_url, "201 OK", producedFlows);
harness.setUrl(delete_output_url, deleteOutputResponse);
}
diff --git a/extensions/http-curl/tests/HttpPostIntegrationTest.cpp b/extensions/http-curl/tests/HttpPostIntegrationTest.cpp
index 159aad707..3194ecc1c 100644
--- a/extensions/http-curl/tests/HttpPostIntegrationTest.cpp
+++ b/extensions/http-curl/tests/HttpPostIntegrationTest.cpp
@@ -33,7 +33,7 @@
#include "utils/IntegrationTestUtils.h"
#include "properties/Configuration.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
class HttpTestHarness : public HTTPIntegrationBase {
public:
diff --git a/extensions/http-curl/tests/TimeoutHTTPSiteToSiteTests.cpp b/extensions/http-curl/tests/TimeoutHTTPSiteToSiteTests.cpp
index 727a6b5cd..d5b2d358c 100644
--- a/extensions/http-curl/tests/TimeoutHTTPSiteToSiteTests.cpp
+++ b/extensions/http-curl/tests/TimeoutHTTPSiteToSiteTests.cpp
@@ -38,7 +38,7 @@
#include "client/HTTPStream.h"
#include "properties/Configuration.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
class SiteToSiteTestHarness : public HTTPIntegrationBase {
public:
diff --git a/extensions/http-curl/tests/VerifyInvokeHTTP.h b/extensions/http-curl/tests/VerifyInvokeHTTP.h
index ec1ad6a5a..a47a800d8 100644
--- a/extensions/http-curl/tests/VerifyInvokeHTTP.h
+++ b/extensions/http-curl/tests/VerifyInvokeHTTP.h
@@ -32,7 +32,7 @@
#include "core/state/ProcessorController.h"
#include "HTTPIntegrationBase.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
class VerifyInvokeHTTP : public HTTPIntegrationBase {
public:
diff --git a/extensions/http-curl/tests/VerifyInvokeHTTPGetTest.cpp b/extensions/http-curl/tests/VerifyInvokeHTTPGetTest.cpp
index 3af0c06f5..9b923fba1 100644
--- a/extensions/http-curl/tests/VerifyInvokeHTTPGetTest.cpp
+++ b/extensions/http-curl/tests/VerifyInvokeHTTPGetTest.cpp
@@ -24,7 +24,7 @@
class VerifyHTTPGet : public VerifyInvokeHTTP {
public:
- virtual void runAssertions() {
+ void runAssertions() override {
assert(org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime(
std::chrono::seconds(10),
"key:invokehttp.status.code value:200",
diff --git a/extensions/http-curl/tests/unit/HTTPClientTests.cpp b/extensions/http-curl/tests/unit/HTTPClientTests.cpp
index 1101b4ef4..15b3225df 100644
--- a/extensions/http-curl/tests/unit/HTTPClientTests.cpp
+++ b/extensions/http-curl/tests/unit/HTTPClientTests.cpp
@@ -43,12 +43,12 @@ TEST_CASE("HTTPClientTestChunkedResponse", "[basic]") {
mg_send_chunk(conn, nullptr, 0U);
}
- bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) {
+ bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) override {
send_response(conn);
return true;
}
- bool handlePost(CivetServer* /*server*/, struct mg_connection *conn) {
+ bool handlePost(CivetServer* /*server*/, struct mg_connection *conn) override {
mg_printf(conn, "HTTP/1.1 100 Continue\r\n\r\n");
std::array<uint8_t, 16384U> buf;
diff --git a/extensions/http-curl/tests/unit/HTTPStreamingCallbackTests.cpp b/extensions/http-curl/tests/unit/HTTPStreamingCallbackTests.cpp
index aa41fc8d9..7d3cd94f6 100644
--- a/extensions/http-curl/tests/unit/HTTPStreamingCallbackTests.cpp
+++ b/extensions/http-curl/tests/unit/HTTPStreamingCallbackTests.cpp
@@ -72,7 +72,7 @@ class HttpStreamingCallbackTestsFixture {
std::string getContent() {
std::unique_lock<std::mutex> lock(content_mutex_);
- return std::string(content_.data(), content_.size());
+ return {content_.data(), content_.size()};
}
std::string waitForCompletionAndGetContent() {
diff --git a/extensions/jni/jvm/JavaControllerService.cpp b/extensions/jni/jvm/JavaControllerService.cpp
index cb823a30c..03e8ead84 100644
--- a/extensions/jni/jvm/JavaControllerService.cpp
+++ b/extensions/jni/jvm/JavaControllerService.cpp
@@ -29,12 +29,7 @@
#include "utils/file/FileUtils.h"
#include "properties/Configure.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace jni {
-namespace controllers {
+namespace org::apache::nifi::minifi::jni::controllers {
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
@@ -96,14 +91,9 @@ void JavaControllerService::onEnable() {
narClassLoaderClazz = loadClass("org/apache/nifi/processor/JniClassLoader");
- nar_loader_ = std::unique_ptr<NarClassLoader>(new NarClassLoader(shared_from_this(), narClassLoaderClazz, nardir, narscratch, nardocs));
+ nar_loader_ = std::make_unique<NarClassLoader>(shared_from_this(), narClassLoaderClazz, nardir, narscratch, nardocs);
}
REGISTER_RESOURCE(JavaControllerService, ControllerService);
-} /* namespace controllers */
-} /* namespace jni */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::jni::controllers
diff --git a/extensions/jni/jvm/JavaControllerService.h b/extensions/jni/jvm/JavaControllerService.h
index 9293c434d..36e80747f 100644
--- a/extensions/jni/jvm/JavaControllerService.h
+++ b/extensions/jni/jvm/JavaControllerService.h
@@ -32,12 +32,7 @@
#include "core/controller/ControllerService.h"
#include "core/logging/LoggerConfiguration.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace jni {
-namespace controllers {
+namespace org::apache::nifi::minifi::jni::controllers {
/**
* Purpose and Justification: Java Controller Service is intended to be used either within the flow or
@@ -163,9 +158,4 @@ class JavaControllerService : public core::controller::ControllerService, public
std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<JavaControllerService>::getLogger();
};
-} /* namespace controllers */
-} /* namespace jni */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::jni::controllers
diff --git a/extensions/libarchive/BinFiles.cpp b/extensions/libarchive/BinFiles.cpp
index 26a2fdb1a..9dd0084b8 100644
--- a/extensions/libarchive/BinFiles.cpp
+++ b/extensions/libarchive/BinFiles.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#include "BinFiles.h"
-#include <stdio.h>
+#include <cstdio>
#include <memory>
#include <string>
#include <vector>
@@ -97,8 +97,7 @@ void BinFiles::preprocessFlowFile(core::ProcessContext* /*context*/, core::Proce
void BinManager::gatherReadyBins() {
std::lock_guard < std::mutex > lock(mutex_);
std::vector< std::string > emptyQueue;
- for (std::map<std::string, std::unique_ptr<std::deque<std::unique_ptr<Bin>>> >::iterator it=groupBinMap_.begin(); it !=groupBinMap_.end(); ++it) {
- std::unique_ptr < std::deque<std::unique_ptr<Bin>>>&queue = it->second;
+ for (auto& [group_id, queue] : groupBinMap_) {
while (!queue->empty()) {
std::unique_ptr<Bin> &bin = queue->front();
if (bin->isReadyForMerge() || (binAge_ != std::chrono::milliseconds::max() && bin->isOlderThan(binAge_))) {
@@ -111,7 +110,7 @@ void BinManager::gatherReadyBins() {
}
}
if (queue->empty()) {
- emptyQueue.push_back(it->first);
+ emptyQueue.push_back(group_id);
}
}
for (auto group : emptyQueue) {
@@ -125,8 +124,7 @@ void BinManager::removeOldestBin() {
std::lock_guard < std::mutex > lock(mutex_);
std::chrono::system_clock::time_point olddate = std::chrono::system_clock::time_point::max();
std::unique_ptr < std::deque<std::unique_ptr<Bin>>>* oldqueue;
- for (std::map<std::string, std::unique_ptr<std::deque<std::unique_ptr<Bin>>>>::iterator it=groupBinMap_.begin(); it !=groupBinMap_.end(); ++it) {
- std::unique_ptr < std::deque<std::unique_ptr<Bin>>>&queue = it->second;
+ for (auto& [_, queue] : groupBinMap_) {
if (!queue->empty()) {
std::unique_ptr<Bin> &bin = queue->front();
if (bin->getCreationDate() < olddate) {
@@ -162,7 +160,7 @@ bool BinManager::offer(const std::string &group, std::shared_ptr<core::FlowFile>
std::lock_guard < std::mutex > lock(mutex_);
if (flow->getSize() > maxSize_) {
// could not be added to a bin -- too large by itself, so create a separate bin for just this guy.
- std::unique_ptr<Bin> bin = std::unique_ptr < Bin > (new Bin(0, ULLONG_MAX, 1, INT_MAX, "", group));
+ auto bin = std::make_unique<Bin>(0, ULLONG_MAX, 1, INT_MAX, "", group);
if (!bin->offer(flow))
return false;
readyBin_.push_back(std::move(bin));
@@ -176,7 +174,7 @@ bool BinManager::offer(const std::string &group, std::shared_ptr<core::FlowFile>
std::unique_ptr<Bin> &tail = queue->back();
if (!tail->offer(flow)) {
// last bin can not offer the flow
- std::unique_ptr<Bin> bin = std::unique_ptr < Bin > (new Bin(minSize_, maxSize_, minEntries_, maxEntries_, fileCount_, group));
+ auto bin = std::make_unique<Bin>(minSize_, maxSize_, minEntries_, maxEntries_, fileCount_, group);
if (!bin->offer(flow))
return false;
queue->push_back(std::move(bin));
@@ -184,7 +182,7 @@ bool BinManager::offer(const std::string &group, std::shared_ptr<core::FlowFile>
binCount_++;
}
} else {
- std::unique_ptr<Bin> bin = std::unique_ptr < Bin > (new Bin(minSize_, maxSize_, minEntries_, maxEntries_, fileCount_, group));
+ auto bin = std::make_unique<Bin>(minSize_, maxSize_, minEntries_, maxEntries_, fileCount_, group);
if (!bin->offer(flow))
return false;
queue->push_back(std::move(bin));
@@ -192,8 +190,8 @@ bool BinManager::offer(const std::string &group, std::shared_ptr<core::FlowFile>
logger_->log_debug("BinManager add bin %s to group %s", queue->back()->getUUIDStr(), group);
}
} else {
- std::unique_ptr<std::deque<std::unique_ptr<Bin>>> queue = std::unique_ptr<std::deque<std::unique_ptr<Bin>>> (new std::deque<std::unique_ptr<Bin>>());
- std::unique_ptr<Bin> bin = std::unique_ptr < Bin > (new Bin(minSize_, maxSize_, minEntries_, maxEntries_, fileCount_, group));
+ auto queue = std::make_unique<std::deque<std::unique_ptr<Bin>>>();
+ auto bin = std::make_unique<Bin>(minSize_, maxSize_, minEntries_, maxEntries_, fileCount_, group);
if (!bin->offer(flow))
return false;
queue->push_back(std::move(bin));
diff --git a/extensions/libarchive/CompressContent.cpp b/extensions/libarchive/CompressContent.cpp
index d2d6c484d..433f2ad18 100644
--- a/extensions/libarchive/CompressContent.cpp
+++ b/extensions/libarchive/CompressContent.cpp
@@ -18,7 +18,7 @@
* limitations under the License.
*/
#include "CompressContent.h"
-#include <stdio.h>
+#include <cstdio>
#include <memory>
#include <string>
#include <map>
@@ -29,11 +29,7 @@
#include "core/Resource.h"
#include "io/StreamPipe.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
const core::Property CompressContent::CompressLevel(
core::PropertyBuilder::createProperty("Compression Level")->withDescription("The compression level to use; this is valid only when using GZIP compression.")
@@ -248,8 +244,4 @@ std::string CompressContent::toMimeType(io::CompressionFormat format) {
REGISTER_RESOURCE(CompressContent, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/libarchive/CompressContent.h b/extensions/libarchive/CompressContent.h
index 59edb2da5..9694fe30d 100644
--- a/extensions/libarchive/CompressContent.h
+++ b/extensions/libarchive/CompressContent.h
@@ -42,11 +42,7 @@
#include "WriteArchiveStream.h"
#include "ReadArchiveStream.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
class CompressContent : public core::Processor {
public:
@@ -182,8 +178,4 @@ class CompressContent : public core::Processor {
static const std::map<io::CompressionFormat, std::string> fileExtension_;
};
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/libarchive/FocusArchiveEntry.cpp b/extensions/libarchive/FocusArchiveEntry.cpp
index 5cf1e93ed..9d11dd7c9 100644
--- a/extensions/libarchive/FocusArchiveEntry.cpp
+++ b/extensions/libarchive/FocusArchiveEntry.cpp
@@ -22,7 +22,7 @@
#include <archive.h>
#include <archive_entry.h>
-#include <string.h>
+#include <cstring>
#include <array>
#include <string>
@@ -35,11 +35,7 @@
#include "Exception.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
std::shared_ptr<utils::IdGenerator> FocusArchiveEntry::id_generator_ = utils::IdGenerator::getIdGenerator();
@@ -130,11 +126,11 @@ void FocusArchiveEntry::onTrigger(core::ProcessContext *context, core::ProcessSe
session->transfer(flowFile, Success);
}
-typedef struct {
+struct FocusArchiveEntryReadData {
std::shared_ptr<io::BaseStream> stream;
core::Processor *processor;
std::array<std::byte, 8196> buf;
-} FocusArchiveEntryReadData;
+};
// Read callback which reads from the flowfile stream
la_ssize_t FocusArchiveEntry::ReadCallback::read_cb(struct archive * a, void *d, const void **buf) {
@@ -247,8 +243,4 @@ FocusArchiveEntry::ReadCallback::ReadCallback(core::Processor *processor, utils:
REGISTER_RESOURCE(FocusArchiveEntry, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/libarchive/FocusArchiveEntry.h b/extensions/libarchive/FocusArchiveEntry.h
index 15ca4ff53..8db05eeb4 100644
--- a/extensions/libarchive/FocusArchiveEntry.h
+++ b/extensions/libarchive/FocusArchiveEntry.h
@@ -30,11 +30,7 @@
#include "utils/file/FileManager.h"
#include "utils/Export.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
class FocusArchiveEntry : public core::Processor {
public:
@@ -83,8 +79,4 @@ class FocusArchiveEntry : public core::Processor {
static std::shared_ptr<utils::IdGenerator> id_generator_;
};
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/libarchive/MergeContent.cpp b/extensions/libarchive/MergeContent.cpp
index bf17eac5a..7e1b3b53b 100644
--- a/extensions/libarchive/MergeContent.cpp
+++ b/extensions/libarchive/MergeContent.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#include "MergeContent.h"
-#include <stdio.h>
+#include <cstdio>
#include <memory>
#include <string>
#include <map>
@@ -273,10 +273,10 @@ bool MergeContent::processBin(core::ProcessContext *context, core::ProcessSessio
return true;
}
-BinaryConcatenationMerge::BinaryConcatenationMerge(const std::string &header, const std::string& footer, const std::string &demarcator)
- : header_(header),
- footer_(footer),
- demarcator_(demarcator) {}
+BinaryConcatenationMerge::BinaryConcatenationMerge(std::string header, std::string footer, std::string demarcator)
+ : header_(std::move(header)),
+ footer_(std::move(footer)),
+ demarcator_(std::move(demarcator)) {}
void BinaryConcatenationMerge::merge(core::ProcessContext* /*context*/, core::ProcessSession *session,
std::deque<std::shared_ptr<core::FlowFile>> &flows, FlowFileSerializer& serializer, const std::shared_ptr<core::FlowFile>& merge_flow) {
diff --git a/extensions/libarchive/MergeContent.h b/extensions/libarchive/MergeContent.h
index 66ff747f3..0824bdf84 100644
--- a/extensions/libarchive/MergeContent.h
+++ b/extensions/libarchive/MergeContent.h
@@ -60,7 +60,7 @@ class MergeBin {
class BinaryConcatenationMerge : public MergeBin {
public:
- BinaryConcatenationMerge(const std::string& header, const std::string& footer, const std::string& demarcator);
+ BinaryConcatenationMerge(std::string header, std::string footer, std::string demarcator);
void merge(core::ProcessContext *context, core::ProcessSession *session,
std::deque<std::shared_ptr<core::FlowFile>> &flows, FlowFileSerializer& serializer, const std::shared_ptr<core::FlowFile> &flowFile) override;
diff --git a/extensions/libarchive/UnfocusArchiveEntry.cpp b/extensions/libarchive/UnfocusArchiveEntry.cpp
index 43d0a4cde..02222b98b 100644
--- a/extensions/libarchive/UnfocusArchiveEntry.cpp
+++ b/extensions/libarchive/UnfocusArchiveEntry.cpp
@@ -19,7 +19,7 @@
*/
#include "UnfocusArchiveEntry.h"
-#include <string.h>
+#include <cstring>
#include <iostream>
#include <fstream>
#include <memory>
@@ -34,11 +34,7 @@
#include "core/Resource.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
const core::Relationship UnfocusArchiveEntry::Success("success", "success operational on the flow record");
@@ -143,9 +139,9 @@ UnfocusArchiveEntry::WriteCallback::WriteCallback(ArchiveMetadata *archiveMetada
_archiveMetadata = archiveMetadata;
}
-typedef struct {
+struct UnfocusArchiveEntryWriteData {
std::shared_ptr<io::BaseStream> stream;
-} UnfocusArchiveEntryWriteData;
+};
la_ssize_t UnfocusArchiveEntry::WriteCallback::write_cb(struct archive *, void *d, const void *buffer, size_t length) {
auto* const data = static_cast<UnfocusArchiveEntryWriteData *>(d);
@@ -203,7 +199,7 @@ int64_t UnfocusArchiveEntry::WriteCallback::operator()(const std::shared_ptr<io:
while (ifs.good()) {
ifs.read(buf, sizeof(buf));
- size_t len = gsl::narrow<size_t>(ifs.gcount());
+ auto len = gsl::narrow<size_t>(ifs.gcount());
int64_t written = archive_write_data(outputArchive, buf, len);
if (written < 0) {
logger_->log_error("UnfocusArchiveEntry failed to write data to "
@@ -231,8 +227,4 @@ int64_t UnfocusArchiveEntry::WriteCallback::operator()(const std::shared_ptr<io:
REGISTER_RESOURCE(UnfocusArchiveEntry, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/libarchive/UnfocusArchiveEntry.h b/extensions/libarchive/UnfocusArchiveEntry.h
index 57f699aa7..587109afa 100644
--- a/extensions/libarchive/UnfocusArchiveEntry.h
+++ b/extensions/libarchive/UnfocusArchiveEntry.h
@@ -32,11 +32,7 @@
#include "core/Core.h"
#include "core/logging/LoggerConfiguration.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
using core::logging::Logger;
@@ -81,8 +77,4 @@ class UnfocusArchiveEntry : public core::Processor {
std::shared_ptr<Logger> logger_ = core::logging::LoggerFactory<UnfocusArchiveEntry>::getLogger();
};
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/librdkafka/ConsumeKafka.cpp b/extensions/librdkafka/ConsumeKafka.cpp
index 809fd5b24..49bc833b7 100644
--- a/extensions/librdkafka/ConsumeKafka.cpp
+++ b/extensions/librdkafka/ConsumeKafka.cpp
@@ -30,7 +30,6 @@
using namespace std::literals::chrono_literals;
namespace org::apache::nifi::minifi {
-
namespace core {
// The upper limit for Max Poll Time is 4 seconds. This is because Watchdog would potentially start
// reporting issues with the processor health otherwise
@@ -106,12 +105,12 @@ void rebalance_cb(rd_kafka_t* rk, rd_kafka_resp_err_t trigger, rd_kafka_topic_pa
if (logger->should_log(core::logging::LOG_LEVEL::debug)) {
utils::print_topics_list(*logger, *partitions);
}
- assign_error = rd_kafka_assign(rk, NULL);
+ assign_error = rd_kafka_assign(rk, nullptr);
break;
default:
logger->log_debug("failed: %s", rd_kafka_err2str(trigger));
- assign_error = rd_kafka_assign(rk, NULL);
+ assign_error = rd_kafka_assign(rk, nullptr);
break;
}
logger->log_debug("assign failure: %s", rd_kafka_err2str(assign_error));
diff --git a/extensions/librdkafka/KafkaConnection.cpp b/extensions/librdkafka/KafkaConnection.cpp
index 3c6acc9de..6675a8756 100644
--- a/extensions/librdkafka/KafkaConnection.cpp
+++ b/extensions/librdkafka/KafkaConnection.cpp
@@ -19,11 +19,9 @@
#include <memory>
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+#include "utils/gsl.h"
+
+namespace org::apache::nifi::minifi::processors {
KafkaConnection::KafkaConnection(const KafkaConnectionKey &key)
: logger_(core::logging::LoggerFactory<KafkaConnection>::getLogger()),
@@ -125,11 +123,9 @@ void KafkaConnection::logCallback(const rd_kafka_t* rk, int level, const char* /
case 7: // LOG_DEBUG
core::logging::LOG_DEBUG(logger) << buf;
break;
+ default:
+ gsl_FailFast();
}
}
-} // namespace processors
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/librdkafka/KafkaConnection.h b/extensions/librdkafka/KafkaConnection.h
index 109e575c4..1d14ab93b 100644
--- a/extensions/librdkafka/KafkaConnection.h
+++ b/extensions/librdkafka/KafkaConnection.h
@@ -15,8 +15,7 @@
* limitations under the License.
*/
-#ifndef EXTENSIONS_LIBRDKAFKA_KAFKACONNECTION_H_
-#define EXTENSIONS_LIBRDKAFKA_KAFKACONNECTION_H_
+#pragma once
#include <atomic>
#include <map>
@@ -31,11 +30,7 @@
#include "KafkaTopic.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
struct KafkaConnectionKey {
std::string client_id_;
@@ -119,10 +114,4 @@ class KafkaConnection {
}
};
-} // namespace processors
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // EXTENSIONS_LIBRDKAFKA_KAFKACONNECTION_H_
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/librdkafka/PublishKafka.cpp b/extensions/librdkafka/PublishKafka.cpp
index 3516c7dcd..d000eb0be 100644
--- a/extensions/librdkafka/PublishKafka.cpp
+++ b/extensions/librdkafka/PublishKafka.cpp
@@ -75,7 +75,7 @@ class PublishKafka::Messages {
bool interrupted_ = false;
const std::shared_ptr<core::logging::Logger> logger_;
- std::string logStatus(const std::unique_lock<std::mutex>& lock) const {
+ [[nodiscard]] std::string logStatus(const std::unique_lock<std::mutex>& lock) const {
gsl_Expects(lock.owns_lock());
const auto messageresult_ok = [](const MessageResult r) { return r.status == MessageStatus::Success && r.err_code == RD_KAFKA_RESP_ERR_NO_ERROR; };
const auto messageresult_inflight = [](const MessageResult r) { return r.status == MessageStatus::InFlight && r.err_code == RD_KAFKA_RESP_ERR_NO_ERROR; };
diff --git a/extensions/librdkafka/PublishKafka.h b/extensions/librdkafka/PublishKafka.h
index bbf4cc9fd..57e5ccd75 100644
--- a/extensions/librdkafka/PublishKafka.h
+++ b/extensions/librdkafka/PublishKafka.h
@@ -14,8 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef EXTENSIONS_LIBRDKAFKA_PUBLISHKAFKA_H_
-#define EXTENSIONS_LIBRDKAFKA_PUBLISHKAFKA_H_
+#pragma once
#include <atomic>
#include <cstdint>
@@ -157,5 +156,3 @@ class PublishKafka : public KafkaProcessorBase {
};
} // namespace org::apache::nifi::minifi::processors
-
-#endif // EXTENSIONS_LIBRDKAFKA_PUBLISHKAFKA_H_
diff --git a/extensions/mqtt/processors/AbstractMQTTProcessor.cpp b/extensions/mqtt/processors/AbstractMQTTProcessor.cpp
index b9bd11762..95bcc55a8 100644
--- a/extensions/mqtt/processors/AbstractMQTTProcessor.cpp
+++ b/extensions/mqtt/processors/AbstractMQTTProcessor.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#include "AbstractMQTTProcessor.h"
-#include <stdio.h>
+#include <cstdio>
#include <memory>
#include <string>
#include <cinttypes>
@@ -118,7 +118,7 @@ void AbstractMQTTProcessor::onSchedule(const std::shared_ptr<core::ProcessContex
}
}
if (!client_) {
- MQTTClient_create(&client_, uri_.c_str(), clientID_.c_str(), MQTTCLIENT_PERSISTENCE_NONE, NULL);
+ MQTTClient_create(&client_, uri_.c_str(), clientID_.c_str(), MQTTCLIENT_PERSISTENCE_NONE, nullptr);
}
if (client_) {
MQTTClient_setCallbacks(client_, this, connectionLost, msgReceived, msgDelivered);
diff --git a/extensions/mqtt/processors/AbstractMQTTProcessor.h b/extensions/mqtt/processors/AbstractMQTTProcessor.h
index b8e8e37d0..4da1f2559 100644
--- a/extensions/mqtt/processors/AbstractMQTTProcessor.h
+++ b/extensions/mqtt/processors/AbstractMQTTProcessor.h
@@ -142,5 +142,4 @@ class AbstractMQTTProcessor : public core::Processor {
std::string securityPrivateKeyPassWord_;
};
-
} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/mqtt/processors/ConsumeMQTT.cpp b/extensions/mqtt/processors/ConsumeMQTT.cpp
index 4eccda33b..93805f125 100644
--- a/extensions/mqtt/processors/ConsumeMQTT.cpp
+++ b/extensions/mqtt/processors/ConsumeMQTT.cpp
@@ -16,7 +16,7 @@
*/
#include "ConsumeMQTT.h"
-#include <stdio.h>
+#include <cstdio>
#include <algorithm>
#include <memory>
#include <string>
diff --git a/extensions/mqtt/processors/ConvertHeartBeat.cpp b/extensions/mqtt/processors/ConvertHeartBeat.cpp
index 647602073..1324fb127 100644
--- a/extensions/mqtt/processors/ConvertHeartBeat.cpp
+++ b/extensions/mqtt/processors/ConvertHeartBeat.cpp
@@ -24,12 +24,7 @@
#include "ConvertHeartBeat.h"
#include "c2/PayloadSerializer.h"
#include "utils/ByteArrayCallback.h"
-
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
void ConvertHeartBeat::onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) {
auto ff = session.get();
@@ -64,8 +59,4 @@ void ConvertHeartBeat::onTrigger(const std::shared_ptr<core::ProcessContext> &co
}
}
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/mqtt/processors/ConvertHeartBeat.h b/extensions/mqtt/processors/ConvertHeartBeat.h
index 980f05adf..8a63543b3 100644
--- a/extensions/mqtt/processors/ConvertHeartBeat.h
+++ b/extensions/mqtt/processors/ConvertHeartBeat.h
@@ -24,11 +24,7 @@
#include "core/logging/LoggerConfiguration.h"
#include "ConvertBase.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
/*
* Purpose: ConvertHeartBeat converts heatbeats into MQTT messages.
@@ -53,8 +49,4 @@ class ConvertHeartBeat: public ConvertBase {
std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ConvertHeartBeat>::getLogger();
};
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/mqtt/protocol/MQTTC2Protocol.cpp b/extensions/mqtt/protocol/MQTTC2Protocol.cpp
index 565519e57..4509efde5 100644
--- a/extensions/mqtt/protocol/MQTTC2Protocol.cpp
+++ b/extensions/mqtt/protocol/MQTTC2Protocol.cpp
@@ -71,13 +71,13 @@ C2Payload MQTTC2Protocol::consumePayload(const std::string &url, const C2Payload
response_payload.setRawData(response);
return response_payload;
} else {
- return C2Payload(payload.getOperation(), state::UpdateState::READ_COMPLETE);
+ return {payload.getOperation(), state::UpdateState::READ_COMPLETE};
}
}
C2Payload MQTTC2Protocol::serialize(const C2Payload &payload) {
if (mqtt_service_ == nullptr || !mqtt_service_->isRunning()) {
- return C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR);
+ return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
std::lock_guard<std::mutex> lock(input_mutex_);
@@ -89,7 +89,7 @@ C2Payload MQTTC2Protocol::serialize(const C2Payload &payload) {
if (transmit_id > 0 && mqtt_service_->awaitResponse(5000, transmit_id, in_topic_, response)) {
return c2::PayloadSerializer::deserialize(response);
}
- return C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR);
+ return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
REGISTER_RESOURCE(MQTTC2Protocol, InternalResource);
diff --git a/extensions/opc/include/opc.h b/extensions/opc/include/opc.h
index e6bdb4b79..6c0f9872d 100644
--- a/extensions/opc/include/opc.h
+++ b/extensions/opc/include/opc.h
@@ -29,11 +29,7 @@
#include "logging/Logger.h"
#include "Exception.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace opc {
+namespace org::apache::nifi::minifi::opc {
class OPCException : public minifi::Exception {
public:
@@ -134,9 +130,5 @@ std::string OPCDateTime2String(UA_DateTime raw_date);
void logFunc(void *context, UA_LogLevel level, UA_LogCategory category, const char *msg, va_list args);
-} /* namespace opc */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::opc
diff --git a/extensions/opc/src/fetchopc.cpp b/extensions/opc/src/fetchopc.cpp
index 1a6445c06..67f696b94 100644
--- a/extensions/opc/src/fetchopc.cpp
+++ b/extensions/opc/src/fetchopc.cpp
@@ -89,7 +89,7 @@ namespace org::apache::nifi::minifi::processors {
nodesFound_ = 0;
variablesFound_ = 0;
- std::function<opc::nodeFoundCallBackFunc> f = std::bind(&FetchOPCProcessor::nodeFoundCallBack, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, context, session);
+ auto f = [this, &context, &session](opc::Client& client, const UA_ReferenceDescription* ref, const std::string& path) { return nodeFoundCallBack(client, ref, path, context, session); };
if (idType_ != opc::OPCNodeIDType::Path) {
UA_NodeId myID;
myID.namespaceIndex = nameSpaceIdx_;
diff --git a/extensions/opc/src/opc.cpp b/extensions/opc/src/opc.cpp
index eb4ed7681..842a8467d 100644
--- a/extensions/opc/src/opc.cpp
+++ b/extensions/opc/src/opc.cpp
@@ -17,7 +17,7 @@
#include "opc.h"
-#include <stdlib.h>
+#include <cstdlib>
#include <memory>
#include <vector>
#include <string>
@@ -32,11 +32,7 @@
#include "open62541/client_highlevel.h"
#include "open62541/client_config_default.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace opc {
+namespace org::apache::nifi::minifi::opc {
/*
* The following functions are only used internally in OPC lib, not to be exported
@@ -227,7 +223,7 @@ NodeData Client::getNodeData(const UA_ReferenceDescription *ref, const std::stri
nodedata.attributes["Full path"] = basePath + "/" + browsename;
nodedata.dataTypeID = UA_TYPES_COUNT;
UA_Variant* var = UA_Variant_new();
- if (UA_Client_readValueAttribute(client_, ref->nodeId.nodeId, var) == UA_STATUSCODE_GOOD && var->type != NULL && var->data != NULL) {
+ if (UA_Client_readValueAttribute(client_, ref->nodeId.nodeId, var) == UA_STATUSCODE_GOOD && var->type != nullptr && var->data != nullptr) {
// Because the timestamps are eliminated in readValueAttribute for simplification
// We need to call the inner function UA_Client_Service_read.
UA_ReadValueId item;
@@ -558,7 +554,7 @@ std::string OPCDateTime2String(UA_DateTime raw_date) {
int sz = snprintf(charBuf.data(), charBuf.size(), "%02hu-%02hu-%04hu %02hu:%02hu:%02hu.%03hu", dts.day, dts.month, dts.year, dts.hour, dts.min, dts.sec, dts.milliSec);
- return std::string(charBuf.data(), sz);
+ return {charBuf.data(), gsl::narrow<std::size_t>(sz)};
}
void logFunc(void *context, UA_LogLevel level, UA_LogCategory /*category*/, const char *msg, va_list args) {
@@ -568,8 +564,4 @@ void logFunc(void *context, UA_LogLevel level, UA_LogCategory /*category*/, cons
loggerPtr->log_string(MapOPCLogLevel(level), buffer);
}
-} /* namespace opc */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::opc
diff --git a/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.cpp b/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.cpp
index dff6e1834..18b363345 100644
--- a/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.cpp
+++ b/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.cpp
@@ -853,13 +853,13 @@ void SourceInitiatedSubscriptionListener::onSchedule(const std::shared_ptr<core:
options.emplace_back(verify_peer ? "yes" : "no");
try {
- server_ = std::unique_ptr<CivetServer>(new CivetServer(options));
+ server_ = std::make_unique<CivetServer>(options);
} catch (const std::exception& e) {
throw Exception(PROCESSOR_EXCEPTION, std::string("Failed to initialize server, error: ") + e.what());
} catch (...) {
throw Exception(PROCESSOR_EXCEPTION, "Failed to initialize server");
}
- handler_ = std::unique_ptr<Handler>(new Handler(*this));
+ handler_ = std::make_unique<Handler>(*this);
server_->addHandler("**", *handler_);
}
diff --git a/extensions/rocksdb-repos/database/StringAppender.cpp b/extensions/rocksdb-repos/database/StringAppender.cpp
index 910efd16a..4580dcdbc 100644
--- a/extensions/rocksdb-repos/database/StringAppender.cpp
+++ b/extensions/rocksdb-repos/database/StringAppender.cpp
@@ -18,12 +18,7 @@
#include "StringAppender.h"
#include "rocksdb/utilities/object_registry.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace repository {
+namespace org::apache::nifi::minifi::core::repository {
bool StringAppender::Merge(const rocksdb::Slice& /*key*/, const rocksdb::Slice* existing_value, const rocksdb::Slice& value, std::string* new_value, rocksdb::Logger* /*logger*/) const {
// Clear the *new_value for writing.
@@ -47,13 +42,8 @@ bool StringAppender::Merge(const rocksdb::Slice& /*key*/, const rocksdb::Slice*
static auto string_appender_registrar = rocksdb::ObjectLibrary::Default()->Register<StringAppender>(
"StringAppender",
[] (const std::string& /* uri */, std::unique_ptr<StringAppender>* out, std::string* /* errmsg */) {
- out->reset(new StringAppender());
+ *out = std::make_unique<StringAppender>();
return out->get();
});
-} // namespace repository
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::core::repository
diff --git a/extensions/rocksdb-repos/database/StringAppender.h b/extensions/rocksdb-repos/database/StringAppender.h
index 5e7107378..f283fc4ae 100644
--- a/extensions/rocksdb-repos/database/StringAppender.h
+++ b/extensions/rocksdb-repos/database/StringAppender.h
@@ -23,12 +23,7 @@
#include <algorithm>
#include "rocksdb/merge_operator.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace repository {
+namespace org::apache::nifi::minifi::core::repository {
class StringAppender : public rocksdb::AssociativeMergeOperator {
public:
@@ -47,9 +42,4 @@ class StringAppender : public rocksdb::AssociativeMergeOperator {
}
};
-} // namespace repository
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::core::repository
diff --git a/extensions/rocksdb-repos/encryption/RocksDbEncryptionProvider.cpp b/extensions/rocksdb-repos/encryption/RocksDbEncryptionProvider.cpp
index 4429e4c96..f1a85ac82 100644
--- a/extensions/rocksdb-repos/encryption/RocksDbEncryptionProvider.cpp
+++ b/extensions/rocksdb-repos/encryption/RocksDbEncryptionProvider.cpp
@@ -24,12 +24,7 @@
#include "utils/crypto/ciphers/Aes256Ecb.h"
#include "logging/LoggerConfiguration.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace repository {
+namespace org::apache::nifi::minifi::core::repository {
using utils::crypto::Bytes;
using utils::crypto::Aes256EcbCipher;
@@ -45,7 +40,7 @@ class AES256BlockCipher final : public rocksdb::BlockCipher {
: database_(std::move(database)),
cipher_impl_(std::move(cipher_impl)) {}
- const char *Name() const override {
+ [[nodiscard]] const char *Name() const override {
return "AES256BlockCipher";
}
@@ -70,7 +65,7 @@ class EncryptingEnv : public rocksdb::EnvWrapper {
public:
EncryptingEnv(Env* target, std::shared_ptr<AES256BlockCipher> cipher) : EnvWrapper(target), env_(target), cipher_(std::move(cipher)) {}
- bool hasEqualKey(const EncryptingEnv& other) const {
+ [[nodiscard]] bool hasEqualKey(const EncryptingEnv& other) const {
return *cipher_ == *other.cipher_;
}
@@ -119,9 +114,4 @@ bool EncryptionEq::operator()(const rocksdb::Env* lhs, const rocksdb::Env* rhs)
return lhs_enc->hasEqualKey(*rhs_enc);
}
-} // namespace repository
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::core::repository
diff --git a/extensions/rocksdb-repos/encryption/RocksDbEncryptionProvider.h b/extensions/rocksdb-repos/encryption/RocksDbEncryptionProvider.h
index baaafcdd6..93f561554 100644
--- a/extensions/rocksdb-repos/encryption/RocksDbEncryptionProvider.h
+++ b/extensions/rocksdb-repos/encryption/RocksDbEncryptionProvider.h
@@ -26,12 +26,7 @@
#include "logging/Logger.h"
#include "utils/crypto/EncryptionManager.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace repository {
+namespace org::apache::nifi::minifi::core::repository {
struct DbEncryptionOptions {
std::string database;
@@ -44,9 +39,4 @@ struct EncryptionEq {
bool operator()(const rocksdb::Env* lhs, const rocksdb::Env* rhs) const;
};
-} // namespace repository
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::core::repository
diff --git a/extensions/script/python/PyBaseStream.cpp b/extensions/script/python/PyBaseStream.cpp
index 7c42fd453..bc51c1ec5 100644
--- a/extensions/script/python/PyBaseStream.cpp
+++ b/extensions/script/python/PyBaseStream.cpp
@@ -25,11 +25,7 @@
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace python {
+namespace org::apache::nifi::minifi::python {
PyBaseStream::PyBaseStream(std::shared_ptr<io::BaseStream> stream)
: stream_(std::move(stream)) {
@@ -51,15 +47,11 @@ py::bytes PyBaseStream::read(size_t len) {
std::vector<std::byte> buffer(len);
const auto read = stream_->read(buffer);
- return py::bytes(reinterpret_cast<char *>(buffer.data()), read);
+ return {reinterpret_cast<char *>(buffer.data()), read};
}
size_t PyBaseStream::write(const py::bytes& buf) {
return stream_->write(gsl::make_span(static_cast<std::string>(buf)).as_span<const std::byte>());
}
-} /* namespace python */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::python
diff --git a/extensions/script/python/PyBaseStream.h b/extensions/script/python/PyBaseStream.h
index bc8130daf..ac8bc3dca 100644
--- a/extensions/script/python/PyBaseStream.h
+++ b/extensions/script/python/PyBaseStream.h
@@ -23,11 +23,7 @@
#include "pybind11/embed.h"
#include "io/BaseStream.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace python {
+namespace org::apache::nifi::minifi::python {
namespace py = pybind11;
@@ -43,8 +39,4 @@ class PyBaseStream {
std::shared_ptr<io::BaseStream> stream_;
};
-} /* namespace python */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::python
diff --git a/extensions/script/python/PythonProcessor.cpp b/extensions/script/python/PythonProcessor.cpp
index 88d6d3f59..6b106150a 100644
--- a/extensions/script/python/PythonProcessor.cpp
+++ b/extensions/script/python/PythonProcessor.cpp
@@ -23,13 +23,8 @@
#include "ExecutePythonProcessor.h"
#include "PythonProcessor.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace python {
+namespace org::apache::nifi::minifi::python {
-namespace py = pybind11;
namespace core = org::apache::nifi::minifi::core;
PythonProcessor::PythonProcessor(core::Processor* proc) {
@@ -49,8 +44,4 @@ void PythonProcessor::addProperty(const std::string &name, const std::string &de
processor_->addProperty(name, description, defaultvalue, required, el);
}
-} /* namespace python */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::python
diff --git a/extensions/script/python/PythonProcessor.h b/extensions/script/python/PythonProcessor.h
index f8616f11a..07976d88a 100644
--- a/extensions/script/python/PythonProcessor.h
+++ b/extensions/script/python/PythonProcessor.h
@@ -23,11 +23,7 @@
#include "core/Processor.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace python {
+namespace org::apache::nifi::minifi::python {
namespace processors {
class ExecutePythonProcessor;
@@ -52,8 +48,4 @@ class PythonProcessor {
python::processors::ExecutePythonProcessor* processor_;
};
-} /* namespace python */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::python
diff --git a/extensions/script/python/PythonScriptEngine.cpp b/extensions/script/python/PythonScriptEngine.cpp
index 66e78bed0..301f53f4e 100644
--- a/extensions/script/python/PythonScriptEngine.cpp
+++ b/extensions/script/python/PythonScriptEngine.cpp
@@ -22,11 +22,7 @@
#include "PythonScriptEngine.h"
#include "utils/file/FileUtils.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace python {
+namespace org::apache::nifi::minifi::python {
Interpreter *getInterpreter() {
static Interpreter interpreter;
@@ -37,7 +33,7 @@ PythonScriptEngine::PythonScriptEngine() {
getInterpreter();
py::gil_scoped_acquire gil { };
py::module::import("minifi_native");
- bindings_.reset(new py::dict());
+ bindings_ = std::make_unique<py::dict>();
(*bindings_) = py::globals().attr("copy")();
}
@@ -87,9 +83,4 @@ void PythonScriptEngine::initialize() {
getInterpreter();
}
-} /* namespace python */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
-
+} // namespace org::apache::nifi::minifi::python
diff --git a/extensions/script/python/PythonScriptEngine.h b/extensions/script/python/PythonScriptEngine.h
index f9a507033..25e48b8e0 100644
--- a/extensions/script/python/PythonScriptEngine.h
+++ b/extensions/script/python/PythonScriptEngine.h
@@ -34,11 +34,7 @@
#pragma GCC visibility push(hidden)
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace python {
+namespace org::apache::nifi::minifi::python {
namespace py = pybind11;
@@ -233,10 +229,6 @@ class __attribute__((visibility("default"))) PythonScriptEngine : public script:
std::unique_ptr<py::dict> bindings_;
};
-} /* namespace python */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::python
#pragma GCC visibility pop
diff --git a/extensions/script/tests/ExecutePythonProcessorTests.cpp b/extensions/script/tests/ExecutePythonProcessorTests.cpp
index fe1efc78e..ed0d4d216 100644
--- a/extensions/script/tests/ExecutePythonProcessorTests.cpp
+++ b/extensions/script/tests/ExecutePythonProcessorTests.cpp
@@ -36,7 +36,6 @@ using org::apache::nifi::minifi::utils::putFileToDir;
using org::apache::nifi::minifi::utils::getFileContent;
using org::apache::nifi::minifi::utils::file::getFileNameAndPath;
using org::apache::nifi::minifi::utils::file::concat_path;
-using org::apache::nifi::minifi::utils::file::get_separator;
using org::apache::nifi::minifi::utils::file::resolve;
using org::apache::nifi::minifi::utils::file::getFullPath;
@@ -57,7 +56,7 @@ class ExecutePythonProcessorTestBase {
protected:
void reInitialize() {
- testController_.reset(new TestController());
+ testController_ = std::make_unique<TestController>();
plan_ = testController_->createPlan();
logTestController_.setDebug<TestPlan>();
logTestController_.setDebug<minifi::processors::PutFile>();
diff --git a/extensions/sftp/client/SFTPClient.cpp b/extensions/sftp/client/SFTPClient.cpp
index 07e7f08d8..bb32138b8 100644
--- a/extensions/sftp/client/SFTPClient.cpp
+++ b/extensions/sftp/client/SFTPClient.cpp
@@ -30,11 +30,7 @@
#include "utils/StringUtils.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
+namespace org::apache::nifi::minifi::utils {
#define SFTP_ERROR(CODE) case CODE: \
return #CODE
@@ -138,11 +134,11 @@ LastSFTPError::operator SFTPError() const {
}
-SFTPClient::SFTPClient(const std::string &hostname, uint16_t port, const std::string& username)
+SFTPClient::SFTPClient(std::string hostname, uint16_t port, std::string username)
: logger_(core::logging::LoggerFactory<SFTPClient>::getLogger()),
- hostname_(hostname),
+ hostname_(std::move(hostname)),
port_(port),
- username_(username),
+ username_(std::move(username)),
curl_errorbuffer_(CURL_ERROR_SIZE, '\0') {
easy_ = curl_easy_init();
if (easy_ == nullptr) {
@@ -633,7 +629,7 @@ bool SFTPClient::rename(const std::string& source_path, const std::string& targe
continue;
}
last_error_.setLibssh2Error(libssh2_sftp_last_error(sftp_session_));
- logger_->log_error("Failed to rename remote file \"%s\" to \"%s\", error: %s",
+ logger_->log_error(R"(Failed to rename remote file "%s" to "%s", error: %s)",
source_path.c_str(),
target_path.c_str(),
sftp_strerror(last_error_));
@@ -796,8 +792,4 @@ bool SFTPClient::setAttributes(const std::string& path, const SFTPAttributes& in
return true;
}
-} /* namespace utils */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::utils
diff --git a/extensions/sftp/client/SFTPClient.h b/extensions/sftp/client/SFTPClient.h
index e8ca876f2..4129ec1bf 100644
--- a/extensions/sftp/client/SFTPClient.h
+++ b/extensions/sftp/client/SFTPClient.h
@@ -32,11 +32,7 @@
#include "core/logging/Logger.h"
#include "io/BaseStream.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
+namespace org::apache::nifi::minifi::utils {
SMART_ENUM(SFTPError,
(Ok, "Ok"),
@@ -80,7 +76,7 @@ class LastSFTPError {
class SFTPClient {
public:
- SFTPClient(const std::string &hostname, uint16_t port, const std::string& username);
+ SFTPClient(std::string hostname, uint16_t port, std::string username);
~SFTPClient();
@@ -192,8 +188,4 @@ class SFTPClient {
LastSFTPError last_error_;
};
-} /* namespace utils */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::utils
diff --git a/extensions/sftp/processors/FetchSFTP.cpp b/extensions/sftp/processors/FetchSFTP.cpp
index 549e40c62..eac269d40 100644
--- a/extensions/sftp/processors/FetchSFTP.cpp
+++ b/extensions/sftp/processors/FetchSFTP.cpp
@@ -188,7 +188,7 @@ void FetchSFTP::onTrigger(const std::shared_ptr<core::ProcessContext> &context,
} else {
auto target_path = utils::file::concat_path(move_destination_directory, child_path);
if (!client->rename(remote_file, target_path, false /*overwrite*/)) {
- logger_->log_warn("Completion Strategy is Move File, but failed to move file \"%s\" to \"%s\"", remote_file, target_path);
+ logger_->log_warn(R"(Completion Strategy is Move File, but failed to move file "%s" to "%s")", remote_file, target_path);
}
}
}
diff --git a/extensions/sftp/processors/ListSFTP.cpp b/extensions/sftp/processors/ListSFTP.cpp
index 0c210c056..573eeb50f 100644
--- a/extensions/sftp/processors/ListSFTP.cpp
+++ b/extensions/sftp/processors/ListSFTP.cpp
@@ -280,7 +280,7 @@ bool ListSFTP::filterFile(const std::string& parent_path, const std::string& fil
bool match = false;
match = utils::regexSearch(filename, compiled_file_filter_regex_);
if (!match) {
- logger_->log_debug("Ignoring \"%s/%s\" because it did not match the File Filter Regex \"%s\"",
+ logger_->log_debug(R"(Ignoring "%s/%s" because it did not match the File Filter Regex "%s")",
parent_path.c_str(),
filename.c_str(),
file_filter_regex_);
@@ -302,7 +302,7 @@ bool ListSFTP::filterDirectory(const std::string& parent_path, const std::string
bool match = false;
match = utils::regexSearch(dir_path, compiled_path_filter_regex_);
if (!match) {
- logger_->log_debug("Not recursing into \"%s\" because it did not match the Path Filter Regex \"%s\"",
+ logger_->log_debug(R"(Not recursing into "%s" because it did not match the Path Filter Regex "%s")",
dir_path.c_str(),
path_filter_regex_);
return false;
diff --git a/extensions/sftp/processors/SFTPProcessorBase.cpp b/extensions/sftp/processors/SFTPProcessorBase.cpp
index ed214b509..1c801759f 100644
--- a/extensions/sftp/processors/SFTPProcessorBase.cpp
+++ b/extensions/sftp/processors/SFTPProcessorBase.cpp
@@ -291,9 +291,9 @@ std::unique_ptr<utils::SFTPClient> SFTPProcessorBase::getOrCreateConnection(
const std::string& proxy_password) {
auto client = getConnectionFromCache(connection_cache_key);
if (client == nullptr) {
- client = std::unique_ptr<utils::SFTPClient>(new utils::SFTPClient(connection_cache_key.hostname,
- connection_cache_key.port,
- connection_cache_key.username));
+ client = std::make_unique<utils::SFTPClient>(connection_cache_key.hostname,
+ connection_cache_key.port,
+ connection_cache_key.username);
if (!IsNullOrEmpty(host_key_file_)) {
if (!client->setHostKeyFile(host_key_file_, strict_host_checking_)) {
logger_->log_error("Cannot set host key file");
diff --git a/extensions/sftp/processors/SFTPProcessorBase.h b/extensions/sftp/processors/SFTPProcessorBase.h
index 96d109aca..cc555dd4f 100644
--- a/extensions/sftp/processors/SFTPProcessorBase.h
+++ b/extensions/sftp/processors/SFTPProcessorBase.h
@@ -34,11 +34,7 @@
#include "utils/Id.h"
#include "../client/SFTPClient.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
class SFTPProcessorBase : public core::Processor {
public:
@@ -160,8 +156,4 @@ class SFTPProcessorBase : public core::Processor {
CreateDirectoryHierarchyError createDirectoryHierarchy(utils::SFTPClient& client, const std::string& remote_path, bool disable_directory_listing);
};
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/sftp/tests/FetchSFTPTests.cpp b/extensions/sftp/tests/FetchSFTPTests.cpp
index ad321ddd4..80bc23d00 100644
--- a/extensions/sftp/tests/FetchSFTPTests.cpp
+++ b/extensions/sftp/tests/FetchSFTPTests.cpp
@@ -78,7 +78,7 @@ class FetchSFTPTestsFixture {
REQUIRE(plan);
// Start SFTP server
- sftp_server = std::unique_ptr<SFTPTestServer>(new SFTPTestServer(src_dir));
+ sftp_server = std::make_unique<SFTPTestServer>(src_dir);
REQUIRE(true == sftp_server->start());
// Build MiNiFi processing graph
diff --git a/extensions/sftp/tests/ListSFTPTests.cpp b/extensions/sftp/tests/ListSFTPTests.cpp
index dc7765c63..5f9c7c415 100644
--- a/extensions/sftp/tests/ListSFTPTests.cpp
+++ b/extensions/sftp/tests/ListSFTPTests.cpp
@@ -76,7 +76,7 @@ class ListSFTPTestsFixture {
REQUIRE_FALSE(src_dir.empty());
// Start SFTP server
- sftp_server = std::unique_ptr<SFTPTestServer>(new SFTPTestServer(src_dir));
+ sftp_server = std::make_unique<SFTPTestServer>(src_dir);
REQUIRE(true == sftp_server->start());
// Build MiNiFi processing graph
diff --git a/extensions/sftp/tests/ListThenFetchSFTPTests.cpp b/extensions/sftp/tests/ListThenFetchSFTPTests.cpp
index 7777ab365..b60f9a1fe 100644
--- a/extensions/sftp/tests/ListThenFetchSFTPTests.cpp
+++ b/extensions/sftp/tests/ListThenFetchSFTPTests.cpp
@@ -79,7 +79,7 @@ class ListThenFetchSFTPTestsFixture {
REQUIRE(plan);
// Start SFTP server
- sftp_server = std::unique_ptr<SFTPTestServer>(new SFTPTestServer(src_dir));
+ sftp_server = std::make_unique<SFTPTestServer>(src_dir);
REQUIRE(true == sftp_server->start());
// Build MiNiFi processing graph
diff --git a/extensions/sftp/tests/PutSFTPTests.cpp b/extensions/sftp/tests/PutSFTPTests.cpp
index c69f70f8b..d2977cc5e 100644
--- a/extensions/sftp/tests/PutSFTPTests.cpp
+++ b/extensions/sftp/tests/PutSFTPTests.cpp
@@ -82,7 +82,7 @@ class PutSFTPTestsFixture {
REQUIRE(plan);
// Start SFTP server
- sftp_server = std::unique_ptr<SFTPTestServer>(new SFTPTestServer(dst_dir));
+ sftp_server = std::make_unique<SFTPTestServer>(dst_dir);
REQUIRE(true == sftp_server->start());
// Build MiNiFi processing graph
diff --git a/extensions/sftp/tests/tools/SFTPTestServer.cpp b/extensions/sftp/tests/tools/SFTPTestServer.cpp
index d21bba3a8..98cf0cebc 100644
--- a/extensions/sftp/tests/tools/SFTPTestServer.cpp
+++ b/extensions/sftp/tests/tools/SFTPTestServer.cpp
@@ -22,13 +22,14 @@
#include <fstream>
#include <vector>
#include <thread>
+#include <utility>
#ifndef WIN32
-#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/types.h>
+#include <csignal>
#include <cstring>
#include <cerrno>
#endif
@@ -37,10 +38,10 @@
namespace utils = org::apache::nifi::minifi::utils;
-SFTPTestServer::SFTPTestServer(const std::string& working_directory,
+SFTPTestServer::SFTPTestServer(std::string working_directory,
const std::string& host_key_file /*= "resources/host.pem"*/,
const std::string& jar_path /*= "tools/sftp-test-server/target/SFTPTestServer-1.0.0.jar"*/)
- : working_directory_(working_directory),
+ : working_directory_(std::move(working_directory)),
started_(false),
port_(0U)
#ifndef WIN32
diff --git a/extensions/sftp/tests/tools/SFTPTestServer.h b/extensions/sftp/tests/tools/SFTPTestServer.h
index 5f4e9fd9c..326976651 100644
--- a/extensions/sftp/tests/tools/SFTPTestServer.h
+++ b/extensions/sftp/tests/tools/SFTPTestServer.h
@@ -33,7 +33,7 @@ std::string get_sftp_test_dir();
class SFTPTestServer {
public:
- SFTPTestServer(const std::string& working_directory,
+ SFTPTestServer(std::string working_directory,
const std::string& host_key_file = "resources/host.pem",
const std::string& jar_path = "tools/sftp-test-server/target/SFTPTestServer-1.0.0.jar");
~SFTPTestServer();
diff --git a/extensions/standard-processors/controllers/UnorderedMapPersistableKeyValueStoreService.cpp b/extensions/standard-processors/controllers/UnorderedMapPersistableKeyValueStoreService.cpp
index 227bcd017..5f98b3c03 100644
--- a/extensions/standard-processors/controllers/UnorderedMapPersistableKeyValueStoreService.cpp
+++ b/extensions/standard-processors/controllers/UnorderedMapPersistableKeyValueStoreService.cpp
@@ -110,7 +110,7 @@ bool UnorderedMapPersistableKeyValueStoreService::parseLine(const std::string& l
current << '=';
break;
default:
- logger_->log_error("Invalid escape sequence in \"%s\": \"\\%c\"", line.c_str(), c);
+ logger_->log_error(R"(Invalid escape sequence in "%s": "\%c")", line.c_str(), c);
return false;
}
in_escape_sequence = false;
@@ -119,7 +119,7 @@ bool UnorderedMapPersistableKeyValueStoreService::parseLine(const std::string& l
in_escape_sequence = true;
} else if (c == '=') {
if (key_complete) {
- logger_->log_error("Unterminated \'=\' in line \"%s\"", line.c_str());
+ logger_->log_error(R"(Unterminated '=' in line "%s")", line.c_str());
return false;
} else {
key_complete = true;
@@ -139,7 +139,7 @@ bool UnorderedMapPersistableKeyValueStoreService::parseLine(const std::string& l
}
key = key_ss.str();
if (key.empty()) {
- logger_->log_error("Line with empty key found in \"%s\": \"%s\"", file_.c_str(), line.c_str());
+ logger_->log_error(R"(Line with empty key found in "%s": "%s")", file_.c_str(), line.c_str());
return false;
}
value = value_ss.str();
@@ -245,7 +245,7 @@ bool UnorderedMapPersistableKeyValueStoreService::load() {
try {
format_version = std::stoi(value);
} catch (...) {
- logger_->log_error("Invalid format version number found in \"%s\": \"%s\"", file_.c_str(), value.c_str());
+ logger_->log_error(R"(Invalid format version number found in "%s": "%s")", file_.c_str(), value.c_str());
return false;
}
if (format_version > FORMAT_VERSION) {
diff --git a/extensions/standard-processors/processors/FetchFile.cpp b/extensions/standard-processors/processors/FetchFile.cpp
index 488baf516..b50afd420 100644
--- a/extensions/standard-processors/processors/FetchFile.cpp
+++ b/extensions/standard-processors/processors/FetchFile.cpp
@@ -16,7 +16,7 @@
*/
#include "FetchFile.h"
-#include <errno.h>
+#include <cerrno>
#include <filesystem>
#include <utility>
diff --git a/extensions/standard-processors/processors/GenerateFlowFile.cpp b/extensions/standard-processors/processors/GenerateFlowFile.cpp
index 49c9381e8..410fae30c 100644
--- a/extensions/standard-processors/processors/GenerateFlowFile.cpp
+++ b/extensions/standard-processors/processors/GenerateFlowFile.cpp
@@ -20,7 +20,7 @@
#include "GenerateFlowFile.h"
-#include <time.h>
+#include <ctime>
#include <chrono>
#include <limits>
@@ -42,11 +42,7 @@
#include "core/TypedValues.h"
#include "core/Resource.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
const char *GenerateFlowFile::DATA_FORMAT_TEXT = "Text";
const core::Property GenerateFlowFile::FileSize(
core::PropertyBuilder::createProperty("File Size")->withDescription("The size of the file that will be used")->isRequired(false)->withDefaultValue<core::DataSizeValue>("1 kB")->build());
@@ -87,7 +83,7 @@ void generateData(std::vector<char>& data, bool textData = false) {
std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
} else {
std::uniform_int_distribution<> distr(std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
- auto rand = std::bind(distr, eng);
+ auto rand = [&distr, &eng] { return distr(eng); };
std::generate_n(data.begin(), data.size(), rand);
}
}
@@ -149,8 +145,4 @@ void GenerateFlowFile::onTrigger(core::ProcessContext* /*context*/, core::Proces
REGISTER_RESOURCE(GenerateFlowFile, Processor);
-} // namespace processors
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/standard-processors/processors/GenerateFlowFile.h b/extensions/standard-processors/processors/GenerateFlowFile.h
index 8e63a2e85..65573ec04 100644
--- a/extensions/standard-processors/processors/GenerateFlowFile.h
+++ b/extensions/standard-processors/processors/GenerateFlowFile.h
@@ -17,8 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_GENERATEFLOWFILE_H_
-#define EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_GENERATEFLOWFILE_H_
+#pragma once
#include <memory>
#include <string>
@@ -32,11 +31,7 @@
#include "utils/gsl.h"
#include "utils/Export.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
class GenerateFlowFile : public core::Processor {
public:
@@ -96,9 +91,4 @@ class GenerateFlowFile : public core::Processor {
std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<GenerateFlowFile>::getLogger();
};
-} // namespace processors
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-#endif // EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_GENERATEFLOWFILE_H_
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/standard-processors/processors/GetTCP.cpp b/extensions/standard-processors/processors/GetTCP.cpp
index 1a7ecbe95..d4d7ac93d 100644
--- a/extensions/standard-processors/processors/GetTCP.cpp
+++ b/extensions/standard-processors/processors/GetTCP.cpp
@@ -40,11 +40,7 @@
#include "core/PropertyBuilder.h"
#include "core/Resource.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
const char *DataHandler::SOURCE_ENDPOINT_ATTRIBUTE = "source.endpoint";
@@ -142,7 +138,7 @@ void GetTCP::onSchedule(const std::shared_ptr<core::ProcessContext> &context, co
logger_->log_debug("Reconnect interval using default value of %" PRId64 " ms", reconnect_interval_.count());
}
- handler_ = std::unique_ptr<DataHandler>(new DataHandler(sessionFactory));
+ handler_ = std::make_unique<DataHandler>(sessionFactory);
f_ex = [&] {
std::unique_ptr<io::Socket> socket_ptr;
@@ -300,8 +296,4 @@ int16_t GetTCP::getMetricNodes(std::vector<std::shared_ptr<state::response::Resp
REGISTER_RESOURCE(GetTCP, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/standard-processors/processors/GetTCP.h b/extensions/standard-processors/processors/GetTCP.h
index 67ec91f6e..f42fa59de 100644
--- a/extensions/standard-processors/processors/GetTCP.h
+++ b/extensions/standard-processors/processors/GetTCP.h
@@ -15,8 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_GETTCP_H_
-#define EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_GETTCP_H_
+#pragma once
#include <map>
#include <memory>
@@ -38,11 +37,7 @@
#include "utils/gsl.h"
#include "utils/Export.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
class SocketAfterExecute : public utils::AfterExecute<int> {
public:
@@ -237,10 +232,4 @@ class GetTCP : public core::Processor, public state::response::MetricsNodeSource
utils::ThreadPool<int> client_thread_pool_;
};
-} // namespace processors
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_GETTCP_H_
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/standard-processors/processors/LogAttribute.cpp b/extensions/standard-processors/processors/LogAttribute.cpp
index a1828733f..dec826cb9 100644
--- a/extensions/standard-processors/processors/LogAttribute.cpp
+++ b/extensions/standard-processors/processors/LogAttribute.cpp
@@ -18,8 +18,8 @@
* limitations under the License.
*/
#include "LogAttribute.h"
-#include <time.h>
-#include <string.h>
+#include <ctime>
+#include <cstring>
#include <memory>
#include <string>
#include <vector>
@@ -34,11 +34,7 @@
#include "core/PropertyBuilder.h"
#include "core/Resource.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
const core::Property LogAttribute::LogLevel(core::PropertyBuilder::createProperty("Log Level")->withDescription("The Log Level to use when logging the Attributes")->withAllowableValues<std::string>(
{"info", "trace", "error", "warn", "debug" })->build());
@@ -179,8 +175,4 @@ void LogAttribute::onTrigger(const std::shared_ptr<core::ProcessContext> &contex
REGISTER_RESOURCE(LogAttribute, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/standard-processors/processors/LogAttribute.h b/extensions/standard-processors/processors/LogAttribute.h
index 4f5bb9591..ab3ee71c4 100644
--- a/extensions/standard-processors/processors/LogAttribute.h
+++ b/extensions/standard-processors/processors/LogAttribute.h
@@ -17,8 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_LOGATTRIBUTE_H_
-#define EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_LOGATTRIBUTE_H_
+#pragma once
#include <memory>
#include <string>
@@ -33,11 +32,7 @@
#include "utils/gsl.h"
#include "utils/Export.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
class LogAttribute : public core::Processor {
public:
@@ -124,10 +119,4 @@ class LogAttribute : public core::Processor {
std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<LogAttribute>::getLogger();
};
-} // namespace processors
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_LOGATTRIBUTE_H_
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp b/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp
index 318e95fc7..f71538e76 100644
--- a/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp
+++ b/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <signal.h>
#include <sys/stat.h>
+#include <csignal>
#include <chrono>
#include <thread>
#undef NDEBUG
diff --git a/extensions/standard-processors/tests/integration/TLSClientSocketSupportedProtocolsTest.cpp b/extensions/standard-processors/tests/integration/TLSClientSocketSupportedProtocolsTest.cpp
index 6cc643c3f..711db9253 100644
--- a/extensions/standard-processors/tests/integration/TLSClientSocketSupportedProtocolsTest.cpp
+++ b/extensions/standard-processors/tests/integration/TLSClientSocketSupportedProtocolsTest.cpp
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <signal.h>
#include <sys/stat.h>
+#include <csignal>
#include <chrono>
#include <thread>
#include <filesystem>
@@ -54,8 +54,8 @@ class SimpleSSLTestServerTLSv1_2 : public SimpleSSLTestServer {
class TLSClientSocketSupportedProtocolsTest {
public:
- explicit TLSClientSocketSupportedProtocolsTest(const std::filesystem::path& key_dir)
- : key_dir_(key_dir), configuration_(std::make_shared<minifi::Configure>()) {
+ explicit TLSClientSocketSupportedProtocolsTest(std::filesystem::path key_dir)
+ : key_dir_(std::move(key_dir)), configuration_(std::make_shared<minifi::Configure>()) {
}
void run() {
diff --git a/extensions/standard-processors/tests/integration/TLSServerSocketSupportedProtocolsTest.cpp b/extensions/standard-processors/tests/integration/TLSServerSocketSupportedProtocolsTest.cpp
index b52a4e959..41b919798 100644
--- a/extensions/standard-processors/tests/integration/TLSServerSocketSupportedProtocolsTest.cpp
+++ b/extensions/standard-processors/tests/integration/TLSServerSocketSupportedProtocolsTest.cpp
@@ -18,8 +18,8 @@
#ifndef WIN32
#include <arpa/inet.h>
#endif
-#include <signal.h>
#include <sys/stat.h>
+#include <csignal>
#include <chrono>
#include <thread>
#include <cerrno>
@@ -119,9 +119,9 @@ void log_addrinfo(addrinfo* const ai, minifi::core::logging::Logger& logger) {
class SimpleSSLTestClient {
public:
- SimpleSSLTestClient(const SSL_METHOD* method, const std::string& host, const std::string& port) :
- host_(host),
- port_(port) {
+ SimpleSSLTestClient(const SSL_METHOD* method, std::string host, std::string port) :
+ host_(std::move(host)),
+ port_(std::move(port)) {
ctx_ = SSL_CTX_new(method);
sfd_ = openConnection(host_.c_str(), port_.c_str(), *logger_);
if (ctx_ != nullptr)
@@ -213,8 +213,8 @@ class SimpleSSLTestClientTLSv1_2 : public SimpleSSLTestClient {
class TLSServerSocketSupportedProtocolsTest {
public:
- explicit TLSServerSocketSupportedProtocolsTest(const std::string& key_dir)
- : is_running_(false), key_dir_(key_dir), configuration_(std::make_shared<minifi::Configure>()) {
+ explicit TLSServerSocketSupportedProtocolsTest(std::string key_dir)
+ : is_running_(false), key_dir_(std::move(key_dir)), configuration_(std::make_shared<minifi::Configure>()) {
}
~TLSServerSocketSupportedProtocolsTest() {
diff --git a/extensions/standard-processors/tests/integration/TailFileTest.cpp b/extensions/standard-processors/tests/integration/TailFileTest.cpp
index 0114693ab..c1c7ff678 100644
--- a/extensions/standard-processors/tests/integration/TailFileTest.cpp
+++ b/extensions/standard-processors/tests/integration/TailFileTest.cpp
@@ -34,7 +34,7 @@
#include "utils/IntegrationTestUtils.h"
#include "utils/TestUtils.h"
-using std::literals::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
class TailFileTestHarness : public IntegrationBase {
public:
diff --git a/extensions/standard-processors/tests/unit/ConfigurationTests.cpp b/extensions/standard-processors/tests/unit/ConfigurationTests.cpp
index d395905c5..463f86212 100644
--- a/extensions/standard-processors/tests/unit/ConfigurationTests.cpp
+++ b/extensions/standard-processors/tests/unit/ConfigurationTests.cpp
@@ -20,8 +20,6 @@
#include "properties/Configuration.h"
-using org::apache::nifi::minifi::Configuration;
-
namespace org::apache::nifi::minifi::test {
TEST_CASE("Configuration can merge lists of property names", "[mergeProperties]") {
diff --git a/extensions/standard-processors/tests/unit/FetchFileTests.cpp b/extensions/standard-processors/tests/unit/FetchFileTests.cpp
index 2643edc4f..19deff586 100644
--- a/extensions/standard-processors/tests/unit/FetchFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/FetchFileTests.cpp
@@ -40,7 +40,7 @@ class FetchFileTestFixture {
~FetchFileTestFixture();
protected:
- std::unordered_multiset<std::string> getDirContents(const std::string& dir_path) const;
+ [[nodiscard]] std::unordered_multiset<std::string> getDirContents(const std::string& dir_path) const;
std::shared_ptr<minifi::processors::FetchFile> fetch_file_processor_;
std::shared_ptr<minifi::test::SingleProcessorTestController> test_controller_;
diff --git a/extensions/standard-processors/tests/unit/GetFileTests.cpp b/extensions/standard-processors/tests/unit/GetFileTests.cpp
index d6a33c51e..561f7d29d 100644
--- a/extensions/standard-processors/tests/unit/GetFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/GetFileTests.cpp
@@ -40,8 +40,8 @@ namespace {
class GetFileTestController {
public:
GetFileTestController();
- std::string getFullPath(const std::string filename) const;
- std::string getInputFilePath() const;
+ [[nodiscard]] std::string getFullPath(const std::string filename) const;
+ [[nodiscard]] std::string getInputFilePath() const;
void setProperty(const core::Property& property, const std::string& value);
void runSession();
diff --git a/extensions/standard-processors/tests/unit/ProcessorTests.cpp b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
index 600c1c967..65939a2d0 100644
--- a/extensions/standard-processors/tests/unit/ProcessorTests.cpp
+++ b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
@@ -500,8 +500,6 @@ class TestProcessorNoContent : public minifi::core::Processor {
explicit TestProcessorNoContent(const std::string& name, const utils::Identifier& uuid = {})
: Processor(name, uuid) {
}
- virtual ~TestProcessorNoContent() {
- }
static constexpr const char* Description = "test resource";
static auto properties() { return std::array<core::Property, 0>{}; }
diff --git a/extensions/standard-processors/tests/unit/RetryFlowFileTests.cpp b/extensions/standard-processors/tests/unit/RetryFlowFileTests.cpp
index 6cb46c566..1729b665e 100644
--- a/extensions/standard-processors/tests/unit/RetryFlowFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/RetryFlowFileTests.cpp
@@ -56,7 +56,7 @@ class RetryFlowFileTest {
protected:
void reInitialize() {
- testController_.reset(new TestController());
+ testController_ = std::make_unique<TestController>();
plan_ = testController_->createPlan();
logTestController_.setDebug<TestPlan>();
logTestController_.setDebug<GenerateFlowFile>();
diff --git a/libminifi/include/Connection.h b/libminifi/include/Connection.h
index b41046f35..e1196c92e 100644
--- a/libminifi/include/Connection.h
+++ b/libminifi/include/Connection.h
@@ -17,8 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_CONNECTION_H_
-#define LIBMINIFI_INCLUDE_CONNECTION_H_
+#pragma once
#include <memory>
#include <set>
@@ -36,18 +35,15 @@
#include "core/Repository.h"
#include "utils/FlowFileQueue.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
+namespace org::apache::nifi::minifi {
class Connection : public core::Connectable {
public:
- explicit Connection(const std::shared_ptr<core::Repository> &flow_repository, const std::shared_ptr<core::ContentRepository> &content_repo, const std::string &name);
- explicit Connection(const std::shared_ptr<core::Repository> &flow_repository, const std::shared_ptr<core::ContentRepository> &content_repo, const std::string &name, const utils::Identifier &uuid);
- explicit Connection(const std::shared_ptr<core::Repository> &flow_repository, const std::shared_ptr<core::ContentRepository> &content_repo, const std::string &name, const utils::Identifier &uuid,
+ explicit Connection(std::shared_ptr<core::Repository> flow_repository, std::shared_ptr<core::ContentRepository> content_repo, const std::string &name);
+ explicit Connection(std::shared_ptr<core::Repository> flow_repository, std::shared_ptr<core::ContentRepository> content_repo, const std::string &name, const utils::Identifier &uuid);
+ explicit Connection(std::shared_ptr<core::Repository> flow_repository, std::shared_ptr<core::ContentRepository> content_repo, const std::string &name, const utils::Identifier &uuid,
const utils::Identifier &srcUUID);
- explicit Connection(const std::shared_ptr<core::Repository> &flow_repository, const std::shared_ptr<core::ContentRepository> &content_repo, const std::string &name, const utils::Identifier &uuid,
+ explicit Connection(std::shared_ptr<core::Repository> flow_repository, std::shared_ptr<core::ContentRepository> content_repo, const std::string &name, const utils::Identifier &uuid,
const utils::Identifier &srcUUID, const utils::Identifier &destUUID);
// Destructor
~Connection() override = default;
@@ -208,8 +204,4 @@ class Connection : public core::Connectable {
Connection(const Connection &parent);
Connection &operator=(const Connection &parent);
};
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-#endif // LIBMINIFI_INCLUDE_CONNECTION_H_
+} // namespace org::apache::nifi::minifi
diff --git a/libminifi/include/FlowFileRecord.h b/libminifi/include/FlowFileRecord.h
index 268a4abdb..5ddd4c520 100644
--- a/libminifi/include/FlowFileRecord.h
+++ b/libminifi/include/FlowFileRecord.h
@@ -17,8 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_FLOWFILERECORD_H_
-#define LIBMINIFI_INCLUDE_FLOWFILERECORD_H_
+#pragma once
#include <memory>
#include <string>
@@ -81,5 +80,3 @@ class FlowFileRecord : public core::FlowFile {
};
} // namespace org::apache::nifi::minifi
-
-#endif // LIBMINIFI_INCLUDE_FLOWFILERECORD_H_
diff --git a/libminifi/include/c2/HeartbeatJsonSerializer.h b/libminifi/include/c2/HeartbeatJsonSerializer.h
index eed48c870..f8f87d0b1 100644
--- a/libminifi/include/c2/HeartbeatJsonSerializer.h
+++ b/libminifi/include/c2/HeartbeatJsonSerializer.h
@@ -24,11 +24,7 @@
#include "rapidjson/document.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace c2 {
+namespace org::apache::nifi::minifi::c2 {
class HeartbeatJsonSerializer {
public:
@@ -41,8 +37,4 @@ class HeartbeatJsonSerializer {
virtual ~HeartbeatJsonSerializer() = default;
};
-} // namespace c2
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::c2
diff --git a/libminifi/include/core/ProcessSession.h b/libminifi/include/core/ProcessSession.h
index ed8ba3355..439b23431 100644
--- a/libminifi/include/core/ProcessSession.h
+++ b/libminifi/include/core/ProcessSession.h
@@ -15,8 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_CORE_PROCESSSESSION_H_
-#define LIBMINIFI_INCLUDE_CORE_PROCESSSESSION_H_
+#pragma once
#include <memory>
#include <string>
@@ -39,11 +38,7 @@
#include "provenance/Provenance.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
namespace detail {
struct ReadBufferResult {
int64_t status;
@@ -202,9 +197,4 @@ class ProcessSession : public ReferenceContainer {
static std::shared_ptr<utils::IdGenerator> id_generator_;
};
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-#endif // LIBMINIFI_INCLUDE_CORE_PROCESSSESSION_H_
+} // namespace org::apache::nifi::minifi::core
diff --git a/libminifi/include/core/logging/LoggerConfiguration.h b/libminifi/include/core/logging/LoggerConfiguration.h
index f201260f7..7b314c026 100644
--- a/libminifi/include/core/logging/LoggerConfiguration.h
+++ b/libminifi/include/core/logging/LoggerConfiguration.h
@@ -18,8 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_CORE_LOGGING_LOGGERCONFIGURATION_H_
-#define LIBMINIFI_INCLUDE_CORE_LOGGING_LOGGERCONFIGURATION_H_
+#pragma once
#include <memory>
#include <vector>
@@ -43,12 +42,7 @@ class LoggerTestAccessor;
class LogTestController;
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace logging {
+namespace org::apache::nifi::minifi::core::logging {
namespace internal {
struct LoggerNamespace {
@@ -175,11 +169,4 @@ class LoggerFactory {
}
};
-} // namespace logging
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // LIBMINIFI_INCLUDE_CORE_LOGGING_LOGGERCONFIGURATION_H_
+} // namespace org::apache::nifi::minifi::core::logging
diff --git a/libminifi/include/sitetosite/Peer.h b/libminifi/include/sitetosite/Peer.h
index 684f86e6e..24f525cc9 100644
--- a/libminifi/include/sitetosite/Peer.h
+++ b/libminifi/include/sitetosite/Peer.h
@@ -15,8 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_SITETOSITE_PEER_H_
-#define LIBMINIFI_INCLUDE_SITETOSITE_PEER_H_
+#pragma once
#include <errno.h>
#include <stdio.h>
@@ -38,11 +37,7 @@
#include "utils/HTTPClient.h"
#include "utils/TimeUtil.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace sitetosite {
+namespace org::apache::nifi::minifi::sitetosite {
class Peer {
public:
@@ -351,10 +346,4 @@ class SiteToSitePeer : public org::apache::nifi::minifi::io::BaseStream {
std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<SiteToSitePeer>::getLogger();
};
-} // namespace sitetosite
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // LIBMINIFI_INCLUDE_SITETOSITE_PEER_H_
+} // namespace org::apache::nifi::minifi::sitetosite
diff --git a/libminifi/include/sitetosite/RawSocketProtocol.h b/libminifi/include/sitetosite/RawSocketProtocol.h
index 89f2b7694..6bc9c566f 100644
--- a/libminifi/include/sitetosite/RawSocketProtocol.h
+++ b/libminifi/include/sitetosite/RawSocketProtocol.h
@@ -17,8 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_SITETOSITE_RAWSOCKETPROTOCOL_H_
-#define LIBMINIFI_INCLUDE_SITETOSITE_RAWSOCKETPROTOCOL_H_
+#pragma once
#include <errno.h>
#include <stdio.h>
@@ -45,11 +44,7 @@
#include "SiteToSiteClient.h"
#include "utils/Id.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace sitetosite {
+namespace org::apache::nifi::minifi::sitetosite {
/**
@@ -194,9 +189,4 @@ class RawSiteToSiteClient : public sitetosite::SiteToSiteClient {
static std::shared_ptr<utils::IdGenerator> id_generator_;
};
-} // namespace sitetosite
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-#endif // LIBMINIFI_INCLUDE_SITETOSITE_RAWSOCKETPROTOCOL_H_
+} // namespace org::apache::nifi::minifi::sitetosite
diff --git a/libminifi/include/utils/Id.h b/libminifi/include/utils/Id.h
index d94d4695c..df5edb8a8 100644
--- a/libminifi/include/utils/Id.h
+++ b/libminifi/include/utils/Id.h
@@ -14,8 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_UTILS_ID_H_
-#define LIBMINIFI_INCLUDE_UTILS_ID_H_
+#pragma once
#include <atomic>
#include <cstddef>
@@ -45,11 +44,7 @@ class uuid;
#define UUID_TIME_STR "time"
#define UUID_WINDOWS_STR "windows"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
+namespace org::apache::nifi::minifi::utils {
class Identifier {
friend struct IdentifierTestAccessor;
@@ -136,10 +131,4 @@ class NonRepeatingStringGenerator {
std::string prefix_{std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count()) + "-"};
};
-} // namespace utils
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // LIBMINIFI_INCLUDE_UTILS_ID_H_
+} // namespace org::apache::nifi::minifi::utils
diff --git a/libminifi/include/utils/RegexUtils.h b/libminifi/include/utils/RegexUtils.h
index ff8b95238..410af0670 100644
--- a/libminifi/include/utils/RegexUtils.h
+++ b/libminifi/include/utils/RegexUtils.h
@@ -125,14 +125,15 @@ class Regex {
enum class Mode { ICASE };
Regex();
- explicit Regex(const std::string &value);
- explicit Regex(const std::string &value,
- const std::vector<Mode> &mode);
+ explicit Regex(std::string value);
+ Regex(std::string value, const std::vector<Mode> &mode);
Regex(const Regex &);
Regex& operator=(const Regex &);
Regex(Regex&& other);
Regex& operator=(Regex&& other);
+#ifndef NO_MORE_REGFREEE
~Regex();
+#endif
private:
std::string regex_str_;
diff --git a/libminifi/include/utils/ThreadPool.h b/libminifi/include/utils/ThreadPool.h
index fc4b64d91..37aa27fdd 100644
--- a/libminifi/include/utils/ThreadPool.h
+++ b/libminifi/include/utils/ThreadPool.h
@@ -14,8 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_UTILS_THREADPOOL_H_
-#define LIBMINIFI_INCLUDE_UTILS_THREADPOOL_H_
+#pragma once
#include <algorithm>
#include <atomic>
@@ -41,11 +40,7 @@
#include "controllers/ThreadManagementService.h"
#include "core/controller/ControllerService.h"
#include "core/controller/ControllerServiceProvider.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
+namespace org::apache::nifi::minifi::utils {
using TaskId = std::string;
@@ -355,10 +350,4 @@ class ThreadPool {
void manage_delayed_queue();
};
-} // namespace utils
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // LIBMINIFI_INCLUDE_UTILS_THREADPOOL_H_
+} // namespace org::apache::nifi::minifi::utils
diff --git a/libminifi/include/utils/file/PathUtils.h b/libminifi/include/utils/file/PathUtils.h
index fe07e28ca..ebbf19830 100644
--- a/libminifi/include/utils/file/PathUtils.h
+++ b/libminifi/include/utils/file/PathUtils.h
@@ -14,8 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_UTILS_FILE_PATHUTILS_H_
-#define LIBMINIFI_INCLUDE_UTILS_FILE_PATHUTILS_H_
+#pragma once
#include <climits>
#include <cctype>
@@ -26,12 +25,7 @@
#include <system_error>
#include <utility>
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
-namespace file {
+namespace org::apache::nifi::minifi::utils::file {
namespace PathUtils = ::org::apache::nifi::minifi::utils::file;
using path = const char*;
@@ -119,11 +113,4 @@ class filesystem_error : public std::system_error {
space_info space(path);
space_info space(path, std::error_code&) noexcept;
-} // namespace file
-} // namespace utils
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // LIBMINIFI_INCLUDE_UTILS_FILE_PATHUTILS_H_
+} // namespace org::apache::nifi::minifi::utils::file
diff --git a/libminifi/src/Connection.cpp b/libminifi/src/Connection.cpp
index 9432eb1b6..1de108b73 100644
--- a/libminifi/src/Connection.cpp
+++ b/libminifi/src/Connection.cpp
@@ -18,7 +18,7 @@
* limitations under the License.
*/
#include "Connection.h"
-#include <time.h>
+#include <ctime>
#include <vector>
#include <queue>
#include <memory>
@@ -35,40 +35,36 @@
using namespace std::literals::chrono_literals;
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
+namespace org::apache::nifi::minifi {
-Connection::Connection(const std::shared_ptr<core::Repository> &flow_repository, const std::shared_ptr<core::ContentRepository> &content_repo, const std::string &name)
+Connection::Connection(std::shared_ptr<core::Repository> flow_repository, std::shared_ptr<core::ContentRepository> content_repo, const std::string &name)
: core::Connectable(name),
- flow_repository_(flow_repository),
- content_repo_(content_repo) {
+ flow_repository_(std::move(flow_repository)),
+ content_repo_(std::move(content_repo)) {
logger_->log_debug("Connection %s created", name_);
}
-Connection::Connection(const std::shared_ptr<core::Repository> &flow_repository, const std::shared_ptr<core::ContentRepository> &content_repo, const std::string &name, const utils::Identifier &uuid)
+Connection::Connection(std::shared_ptr<core::Repository> flow_repository, std::shared_ptr<core::ContentRepository> content_repo, const std::string &name, const utils::Identifier &uuid)
: core::Connectable(name, uuid),
- flow_repository_(flow_repository),
- content_repo_(content_repo) {
+ flow_repository_(std::move(flow_repository)),
+ content_repo_(std::move(content_repo)) {
logger_->log_debug("Connection %s created", name_);
}
-Connection::Connection(const std::shared_ptr<core::Repository> &flow_repository, const std::shared_ptr<core::ContentRepository> &content_repo, const std::string &name, const utils::Identifier &uuid,
+Connection::Connection(std::shared_ptr<core::Repository> flow_repository, std::shared_ptr<core::ContentRepository> content_repo, const std::string &name, const utils::Identifier &uuid,
const utils::Identifier& srcUUID)
: core::Connectable(name, uuid),
- flow_repository_(flow_repository),
- content_repo_(content_repo) {
+ flow_repository_(std::move(flow_repository)),
+ content_repo_(std::move(content_repo)) {
src_uuid_ = srcUUID;
logger_->log_debug("Connection %s created", name_);
}
-Connection::Connection(const std::shared_ptr<core::Repository> &flow_repository, const std::shared_ptr<core::ContentRepository> &content_repo, const std::string &name, const utils::Identifier &uuid,
+Connection::Connection(std::shared_ptr<core::Repository> flow_repository, std::shared_ptr<core::ContentRepository> content_repo, const std::string &name, const utils::Identifier &uuid,
const utils::Identifier& srcUUID, const utils::Identifier& destUUID)
: core::Connectable(name, uuid),
- flow_repository_(flow_repository),
- content_repo_(content_repo) {
-
+ flow_repository_(std::move(flow_repository)),
+ content_repo_(std::move(content_repo)) {
src_uuid_ = srcUUID;
dest_uuid_ = destUUID;
logger_->log_debug("Connection %s created", name_);
@@ -187,7 +183,4 @@ void Connection::drain(bool delete_permanently) {
logger_->log_debug("Drain connection %s", name_);
}
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi
diff --git a/libminifi/src/FlowFileRecord.cpp b/libminifi/src/FlowFileRecord.cpp
index 9c6ef8c8b..b8f6f0f51 100644
--- a/libminifi/src/FlowFileRecord.cpp
+++ b/libminifi/src/FlowFileRecord.cpp
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <time.h>
+#include <ctime>
#include <cstdio>
#include <vector>
#include <queue>
@@ -33,10 +33,7 @@
#include "core/Repository.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
+namespace org::apache::nifi::minifi {
std::shared_ptr<core::logging::Logger> FlowFileRecord::logger_ = core::logging::LoggerFactory<FlowFileRecord>::getLogger();
std::atomic<uint64_t> FlowFileRecord::local_flow_seq_number_(0);
@@ -274,7 +271,4 @@ std::shared_ptr<FlowFileRecord> FlowFileRecord::DeSerialize(io::InputStream& inS
return file;
}
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi
diff --git a/libminifi/src/c2/ControllerSocketProtocol.cpp b/libminifi/src/c2/ControllerSocketProtocol.cpp
index 91dbbb4c3..ded4a1488 100644
--- a/libminifi/src/c2/ControllerSocketProtocol.cpp
+++ b/libminifi/src/c2/ControllerSocketProtocol.cpp
@@ -232,6 +232,8 @@ void ControllerSocketProtocol::initialize(core::controller::ControllerServicePro
}
}
break;
+ default:
+ logger_->log_error("Unhandled C2 operation: %s", std::to_string(head));
}
};
server_socket_->registerCallback(check, handler);
diff --git a/libminifi/src/c2/HeartbeatJsonSerializer.cpp b/libminifi/src/c2/HeartbeatJsonSerializer.cpp
index 7ec3ce4c3..696a0ec98 100644
--- a/libminifi/src/c2/HeartbeatJsonSerializer.cpp
+++ b/libminifi/src/c2/HeartbeatJsonSerializer.cpp
@@ -22,11 +22,7 @@
#include "rapidjson/stringbuffer.h"
#include "rapidjson/prettywriter.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace c2 {
+namespace org::apache::nifi::minifi::c2 {
static void serializeOperationInfo(rapidjson::Value& target, const C2Payload& payload, rapidjson::Document::AllocatorType& alloc) {
gsl_Expects(target.IsObject());
@@ -241,7 +237,7 @@ class NamedValueMap {
}
return data_.end();
}
- Container::const_iterator find(const std::string& key) const {
+ [[nodiscard]] Container::const_iterator find(const std::string& key) const {
for (auto it = data_.begin(); it != data_.end(); ++it) {
if (it->name == key) return it;
}
@@ -297,8 +293,4 @@ rapidjson::Value HeartbeatJsonSerializer::serializeJsonPayload(const C2Payload&
return json_payload;
}
-} // namespace c2
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::c2
diff --git a/libminifi/src/c2/protocols/RESTProtocol.cpp b/libminifi/src/c2/protocols/RESTProtocol.cpp
index 2dcde522f..7ef042a09 100644
--- a/libminifi/src/c2/protocols/RESTProtocol.cpp
+++ b/libminifi/src/c2/protocols/RESTProtocol.cpp
@@ -80,7 +80,7 @@ C2Payload RESTProtocol::parseJsonResponse(const C2Payload &payload, gsl::span<co
// neither must be there. We don't want assign array yet and cause an assertion error
if (size == 0)
- return C2Payload(payload.getOperation(), state::UpdateState::READ_COMPLETE);
+ return {payload.getOperation(), state::UpdateState::READ_COMPLETE};
C2Payload new_payload(payload.getOperation(), state::UpdateState::NESTED);
if (!identifier.empty())
@@ -136,7 +136,7 @@ C2Payload RESTProtocol::parseJsonResponse(const C2Payload &payload, gsl::span<co
}
} catch (...) {
}
- return C2Payload(payload.getOperation(), state::UpdateState::READ_COMPLETE);
+ return {payload.getOperation(), state::UpdateState::READ_COMPLETE};
}
RESTProtocol::RESTProtocol() = default;
diff --git a/libminifi/src/controllers/NetworkPrioritizerService.cpp b/libminifi/src/controllers/NetworkPrioritizerService.cpp
index d27af5716..202b51a0f 100644
--- a/libminifi/src/controllers/NetworkPrioritizerService.cpp
+++ b/libminifi/src/controllers/NetworkPrioritizerService.cpp
@@ -29,8 +29,8 @@
#include <netdb.h>
#include <unistd.h>
#endif
-#include <string.h>
-#include <stdlib.h>
+#include <cstring>
+#include <cstdlib>
#include "utils/StringUtils.h"
#include "core/TypedValues.h"
@@ -87,8 +87,8 @@ io::NetworkInterface NetworkPrioritizerService::getInterface(uint32_t size = 0)
return newifc;
}
}
- for (size_t i = 0; i < linked_services_.size(); i++) {
- auto np = std::dynamic_pointer_cast<NetworkPrioritizerService>(linked_services_.at(i));
+ for (const auto& service : linked_services_) {
+ auto np = std::dynamic_pointer_cast<NetworkPrioritizerService>(service);
if (np != nullptr) {
auto ifcs = np->getInterfaces(size);
ifc = get_nearest_interface(ifcs);
diff --git a/libminifi/src/controllers/UpdatePolicyControllerService.cpp b/libminifi/src/controllers/UpdatePolicyControllerService.cpp
index e669e1bbe..b057cf38a 100644
--- a/libminifi/src/controllers/UpdatePolicyControllerService.cpp
+++ b/libminifi/src/controllers/UpdatePolicyControllerService.cpp
@@ -16,8 +16,8 @@
*/
#include "controllers/UpdatePolicyControllerService.h"
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
#include <cstdio>
#include <limits>
diff --git a/libminifi/src/core/ProcessSession.cpp b/libminifi/src/core/ProcessSession.cpp
index 086cc3a18..ff5cbb1c7 100644
--- a/libminifi/src/core/ProcessSession.cpp
+++ b/libminifi/src/core/ProcessSession.cpp
@@ -54,14 +54,10 @@ int getpagesize(void) {
}
#endif
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
std::string detail::to_string(const detail::ReadBufferResult& read_buffer_result) {
- return std::string(reinterpret_cast<const char*>(read_buffer_result.buffer.data()), read_buffer_result.buffer.size());
+ return {reinterpret_cast<const char*>(read_buffer_result.buffer.data()), read_buffer_result.buffer.size()};
}
std::shared_ptr<utils::IdGenerator> ProcessSession::id_generator_ = utils::IdGenerator::getIdGenerator();
@@ -1098,8 +1094,4 @@ bool ProcessSession::existsFlowFileInRelationship(const Relationship &relationsh
});
}
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::core
diff --git a/libminifi/src/core/Processor.cpp b/libminifi/src/core/Processor.cpp
index 897638969..1ca41a715 100644
--- a/libminifi/src/core/Processor.cpp
+++ b/libminifi/src/core/Processor.cpp
@@ -19,7 +19,7 @@
*/
#include "core/Processor.h"
-#include <time.h>
+#include <ctime>
#include <memory>
#include <set>
@@ -37,11 +37,7 @@
using namespace std::literals::chrono_literals;
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
Processor::Processor(const std::string& name)
: Connectable(name),
@@ -397,8 +393,4 @@ std::chrono::milliseconds Processor::getYieldTime() const {
return 0ms;
}
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::core
diff --git a/libminifi/src/core/logging/LoggerConfiguration.cpp b/libminifi/src/core/logging/LoggerConfiguration.cpp
index 8c1455606..2af1c1b7a 100644
--- a/libminifi/src/core/logging/LoggerConfiguration.cpp
+++ b/libminifi/src/core/logging/LoggerConfiguration.cpp
@@ -56,12 +56,7 @@
#include <tchar.h>
#endif
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace logging {
+namespace org::apache::nifi::minifi::core::logging {
const char* LoggerConfiguration::spdlog_default_pattern = "[%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v";
@@ -103,8 +98,7 @@ LoggerConfiguration::LoggerConfiguration()
formatter_(std::make_shared<spdlog::pattern_formatter>(spdlog_default_pattern)),
shorten_names_(false) {
controller_ = std::make_shared<LoggerControl>();
- logger_ = std::shared_ptr<LoggerImpl>(
- new LoggerImpl(core::getClassName<LoggerConfiguration>(), controller_, get_logger(nullptr, root_namespace_, core::getClassName<LoggerConfiguration>(), formatter_)));
+ logger_ = std::make_shared<LoggerImpl>(core::getClassName<LoggerConfiguration>(), controller_, get_logger(nullptr, root_namespace_, core::getClassName<LoggerConfiguration>(), formatter_));
loggers.push_back(logger_);
}
@@ -376,9 +370,4 @@ std::shared_ptr<spdlog::sinks::rotating_file_sink_mt> LoggerConfiguration::getRo
return sink;
}
-} /* namespace logging */
-} /* namespace core */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::core::logging
diff --git a/libminifi/src/core/state/Value.cpp b/libminifi/src/core/state/Value.cpp
index 120b228a8..06e8d0cb7 100644
--- a/libminifi/src/core/state/Value.cpp
+++ b/libminifi/src/core/state/Value.cpp
@@ -73,7 +73,7 @@ rapidjson::Value nodeToJson(const SerializedResponseNode& node, rapidjson::Memor
return result;
}
} else {
- return rapidjson::Value(node.value.to_string().c_str(), alloc);
+ return {node.value.to_string().c_str(), alloc};
}
}
} // namespace
diff --git a/libminifi/src/sitetosite/Peer.cpp b/libminifi/src/sitetosite/Peer.cpp
index 5a5be8a8c..4906294e7 100644
--- a/libminifi/src/sitetosite/Peer.cpp
+++ b/libminifi/src/sitetosite/Peer.cpp
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <stdio.h>
+#include <cstdio>
#include <chrono>
#include <thread>
#include <random>
@@ -29,11 +29,7 @@
#include "io/validation.h"
#include "FlowController.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace sitetosite {
+namespace org::apache::nifi::minifi::sitetosite {
bool SiteToSitePeer::Open() {
if (IsNullOrEmpty(host_))
@@ -67,8 +63,4 @@ void SiteToSitePeer::Close() {
stream_->close();
}
-} /* namespace sitetosite */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::sitetosite
diff --git a/libminifi/src/sitetosite/RawSocketProtocol.cpp b/libminifi/src/sitetosite/RawSocketProtocol.cpp
index ebe7230b3..2d5fb9722 100644
--- a/libminifi/src/sitetosite/RawSocketProtocol.cpp
+++ b/libminifi/src/sitetosite/RawSocketProtocol.cpp
@@ -16,8 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <stdio.h>
-#include <time.h>
+#include <cstdio>
+#include <ctime>
#include <chrono>
#include <utility>
#include <map>
@@ -35,11 +35,7 @@
using namespace std::literals::chrono_literals;
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace sitetosite {
+namespace org::apache::nifi::minifi::sitetosite {
std::shared_ptr<utils::IdGenerator> RawSiteToSiteClient::id_generator_ = utils::IdGenerator::getIdGenerator();
std::shared_ptr<utils::IdGenerator> Transaction::id_generator_ = utils::IdGenerator::getIdGenerator();
@@ -536,13 +532,13 @@ std::shared_ptr<Transaction> RawSiteToSiteClient::createTransaction(TransferDire
return transaction;
default:
logger_->log_warn("Site2Site got unexpected response %d when asking for data", code);
- return NULL;
+ return nullptr;
}
} else {
ret = writeRequestType(SEND_FLOWFILES);
if (ret <= 0) {
- return NULL;
+ return nullptr;
} else {
org::apache::nifi::minifi::io::CRCStream<SiteToSitePeer> crcstream(gsl::make_not_null(peer_.get()));
transaction = std::make_shared<Transaction>(direction, std::move(crcstream));
@@ -555,7 +551,7 @@ std::shared_ptr<Transaction> RawSiteToSiteClient::createTransaction(TransferDire
bool RawSiteToSiteClient::transmitPayload(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session, const std::string &payload,
std::map<std::string, std::string> attributes) {
- std::shared_ptr<Transaction> transaction = NULL;
+ std::shared_ptr<Transaction> transaction;
if (payload.length() <= 0)
return false;
@@ -575,7 +571,7 @@ bool RawSiteToSiteClient::transmitPayload(const std::shared_ptr<core::ProcessCon
// Create the transaction
transaction = createTransaction(SEND);
- if (transaction == NULL) {
+ if (transaction == nullptr) {
context->yield();
tearDown();
throw Exception(SITE2SITE_EXCEPTION, "Can not create transaction");
@@ -621,8 +617,4 @@ bool RawSiteToSiteClient::transmitPayload(const std::shared_ptr<core::ProcessCon
return true;
}
-} /* namespace sitetosite */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::sitetosite
diff --git a/libminifi/src/utils/BackTrace.cpp b/libminifi/src/utils/BackTrace.cpp
index 1719fd067..0cda886a9 100644
--- a/libminifi/src/utils/BackTrace.cpp
+++ b/libminifi/src/utils/BackTrace.cpp
@@ -35,7 +35,6 @@
#ifdef HAS_EXECINFO
namespace {
using std::optional;
- using std::nullopt;
/**
* Demangles a symbol name using the cxx abi.
* @param symbol_name the mangled name of the symbol
diff --git a/libminifi/src/utils/Id.cpp b/libminifi/src/utils/Id.cpp
index abd8dd608..83106f936 100644
--- a/libminifi/src/utils/Id.cpp
+++ b/libminifi/src/utils/Id.cpp
@@ -24,7 +24,7 @@
#include "utils/Id.h"
#define __STDC_FORMAT_MACROS 1 // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
-#include <inttypes.h>
+#include <cinttypes>
#include <algorithm>
#include <chrono>
#include <cmath>
@@ -42,12 +42,9 @@
#endif
#include "utils/StringUtils.h"
+#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
+namespace org::apache::nifi::minifi::utils {
#ifdef WIN32
namespace {
@@ -193,8 +190,8 @@ IdGenerator::~IdGenerator() = default;
uint64_t IdGenerator::getDeviceSegmentFromString(const std::string& str, int numBits) const {
uint64_t deviceSegment = 0;
- for (size_t i = 0; i < str.length(); i++) {
- unsigned char c = toupper(str[i]);
+ for (auto ch : str) {
+ auto c = gsl::narrow_cast<unsigned char>(std::toupper(gsl::narrow_cast<unsigned char>(ch)));
if (c >= '0' && c <= '9') {
deviceSegment = deviceSegment + (c - '0');
} else if (c >= 'A' && c <= 'F') {
@@ -330,8 +327,4 @@ Identifier IdGenerator::generate() {
return Identifier{output};
}
-} /* namespace utils */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::utils
diff --git a/libminifi/src/utils/RegexUtils.cpp b/libminifi/src/utils/RegexUtils.cpp
index 39319a2f0..d87f11c11 100644
--- a/libminifi/src/utils/RegexUtils.cpp
+++ b/libminifi/src/utils/RegexUtils.cpp
@@ -79,12 +79,11 @@ void SMatch::clear() {
Regex::Regex() : Regex::Regex("") {}
-Regex::Regex(const std::string &value) : Regex::Regex(value, {}) {}
+Regex::Regex(std::string value) : Regex::Regex(std::move(value), {}) {}
-Regex::Regex(const std::string &value,
- const std::vector<Regex::Mode> &mode)
- : regex_str_(value),
- valid_(false) {
+Regex::Regex(std::string value, const std::vector<Regex::Mode> &mode)
+ : regex_str_(std::move(value)),
+ valid_(false) {
// Create regex mode
#ifdef NO_MORE_REGFREEE
regex_mode_ = std::regex_constants::ECMAScript;
@@ -177,14 +176,14 @@ Regex& Regex::operator=(Regex&& other) {
return *this;
}
-Regex::~Regex() {
#ifndef NO_MORE_REGFREEE
+Regex::~Regex() {
if (valid_) {
regfree(&compiled_regex_);
regfree(&compiled_full_input_regex_);
}
-#endif
}
+#endif
#ifndef NO_MORE_REGFREEE
void Regex::compileRegex(regex_t& regex, const std::string& regex_string) const {
diff --git a/libminifi/src/utils/ThreadPool.cpp b/libminifi/src/utils/ThreadPool.cpp
index ade82017b..640c2c5f4 100644
--- a/libminifi/src/utils/ThreadPool.cpp
+++ b/libminifi/src/utils/ThreadPool.cpp
@@ -18,11 +18,7 @@
#include "utils/ThreadPool.h"
#include "core/state/UpdateController.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
+namespace org::apache::nifi::minifi::utils {
template<typename T>
void ThreadPool<T>::run_tasks(std::shared_ptr<WorkerThread> thread) {
@@ -128,7 +124,7 @@ void ThreadPool<T>::manageWorkers() {
std::stringstream thread_name;
thread_name << name_ << " #" << i;
auto worker_thread = std::make_shared<WorkerThread>(thread_name.str());
- worker_thread->thread_ = createThread(std::bind(&ThreadPool::run_tasks, this, worker_thread));
+ worker_thread->thread_ = createThread([this, worker_thread] { run_tasks(worker_thread); });
thread_queue_.push_back(worker_thread);
current_workers_++;
}
@@ -159,7 +155,7 @@ void ThreadPool<T>::manageWorkers() {
} else if (thread_manager_->canIncrease() && max_worker_threads_ > current_workers_) { // increase slowly
std::unique_lock<std::mutex> lock(worker_queue_mutex_);
auto worker_thread = std::make_shared<WorkerThread>();
- worker_thread->thread_ = createThread(std::bind(&ThreadPool::run_tasks, this, worker_thread));
+ worker_thread->thread_ = createThread([this, worker_thread] { run_tasks(worker_thread); });
if (daemon_threads_) {
worker_thread->thread_.detach();
}
@@ -282,8 +278,4 @@ template class utils::ThreadPool<int>;
template class utils::ThreadPool<bool>;
template class utils::ThreadPool<state::Update>;
-} /* namespace utils */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::utils
diff --git a/libminifi/src/utils/file/PathUtils.cpp b/libminifi/src/utils/file/PathUtils.cpp
index 4923845d0..2c6ba3272 100644
--- a/libminifi/src/utils/file/PathUtils.cpp
+++ b/libminifi/src/utils/file/PathUtils.cpp
@@ -21,21 +21,16 @@
#ifdef WIN32
#include <Windows.h>
#else
-#include <limits.h>
-#include <stdlib.h>
#include <sys/statvfs.h>
+#include <climits>
+#include <cstdlib>
#endif
#include <iostream>
#include "utils/file/FileUtils.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
-namespace file {
+namespace org::apache::nifi::minifi::utils::file {
bool getFileNameAndPath(const std::string &path, std::string &filePath, std::string &fileName) {
const std::size_t found = path.find_last_of(FileUtils::get_separator());
@@ -138,9 +133,4 @@ space_info space(const path path) {
return result;
}
-} // namespace file
-} // namespace utils
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::utils::file
diff --git a/libminifi/test/archive-tests/CompressContentTests.cpp b/libminifi/test/archive-tests/CompressContentTests.cpp
index 2792b416c..ba10a2cff 100644
--- a/libminifi/test/archive-tests/CompressContentTests.cpp
+++ b/libminifi/test/archive-tests/CompressContentTests.cpp
@@ -192,23 +192,21 @@ class CompressDecompressionTestController : public TestController{
}
};
- std::string rawContentPath() const {
+ [[nodiscard]] std::string rawContentPath() const {
return raw_content_path_;
}
- std::string compressedPath() const {
+ [[nodiscard]] std::string compressedPath() const {
return compressed_content_path_;
}
- RawContent getRawContent() const {
+ [[nodiscard]] RawContent getRawContent() const {
std::ifstream file;
file.open(raw_content_path_, std::ios::binary);
std::string contents{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
return RawContent{std::move(contents)};
}
-
-
virtual ~CompressDecompressionTestController() = 0;
std::shared_ptr<core::Processor> processor;
@@ -262,7 +260,7 @@ class DecompressTestController : public CompressDecompressionTestController{
DecompressTestController() {
setupFlow();
}
- ~DecompressTestController() {
+ ~DecompressTestController() override {
tempDir_ = "";
raw_content_path_ = "";
compressed_content_path_ = "";
diff --git a/libminifi/test/archive-tests/ManipulateArchiveTests.cpp b/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
index f8e1e0994..63ea5f1bf 100644
--- a/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
+++ b/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
@@ -43,7 +43,7 @@ const char* MODIFY_SRC = FILE_NAMES[0];
const char* ORDER_ANCHOR = FILE_NAMES[1];
const char* MODIFY_DEST = "modified";
-typedef std::map<std::string, std::string> PROP_MAP_T;
+using PROP_MAP_T = std::map<std::string, std::string>;
bool run_archive_test(OrderedTestArchive input_archive, OrderedTestArchive output_archive, PROP_MAP_T properties, bool check_attributes = true) {
TestController testController;
diff --git a/libminifi/test/archive-tests/MergeFileTests.cpp b/libminifi/test/archive-tests/MergeFileTests.cpp
index 19b8202be..3318085e5 100644
--- a/libminifi/test/archive-tests/MergeFileTests.cpp
+++ b/libminifi/test/archive-tests/MergeFileTests.cpp
@@ -74,12 +74,12 @@ class FixedBuffer {
other.size_ = 0;
other.capacity_ = 0;
}
- std::size_t size() const { return size_; }
- std::size_t capacity() const { return capacity_; }
- uint8_t* begin() const { return buf_.get(); }
- uint8_t* end() const { return buf_.get() + size_; }
+ [[nodiscard]] std::size_t size() const { return size_; }
+ [[nodiscard]] std::size_t capacity() const { return capacity_; }
+ [[nodiscard]] uint8_t* begin() const { return buf_.get(); }
+ [[nodiscard]] uint8_t* end() const { return buf_.get() + size_; }
- std::string to_string() const {
+ [[nodiscard]] std::string to_string() const {
return {begin(), end()};
}
diff --git a/libminifi/test/aws-tests/AWSCredentialsServiceTest.cpp b/libminifi/test/aws-tests/AWSCredentialsServiceTest.cpp
index b02095aa1..1025e7ab3 100644
--- a/libminifi/test/aws-tests/AWSCredentialsServiceTest.cpp
+++ b/libminifi/test/aws-tests/AWSCredentialsServiceTest.cpp
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-#include <stdlib.h>
+#include <cstdlib>
#include <memory>
#include "../TestBase.h"
diff --git a/libminifi/test/keyvalue-tests/PersistableKeyValueStoreServiceTest.cpp b/libminifi/test/keyvalue-tests/PersistableKeyValueStoreServiceTest.cpp
index e919e7fa7..965ea65b7 100644
--- a/libminifi/test/keyvalue-tests/PersistableKeyValueStoreServiceTest.cpp
+++ b/libminifi/test/keyvalue-tests/PersistableKeyValueStoreServiceTest.cpp
@@ -101,7 +101,7 @@ class PersistableKeyValueStoreServiceTestsFixture {
content_repo->initialize(configuration);
stream_factory = minifi::io::StreamFactory::getInstance(configuration);
- yaml_config = std::unique_ptr<core::YamlConfiguration>(new core::YamlConfiguration(test_repo, test_repo, content_repo, stream_factory, configuration, config_yaml));
+ yaml_config = std::make_unique<core::YamlConfiguration>(test_repo, test_repo, content_repo, stream_factory, configuration, config_yaml);
process_group = yaml_config->getRoot();
persistable_key_value_store_service_node = process_group->findControllerService("testcontroller");
diff --git a/libminifi/test/rocksdb-tests/DBProvenanceRepositoryTests.cpp b/libminifi/test/rocksdb-tests/DBProvenanceRepositoryTests.cpp
index 3c341d8f3..fc1550ea0 100644
--- a/libminifi/test/rocksdb-tests/DBProvenanceRepositoryTests.cpp
+++ b/libminifi/test/rocksdb-tests/DBProvenanceRepositoryTests.cpp
@@ -35,7 +35,7 @@ void generateData(std::vector<char>& data) {
std::mt19937 eng(rd());
std::uniform_int_distribution<> distr(std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
- auto rand = std::bind(distr, eng);
+ auto rand = [&distr, &eng] { return distr(eng); };
std::generate_n(data.begin(), data.size(), rand);
}
diff --git a/libminifi/test/rocksdb-tests/RocksDBTests.cpp b/libminifi/test/rocksdb-tests/RocksDBTests.cpp
index 7053fea72..6420a04de 100644
--- a/libminifi/test/rocksdb-tests/RocksDBTests.cpp
+++ b/libminifi/test/rocksdb-tests/RocksDBTests.cpp
@@ -44,7 +44,7 @@ struct RocksDBTest : TestController {
db_dir = createTempDirectory();
}
- OpenDatabase openDB(const std::vector<std::string>& cf_names) const {
+ [[nodiscard]] OpenDatabase openDB(const std::vector<std::string>& cf_names) const {
rocksdb::DB* db_ptr = nullptr;
std::vector<rocksdb::ColumnFamilyHandle*> cf_handle_ptrs;
std::vector<rocksdb::ColumnFamilyDescriptor> cf_descs;
diff --git a/libminifi/test/sql-tests/mocks/MockConnectors.cpp b/libminifi/test/sql-tests/mocks/MockConnectors.cpp
index 9400d1141..1e4d7570c 100644
--- a/libminifi/test/sql-tests/mocks/MockConnectors.cpp
+++ b/libminifi/test/sql-tests/mocks/MockConnectors.cpp
@@ -24,11 +24,7 @@
#include <string>
#include <memory>
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace sql {
+namespace org::apache::nifi::minifi::sql {
std::size_t MockRow::size() const {
return column_names_->size();
@@ -186,7 +182,7 @@ std::unique_ptr<Rowset> MockDB::execute(const std::string& query, const std::vec
void MockDB::createTable(const std::string& query) {
std::smatch match;
- std::regex expr("create table (\\w+)\\s*\\((.*)\\);", std::regex_constants::icase);
+ std::regex expr(R"(create table (\w+)\s*\((.*)\);)", std::regex_constants::icase);
std::regex_search(query, match, expr);
std::string table_name = match[1];
auto columns_with_type = minifi::utils::StringUtils::splitAndTrimRemovingEmpty(match[2], ",");
@@ -208,7 +204,7 @@ void MockDB::insertInto(const std::string& query, const std::vector<std::string>
}
std::smatch match;
- std::regex expr("insert into (\\w+)\\s*(\\((.*)\\))*\\s*values\\s*\\((.+)\\)", std::regex_constants::icase);
+ std::regex expr(R"(insert into (\w+)\s*(\((.*)\))*\s*values\s*\((.+)\))", std::regex_constants::icase);
std::regex_search(replaced_query, match, expr);
std::string table_name = match[1];
std::vector<std::string> values = minifi::utils::StringUtils::splitAndTrimRemovingEmpty(match[4], ",");
@@ -242,7 +238,7 @@ std::unique_ptr<Rowset> MockDB::select(const std::string& query, const std::vect
}
std::smatch match;
- std::regex expr("select\\s+(.+)\\s+from\\s+(\\w+)\\s*(where ((.+(?= order by))|.+$))*\\s*(order by (.+))*", std::regex_constants::icase);
+ std::regex expr(R"(select\s+(.+)\s+from\s+(\w+)\s*(where ((.+(?= order by))|.+$))*\s*(order by (.+))*)", std::regex_constants::icase);
std::regex_search(replaced_query, match, expr);
auto cols = minifi::utils::StringUtils::splitAndTrimRemovingEmpty(match[1], ",");
if (cols[0] == "*") {
@@ -413,8 +409,4 @@ std::unique_ptr<Session> MockODBCConnection::getSession() const {
return std::make_unique<sql::MockSession>();
}
-} /* namespace sql */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::sql
diff --git a/libminifi/test/sql-tests/mocks/MockConnectors.h b/libminifi/test/sql-tests/mocks/MockConnectors.h
index b0f2aa6c9..5d1e8d590 100644
--- a/libminifi/test/sql-tests/mocks/MockConnectors.h
+++ b/libminifi/test/sql-tests/mocks/MockConnectors.h
@@ -28,11 +28,7 @@
#include "data/DatabaseConnectors.h"
#include "utils/StringUtils.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace sql {
+namespace org::apache::nifi::minifi::sql {
class MockRow : public Row {
public:
@@ -166,8 +162,4 @@ class MockODBCConnection : public Connection {
std::string file_path_;
};
-} /* namespace sql */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::sql
diff --git a/libminifi/test/unit/BackTraceTests.cpp b/libminifi/test/unit/BackTraceTests.cpp
index 48aecf977..9a14ffe69 100644
--- a/libminifi/test/unit/BackTraceTests.cpp
+++ b/libminifi/test/unit/BackTraceTests.cpp
@@ -32,8 +32,7 @@ bool function() {
class WorkerNumberExecutions : public utils::AfterExecute<int> {
public:
explicit WorkerNumberExecutions(int tasks)
- : runs(0),
- tasks(tasks) {
+ : tasks(tasks) {
}
explicit WorkerNumberExecutions(WorkerNumberExecutions && other)
@@ -41,8 +40,6 @@ class WorkerNumberExecutions : public utils::AfterExecute<int> {
tasks(std::move(other.tasks)) {
}
- ~WorkerNumberExecutions() = default;
-
bool isFinished(const int &result) override {
if (result > 0 && ++runs < tasks) {
return false;
@@ -64,7 +61,7 @@ class WorkerNumberExecutions : public utils::AfterExecute<int> {
}
protected:
- int runs;
+ int runs{0};
int tasks;
};
diff --git a/libminifi/test/unit/CollectionUtilsTests.cpp b/libminifi/test/unit/CollectionUtilsTests.cpp
index 9ad7a1bb7..870f06209 100644
--- a/libminifi/test/unit/CollectionUtilsTests.cpp
+++ b/libminifi/test/unit/CollectionUtilsTests.cpp
@@ -46,7 +46,7 @@ TEST_CASE("TestHaveCommonItem", "[haveCommonItem]") {
template<typename T>
struct MockSet : std::set<T> {
using std::set<T>::set;
- auto find(const T& item) const -> decltype(this->std::set<T>::find(item)) {
+ [[nodiscard]] auto find(const T& item) const -> decltype(this->std::set<T>::find(item)) {
on_find_();
return std::set<T>::find(item);
}
diff --git a/libminifi/test/unit/ControllerTests.cpp b/libminifi/test/unit/ControllerTests.cpp
index 0ab8877a7..eca69e38b 100644
--- a/libminifi/test/unit/ControllerTests.cpp
+++ b/libminifi/test/unit/ControllerTests.cpp
@@ -33,13 +33,12 @@ class TestStateController : public minifi::state::StateController {
TestStateController()
: is_running(false) {
}
- virtual ~TestStateController() = default;
- virtual std::string getComponentName() const {
+ std::string getComponentName() const override {
return "TestStateController";
}
- virtual utils::Identifier getComponentUUID() const {
+ utils::Identifier getComponentUUID() const override {
static auto dummyUUID = utils::Identifier::parse("12345678-1234-1234-1234-123456789abc").value();
return dummyUUID;
}
@@ -47,27 +46,27 @@ class TestStateController : public minifi::state::StateController {
/**
* Start the client
*/
- virtual int16_t start() {
+ int16_t start() override {
is_running = true;
return 0;
}
/**
* Stop the client
*/
- virtual int16_t stop() {
+ int16_t stop() override {
is_running = false;
return 0;
}
- virtual bool isRunning() {
+ bool isRunning() override {
return is_running;
}
- virtual int16_t pause() {
+ int16_t pause() override {
return 0;
}
- virtual int16_t resume() {
+ int16_t resume() override {
return 0;
}
diff --git a/libminifi/test/unit/DynamicPropertyTests.cpp b/libminifi/test/unit/DynamicPropertyTests.cpp
index 83004e225..2552c397d 100644
--- a/libminifi/test/unit/DynamicPropertyTests.cpp
+++ b/libminifi/test/unit/DynamicPropertyTests.cpp
@@ -21,11 +21,7 @@
#include "../TestBase.h"
#include "../Catch.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
class TestConfigurableComponentSupportsDynamic : public ConfigurableComponent {
public:
@@ -93,8 +89,4 @@ TEST_CASE("Test Set Dynamic Property 3", "[testSetDynamicProperty2]") {
REQUIRE("test2" == propertyKeys[1]);
}
-} /* namespace core */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::core
diff --git a/libminifi/test/unit/EnvironmentUtilsTests.cpp b/libminifi/test/unit/EnvironmentUtilsTests.cpp
index 0be19b633..5b9751e2e 100644
--- a/libminifi/test/unit/EnvironmentUtilsTests.cpp
+++ b/libminifi/test/unit/EnvironmentUtilsTests.cpp
@@ -24,6 +24,7 @@
#include "utils/Environment.h"
#include "utils/file/PathUtils.h"
+#include "utils/gsl.h"
#include "../TestBase.h"
#include "../Catch.h"
@@ -117,6 +118,9 @@ TEST_CASE("multithreaded environment manipulation", "[getenv][setenv][unsetenv]"
utils::Environment::unsetEnvironmentVariable(env_name.c_str());
break;
}
+ default: {
+ gsl_FailFast();
+ }
}
}
});
diff --git a/libminifi/test/unit/ExpectedTest.cpp b/libminifi/test/unit/ExpectedTest.cpp
index b153f1c5b..0bff815e4 100644
--- a/libminifi/test/unit/ExpectedTest.cpp
+++ b/libminifi/test/unit/ExpectedTest.cpp
@@ -478,9 +478,9 @@ TEST_CASE("expected valueOrElse", "[expected][valueOrElse]") {
using namespace std::literals; // NOLINT
nonstd::expected<int, std::string> ex{nonstd::unexpect, "hello"};
REQUIRE(42 == (ex | utils::valueOrElse([] { return 42; })));
- REQUIRE_THROWS_AS(ex | utils::valueOrElse([]{ throw 42; }), int);
+ REQUIRE_THROWS_AS(ex | utils::valueOrElse([]{ throw std::exception(); }), std::exception);
REQUIRE(gsl::narrow<int>("hello"sv.size()) == (ex | utils::valueOrElse([](const std::string& err) { return gsl::narrow<int>(err.size()); })));
- REQUIRE_THROWS_AS(ex | utils::valueOrElse([](std::string){ throw 42; }), int);
- REQUIRE_THROWS_AS(ex | utils::valueOrElse([](const std::string&) -> int { throw 42; }), int);
- REQUIRE_THROWS_AS(std::move(ex) | utils::valueOrElse([](std::string&&) -> int { throw 42; }), int);
+ REQUIRE_THROWS_AS(ex | utils::valueOrElse([](std::string){ throw std::exception(); }), std::exception);
+ REQUIRE_THROWS_AS(ex | utils::valueOrElse([](const std::string&) -> int { throw std::exception(); }), std::exception);
+ REQUIRE_THROWS_AS(std::move(ex) | utils::valueOrElse([](std::string&&) -> int { throw std::exception(); }), std::exception);
}
diff --git a/libminifi/test/unit/GeneralUtilsTest.cpp b/libminifi/test/unit/GeneralUtilsTest.cpp
index 110052668..64547b6db 100644
--- a/libminifi/test/unit/GeneralUtilsTest.cpp
+++ b/libminifi/test/unit/GeneralUtilsTest.cpp
@@ -27,25 +27,25 @@
namespace utils = org::apache::nifi::minifi::utils;
// intdiv_ceil
-static_assert(0 == utils::intdiv_ceil(0, 1), "");
-static_assert(0 == utils::intdiv_ceil(0, 2), "");
-static_assert(1 == utils::intdiv_ceil(1, 2), "");
-static_assert(1 == utils::intdiv_ceil(1, 3), "");
-static_assert(1 == utils::intdiv_ceil(3, 3), "");
-static_assert(2 == utils::intdiv_ceil(4, 3), "");
-static_assert(2 == utils::intdiv_ceil(5, 3), "");
-static_assert(0 == utils::intdiv_ceil(-1, 3), "");
-static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
-static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
-static_assert(2 == utils::intdiv_ceil(-4, -3), "");
-static_assert(2 == utils::intdiv_ceil(-5, -3), "");
-static_assert(0 == utils::intdiv_ceil(1, -3), "");
-static_assert(-1 == utils::intdiv_ceil(5, -3), "");
-static_assert(3 == utils::intdiv_ceil(6, 2), "");
-static_assert(-3 == utils::intdiv_ceil(-6, 2), "");
-static_assert(-3 == utils::intdiv_ceil(6, -2), "");
-static_assert(3 == utils::intdiv_ceil(-6, -2), "");
-static_assert(0 == utils::intdiv_ceil(0, -10), "");
+static_assert(0 == utils::intdiv_ceil(0, 1));
+static_assert(0 == utils::intdiv_ceil(0, 2));
+static_assert(1 == utils::intdiv_ceil(1, 2));
+static_assert(1 == utils::intdiv_ceil(1, 3));
+static_assert(1 == utils::intdiv_ceil(3, 3));
+static_assert(2 == utils::intdiv_ceil(4, 3));
+static_assert(2 == utils::intdiv_ceil(5, 3));
+static_assert(0 == utils::intdiv_ceil(-1, 3));
+static_assert(-1 == utils::intdiv_ceil(-3, 3));
+static_assert(-1 == utils::intdiv_ceil(-4, 3));
+static_assert(2 == utils::intdiv_ceil(-4, -3));
+static_assert(2 == utils::intdiv_ceil(-5, -3));
+static_assert(0 == utils::intdiv_ceil(1, -3));
+static_assert(-1 == utils::intdiv_ceil(5, -3));
+static_assert(3 == utils::intdiv_ceil(6, 2));
+static_assert(-3 == utils::intdiv_ceil(-6, 2));
+static_assert(-3 == utils::intdiv_ceil(6, -2));
+static_assert(3 == utils::intdiv_ceil(-6, -2));
+static_assert(0 == utils::intdiv_ceil(0, -10));
template<int N, int D, typename = void>
struct does_compile : std::false_type {};
diff --git a/libminifi/test/unit/IdTests.cpp b/libminifi/test/unit/IdTests.cpp
index a6bbbea27..a24b8661d 100644
--- a/libminifi/test/unit/IdTests.cpp
+++ b/libminifi/test/unit/IdTests.cpp
@@ -26,19 +26,11 @@
#include "utils/Id.h"
#include "../Utils.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
+namespace org::apache::nifi::minifi::utils {
struct IdentifierTestAccessor {
FIELD_ACCESSOR(data_)
};
-} // namespace utils
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::utils
using org::apache::nifi::minifi::utils::IdentifierTestAccessor;
@@ -385,8 +377,8 @@ TEST_CASE("Speed", "[speed]") {
generator->generate();
auto before = std::chrono::high_resolution_clock::now();
- for (size_t i = 0U; i < uuids.size(); i++) {
- uuids[i] = generator->generate();
+ for (auto& uuid : uuids) {
+ uuid = generator->generate();
}
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - before).count();
std::cerr << "Generating one " << implementation << " UUID took " << (duration / uuids.size()) << "ns" << std::endl;
diff --git a/libminifi/test/unit/IntervalSwitchTest.cpp b/libminifi/test/unit/IntervalSwitchTest.cpp
index efc9a3e56..16ffa91ee 100644
--- a/libminifi/test/unit/IntervalSwitchTest.cpp
+++ b/libminifi/test/unit/IntervalSwitchTest.cpp
@@ -54,7 +54,7 @@ TEST_CASE("basic IntervalSwitch", "[intervalswitch.basic]") {
}
TEST_CASE("IntervalSwitch comparator", "[intervalswitch.comp]") {
- utils::IntervalSwitch<uint32_t, std::greater<uint32_t>> interval_switch{250, 100};
+ utils::IntervalSwitch<uint32_t, std::greater<>> interval_switch{250, 100};
REQUIRE(interval_switch(99) == expected(State::UPPER, false));
REQUIRE(interval_switch(120) == expected(State::UPPER, false));
REQUIRE(interval_switch(250) == expected(State::UPPER, false));
diff --git a/libminifi/test/unit/LoggerTests.cpp b/libminifi/test/unit/LoggerTests.cpp
index deec59861..f1d233adb 100644
--- a/libminifi/test/unit/LoggerTests.cpp
+++ b/libminifi/test/unit/LoggerTests.cpp
@@ -27,7 +27,7 @@
#include "StreamPipe.h"
#include "utils/IntegrationTestUtils.h"
-using std::chrono_literals::operator""s;
+using namespace std::literals::chrono_literals;
TEST_CASE("Test log Levels", "[ttl1]") {
LogTestController::getInstance().setTrace<logging::Logger>();
@@ -80,7 +80,7 @@ TEST_CASE("Test log Levels change", "[ttl5]") {
}
struct CStringConvertible {
- const char* c_str() const {
+ [[nodiscard]] const char* c_str() const {
return data.c_str();
}
diff --git a/libminifi/test/unit/PropertyTests.cpp b/libminifi/test/unit/PropertyTests.cpp
index 5f9facdff..b35b0aa18 100644
--- a/libminifi/test/unit/PropertyTests.cpp
+++ b/libminifi/test/unit/PropertyTests.cpp
@@ -26,9 +26,6 @@
namespace {
enum class ConversionTestTarget { MS, NS };
-namespace core = minifi::core;
-
-
TEST_CASE("Test Trimmer Right", "[testTrims]") {
std::string test = "a quick brown fox jumped over the road\t\n";
diff --git a/libminifi/test/unit/RegexUtilsTests.cpp b/libminifi/test/unit/RegexUtilsTests.cpp
index efec1124d..2a01ce565 100644
--- a/libminifi/test/unit/RegexUtilsTests.cpp
+++ b/libminifi/test/unit/RegexUtilsTests.cpp
@@ -19,13 +19,11 @@
#include <string>
#include <vector>
-#include "Exception.h"
#include "utils/RegexUtils.h"
#include "../TestBase.h"
#include "../Catch.h"
using org::apache::nifi::minifi::utils::Regex;
-using org::apache::nifi::minifi::Exception;
namespace minifi = org::apache::nifi::minifi;
TEST_CASE("TestRegexUtils::single_match", "[regex1]") {
diff --git a/libminifi/test/unit/Site2SiteTests.cpp b/libminifi/test/unit/Site2SiteTests.cpp
index a6df18311..8d85f17e6 100644
--- a/libminifi/test/unit/Site2SiteTests.cpp
+++ b/libminifi/test/unit/Site2SiteTests.cpp
@@ -32,8 +32,7 @@
#define FMT_DEFAULT fmt_lower
TEST_CASE("TestSetPortId", "[S2S1]") {
- std::unique_ptr<minifi::sitetosite::SiteToSitePeer> peer = std::unique_ptr<minifi::sitetosite::SiteToSitePeer>(
- new minifi::sitetosite::SiteToSitePeer(std::unique_ptr<org::apache::nifi::minifi::io::BufferStream>(new org::apache::nifi::minifi::io::BufferStream()), "fake_host", 65433, ""));
+ auto peer = std::make_unique<minifi::sitetosite::SiteToSitePeer>(std::make_unique<org::apache::nifi::minifi::io::BufferStream>(), "fake_host", 65433, "");
minifi::sitetosite::RawSiteToSiteClient protocol(std::move(peer));
@@ -65,12 +64,11 @@ void sunny_path_bootstrap(SiteToSiteResponder *collector) {
}
TEST_CASE("TestSiteToSiteVerifySend", "[S2S3]") {
- SiteToSiteResponder *collector = new SiteToSiteResponder();
+ auto *collector = new SiteToSiteResponder();
sunny_path_bootstrap(collector);
- std::unique_ptr<minifi::sitetosite::SiteToSitePeer> peer = std::unique_ptr<minifi::sitetosite::SiteToSitePeer>(
- new minifi::sitetosite::SiteToSitePeer(std::unique_ptr<minifi::io::BaseStream>(collector), "fake_host", 65433, ""));
+ auto peer = std::make_unique<minifi::sitetosite::SiteToSitePeer>(std::unique_ptr<minifi::io::BaseStream>(collector), "fake_host", 65433, "");
minifi::sitetosite::RawSiteToSiteClient protocol(std::move(peer));
@@ -127,7 +125,7 @@ TEST_CASE("TestSiteToSiteVerifySend", "[S2S3]") {
}
TEST_CASE("TestSiteToSiteVerifyNegotiationFail", "[S2S4]") {
- SiteToSiteResponder *collector = new SiteToSiteResponder();
+ auto *collector = new SiteToSiteResponder();
char a = '\xFF';
std::string resp_code;
@@ -135,8 +133,7 @@ TEST_CASE("TestSiteToSiteVerifyNegotiationFail", "[S2S4]") {
collector->push_response(resp_code);
collector->push_response(resp_code);
- std::unique_ptr<minifi::sitetosite::SiteToSitePeer> peer = std::unique_ptr<minifi::sitetosite::SiteToSitePeer>(
- new minifi::sitetosite::SiteToSitePeer(std::unique_ptr<minifi::io::BaseStream>(collector), "fake_host", 65433, ""));
+ auto peer = std::make_unique<minifi::sitetosite::SiteToSitePeer>(std::unique_ptr<minifi::io::BaseStream>(collector), "fake_host", 65433, "");
minifi::sitetosite::RawSiteToSiteClient protocol(std::move(peer));
diff --git a/libminifi/test/unit/StagingQueueTests.cpp b/libminifi/test/unit/StagingQueueTests.cpp
index f5c356edc..852efea26 100644
--- a/libminifi/test/unit/StagingQueueTests.cpp
+++ b/libminifi/test/unit/StagingQueueTests.cpp
@@ -37,7 +37,7 @@ class MockItem {
return std::move(*this);
}
- size_t size() const {
+ [[nodiscard]] size_t size() const {
return data_.size();
}
diff --git a/libminifi/test/unit/StringUtilsTests.cpp b/libminifi/test/unit/StringUtilsTests.cpp
index fe4ea427b..d82e9bbba 100644
--- a/libminifi/test/unit/StringUtilsTests.cpp
+++ b/libminifi/test/unit/StringUtilsTests.cpp
@@ -134,7 +134,7 @@ TEST_CASE("StringUtils::splitAndTrimRemovingEmpty", "[test split with trim remov
}
TEST_CASE("StringUtils::replaceEnvironmentVariables works correctly", "[replaceEnvironmentVariables]") {
- utils::Environment::setEnvironmentVariable("blahblahnamenamenotexist", "computer", 0);
+ utils::Environment::setEnvironmentVariable("blahblahnamenamenotexist", "computer", false);
REQUIRE("hello world computer" == StringUtils::replaceEnvironmentVariables("hello world ${blahblahnamenamenotexist}"));
REQUIRE("hello world ${blahblahnamenamenotexist" == StringUtils::replaceEnvironmentVariables("hello world ${blahblahnamenamenotexist"));
@@ -144,7 +144,7 @@ TEST_CASE("StringUtils::replaceEnvironmentVariables works correctly", "[replaceE
REQUIRE("computer bug" == StringUtils::replaceEnvironmentVariables("${blahblahnamenamenotexist} bug"));
REQUIRE("O computer! My computer!" == StringUtils::replaceEnvironmentVariables("O ${blahblahnamenamenotexist}! My ${blahblahnamenamenotexist}!"));
- utils::Environment::setEnvironmentVariable("blahblahnamenamenotexist_2", "no", 0);
+ utils::Environment::setEnvironmentVariable("blahblahnamenamenotexist_2", "no", false);
REQUIRE("computer says 'no'" == StringUtils::replaceEnvironmentVariables("${blahblahnamenamenotexist} says '${blahblahnamenamenotexist_2}'"));
REQUIRE("no computer can say no to computer nougats" == StringUtils::replaceEnvironmentVariables(
"${blahblahnamenamenotexist_2} ${blahblahnamenamenotexist} can say ${blahblahnamenamenotexist_2} to ${blahblahnamenamenotexist} ${blahblahnamenamenotexist_2}ugats"));
diff --git a/libminifi/test/unit/ThreadPoolTests.cpp b/libminifi/test/unit/ThreadPoolTests.cpp
index e3502b5b5..88069326a 100644
--- a/libminifi/test/unit/ThreadPoolTests.cpp
+++ b/libminifi/test/unit/ThreadPoolTests.cpp
@@ -30,8 +30,7 @@ bool function() {
class WorkerNumberExecutions : public utils::AfterExecute<int> {
public:
explicit WorkerNumberExecutions(int tasks)
- : runs(0),
- tasks(tasks) {
+ : tasks(tasks) {
}
explicit WorkerNumberExecutions(WorkerNumberExecutions && other)
@@ -39,8 +38,6 @@ class WorkerNumberExecutions : public utils::AfterExecute<int> {
tasks(std::move(other.tasks)) {
}
- ~WorkerNumberExecutions() = default;
-
bool isFinished(const int &result) override {
if (result > 0 && ++runs < tasks) {
return false;
@@ -62,7 +59,7 @@ class WorkerNumberExecutions : public utils::AfterExecute<int> {
}
protected:
- int runs;
+ int runs{0};
int tasks;
};
diff --git a/main/MiNiFiMain.cpp b/main/MiNiFiMain.cpp
index 70afd8085..b901f623e 100644
--- a/main/MiNiFiMain.cpp
+++ b/main/MiNiFiMain.cpp
@@ -38,9 +38,9 @@
#endif
#include <fcntl.h>
-#include <stdio.h>
+#include <cstdio>
#include <semaphore.h>
-#include <signal.h>
+#include <csignal>
#include <sodium.h>
#include <atomic>