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/08/19 10:20:17 UTC
[nifi-minifi-cpp] 03/03: MINIFICPP-1865 Integrate performance 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
commit 746ade8170f445c3eb7c369e736ff439b87db1c6
Author: Gabor Gyimesi <ga...@gmail.com>
AuthorDate: Thu Aug 18 18:30:31 2022 +0200
MINIFICPP-1865 Integrate performance clang-tidy checks in CI
Closes #1377
Signed-off-by: Marton Szasz <sz...@apache.org>
---
.clang-tidy | 17 ++++++++++++-
extensions/aws/processors/PutS3Object.cpp | 4 ++--
extensions/civetweb/processors/ListenHTTP.cpp | 4 ++--
extensions/expression-language/Expression.cpp | 20 ++++++++--------
.../impl/expression/Expression.h | 4 ++--
extensions/http-curl/protocols/RESTSender.cpp | 2 +-
extensions/http-curl/protocols/RESTSender.h | 2 +-
extensions/http-curl/tests/HTTPSiteToSiteTests.cpp | 2 +-
.../http-curl/tests/unit/InvokeHTTPTests.cpp | 12 +++++-----
extensions/jni/jvm/JniFlowFile.cpp | 24 +++++++++----------
extensions/libarchive/ArchiveTests.h | 8 +++----
extensions/libarchive/BinFiles.cpp | 10 ++++----
extensions/libarchive/BinFiles.h | 4 ++--
extensions/libarchive/MergeContent.cpp | 6 ++---
extensions/libarchive/MergeContent.h | 2 +-
extensions/script/lua/LuaScriptEngine.cpp | 5 ++--
extensions/script/lua/LuaScriptEngine.h | 12 ++--------
extensions/script/python/PyProcessSession.cpp | 22 ++++++-----------
extensions/script/python/PyProcessSession.h | 20 +++++-----------
extensions/script/python/PythonBindings.h | 2 +-
extensions/sftp/client/SFTPClient.cpp | 2 +-
.../processors/DefragmentText.cpp | 2 +-
.../tests/integration/TestExecuteProcess.cpp | 20 +++++++---------
.../tests/unit/ProcessorTests.cpp | 6 ++---
.../tests/unit/TailFileTests.cpp | 3 ++-
libminifi/include/RemoteProcessorGroupPort.h | 14 +++--------
.../controller/StandardControllerServiceNode.h | 19 +++------------
.../reporting/SiteToSiteProvenanceReportingTask.h | 19 +++------------
libminifi/include/core/yaml/YamlConnectionParser.h | 14 ++---------
libminifi/include/io/tls/TLSServerSocket.h | 16 +++----------
libminifi/include/io/tls/TLSSocket.h | 21 ++++------------
libminifi/include/utils/ClassUtils.h | 19 +++------------
libminifi/include/utils/RegexUtils.h | 4 ++--
libminifi/include/utils/StringUtils.h | 2 +-
libminifi/src/RemoteProcessorGroupPort.cpp | 2 +-
libminifi/src/c2/C2Agent.cpp | 16 ++++++-------
libminifi/src/c2/C2Client.cpp | 9 +++----
.../controller/StandardControllerServiceNode.cpp | 18 ++++----------
.../SiteToSiteProvenanceReportingTask.cpp | 18 ++++----------
libminifi/src/core/yaml/YamlConnectionParser.cpp | 2 +-
libminifi/src/io/tls/TLSServerSocket.cpp | 14 +++--------
libminifi/src/io/tls/TLSSocket.cpp | 24 +++++++------------
libminifi/src/utils/ClassUtils.cpp | 15 +++---------
libminifi/src/utils/RegexUtils.cpp | 4 ++--
libminifi/src/utils/StringUtils.cpp | 6 ++---
.../test/archive-tests/ManipulateArchiveTests.cpp | 12 +++++-----
libminifi/test/archive-tests/MergeFileTests.cpp | 2 +-
libminifi/test/archive-tests/util/ArchiveTests.cpp | 16 ++++++-------
libminifi/test/rocksdb-tests/RocksDBTests.cpp | 1 +
libminifi/test/sql-tests/mocks/MockConnectors.cpp | 2 ++
libminifi/test/unit/BackTraceTests.cpp | 6 ++---
libminifi/test/unit/ExpectedTest.cpp | 28 +++++++++++-----------
libminifi/test/unit/IdTests.cpp | 2 +-
libminifi/test/unit/ThreadPoolTests.cpp | 6 ++---
54 files changed, 209 insertions(+), 337 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index 224d7c595..6dac184f4 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -90,5 +90,20 @@ Checks: >
readability-string-compare,
readability-uniqueptr-delete-release,
readability-uppercase-literal-suffix,
- readability-use-anyofallof
+ readability-use-anyofallof,
+ performance-faster-string-find,
+ performance-for-range-copy,
+ performance-implicit-conversion-in-loop,
+ performance-inefficient-algorithm,
+ performance-inefficient-string-concatenation,
+ performance-inefficient-vector-operation,
+ performance-move-const-arg,
+ performance-move-constructor-init,
+ performance-no-automatic-move,
+ performance-no-int-to-ptr,
+ performance-noexcept-move-constructor,
+ performance-trivially-destructible,
+ performance-type-promotion-in-math-fn,
+ performance-unnecessary-copy-initialization,
+ performance-unnecessary-value-param
FormatStyle: 'file'
diff --git a/extensions/aws/processors/PutS3Object.cpp b/extensions/aws/processors/PutS3Object.cpp
index b312e9b53..22407b896 100644
--- a/extensions/aws/processors/PutS3Object.cpp
+++ b/extensions/aws/processors/PutS3Object.cpp
@@ -46,10 +46,10 @@ void PutS3Object::fillUserMetadata(const std::shared_ptr<core::ProcessContext> &
logger_->log_debug("PutS3Object: DynamicProperty: [%s] -> [%s]", prop_key, prop_value);
user_metadata_map_.emplace(prop_key, prop_value);
if (first_property) {
- user_metadata_ = prop_key + "=" + prop_value;
+ user_metadata_ = minifi::utils::StringUtils::join_pack(prop_key, "=", prop_value);
first_property = false;
} else {
- user_metadata_ += "," + prop_key + "=" + prop_value;
+ user_metadata_ += minifi::utils::StringUtils::join_pack(",", prop_key, "=", prop_value);
}
}
}
diff --git a/extensions/civetweb/processors/ListenHTTP.cpp b/extensions/civetweb/processors/ListenHTTP.cpp
index a790d0436..127ac332a 100644
--- a/extensions/civetweb/processors/ListenHTTP.cpp
+++ b/extensions/civetweb/processors/ListenHTTP.cpp
@@ -253,7 +253,7 @@ bool ListenHTTP::processIncomingFlowFile(core::ProcessSession &session) {
response.mime_type = "application/octet-stream";
}
response.body = to_string(session.readBuffer(flow_file));
- handler_->setResponseBody(std::move(response));
+ handler_->setResponseBody(response);
}
session.remove(flow_file);
@@ -435,7 +435,7 @@ void ListenHTTP::Handler::setResponseBody(const ResponseBody& response) {
logger_->log_info("Registering response body for URI '%s' of length %lu",
response.uri,
response.body.size());
- response_uri_map_[response.uri] = std::move(response);
+ response_uri_map_[response.uri] = response;
}
}
diff --git a/extensions/expression-language/Expression.cpp b/extensions/expression-language/Expression.cpp
index f25da3f9b..c52411c74 100644
--- a/extensions/expression-language/Expression.cpp
+++ b/extensions/expression-language/Expression.cpp
@@ -76,7 +76,7 @@ Expression compile(const std::string &expr_str) {
}
Expression make_static(std::string val) {
- return Expression(Value(val));
+ return Expression(Value(std::move(val)));
}
Expression make_dynamic(const std::function<Value(const Parameters ¶ms, const std::vector<Expression> &sub_exprs)> &val_fn) {
@@ -910,7 +910,7 @@ Expression make_dynamic_function_incomplete(const std::string &function_name, co
} else {
return make_dynamic([=](const Parameters ¶ms, const std::vector<Expression>& /*sub_exprs*/) -> Value {
std::vector<Value> evaluated_args;
-
+ evaluated_args.reserve(args.size());
for (const auto &arg : args) {
evaluated_args.emplace_back(arg(params));
}
@@ -1035,7 +1035,7 @@ Expression make_allAttributes(const std::string &function_name, const std::vecto
result.make_multi([=](const Parameters& /*params*/) -> std::vector<Expression> {
std::vector<Expression> out_exprs;
-
+ out_exprs.reserve(args.size());
for (const auto &arg : args) {
out_exprs.emplace_back(make_dynamic([=](const Parameters ¶ms,
const std::vector<Expression>& /*sub_exprs*/) -> Value {
@@ -1080,7 +1080,7 @@ Expression make_anyAttribute(const std::string &function_name, const std::vector
result.make_multi([=](const Parameters& /*params*/) -> std::vector<Expression> {
std::vector<Expression> out_exprs;
-
+ out_exprs.reserve(args.size());
for (const auto &arg : args) {
out_exprs.emplace_back(make_dynamic([=](const Parameters ¶ms,
const std::vector<Expression>& /*sub_exprs*/) -> Value {
@@ -1312,7 +1312,7 @@ Expression make_join(const std::string &function_name, const std::vector<Express
throw std::runtime_error(message_ss.str());
}
- auto delim_expr = args[1];
+ const auto& delim_expr = args[1];
return args[0].make_aggregate([delim_expr](const Parameters ¶ms,
const std::vector<Expression> &sub_exprs) -> Value {
@@ -1541,8 +1541,7 @@ Expression Expression::operator+(const Expression &other_expr) const {
other_val_fn,
other_sub_expr_generator](const Parameters ¶ms,
const std::vector<Expression>& /*sub_exprs*/) -> Value {
- Value result(val);
- return Value(result.asString().append(other_val_fn(params, other_sub_expr_generator(params)).asString()));
+ return Value(val.asString().append(other_val_fn(params, other_sub_expr_generator(params)).asString()));
});
} else if (!is_dynamic() && !other_expr.is_dynamic()) {
std::string result(val_.asString());
@@ -1561,13 +1560,14 @@ Value Expression::operator()(const Parameters ¶ms) const {
}
}
-Expression Expression::compose_multi(const std::function<Value(const std::vector<Value> &)> fn, const std::vector<Expression> &args) const {
+Expression Expression::compose_multi(const std::function<Value(const std::vector<Value> &)>& fn, const std::vector<Expression> &args) const {
auto result = make_dynamic(val_fn_);
auto compose_expr_generator = sub_expr_generator_;
result.sub_expr_generator_ = [=](const Parameters ¶ms) -> std::vector<Expression> {
auto sub_exprs = compose_expr_generator(params);
- std::vector<Expression> out_exprs {};
+ std::vector<Expression> out_exprs;
+ out_exprs.reserve(sub_exprs.size());
for (const auto &sub_expr : sub_exprs) {
out_exprs.emplace_back(make_dynamic([=](const Parameters ¶ms,
const std::vector<Expression>& /*sub_exprs*/) {
@@ -1590,7 +1590,7 @@ Expression Expression::compose_multi(const std::function<Value(const std::vector
return result;
}
-Expression Expression::make_aggregate(std::function<Value(const Parameters ¶ms, const std::vector<Expression> &sub_exprs)> val_fn) const {
+Expression Expression::make_aggregate(const std::function<Value(const Parameters ¶ms, const std::vector<Expression> &sub_exprs)>& val_fn) const {
auto sub_expr_generator = sub_expr_generator_;
return make_dynamic([sub_expr_generator,
val_fn](const Parameters ¶ms,
diff --git a/extensions/expression-language/impl/expression/Expression.h b/extensions/expression-language/impl/expression/Expression.h
index b9187f2ec..1fcdd173b 100644
--- a/extensions/expression-language/impl/expression/Expression.h
+++ b/extensions/expression-language/impl/expression/Expression.h
@@ -113,9 +113,9 @@ class Expression {
* @param args function arguments
* @return composed multi-expression
*/
- Expression compose_multi(std::function<Value(const std::vector<Value> &)> fn, const std::vector<Expression> &args) const;
+ Expression compose_multi(const std::function<Value(const std::vector<Value> &)>& fn, const std::vector<Expression> &args) const;
- Expression make_aggregate(std::function<Value(const Parameters ¶ms, const std::vector<Expression> &sub_exprs)> val_fn) const;
+ Expression make_aggregate(const std::function<Value(const Parameters ¶ms, const std::vector<Expression> &sub_exprs)>& val_fn) const;
protected:
Value val_;
diff --git a/extensions/http-curl/protocols/RESTSender.cpp b/extensions/http-curl/protocols/RESTSender.cpp
index a6cbe7d27..d39dc158f 100644
--- a/extensions/http-curl/protocols/RESTSender.cpp
+++ b/extensions/http-curl/protocols/RESTSender.cpp
@@ -92,7 +92,7 @@ void RESTSender::setSecurityContext(utils::HTTPClient &client, const std::string
client.initialize(type, url, generatedService);
}
-C2Payload RESTSender::sendPayload(const std::string url, const Direction direction, const C2Payload &payload, std::optional<std::string> data) {
+C2Payload RESTSender::sendPayload(const std::string& url, const Direction direction, const C2Payload &payload, std::optional<std::string> data) {
if (url.empty()) {
return {payload.getOperation(), state::UpdateState::READ_ERROR};
}
diff --git a/extensions/http-curl/protocols/RESTSender.h b/extensions/http-curl/protocols/RESTSender.h
index ff5c9f561..9fb96f35d 100644
--- a/extensions/http-curl/protocols/RESTSender.h
+++ b/extensions/http-curl/protocols/RESTSender.h
@@ -55,7 +55,7 @@ class RESTSender : public RESTProtocol, public C2Protocol {
void initialize(core::controller::ControllerServiceProvider* controller, const std::shared_ptr<Configure> &configure) override;
protected:
- C2Payload sendPayload(const std::string url, const Direction direction, const C2Payload &payload, std::optional<std::string> data);
+ C2Payload sendPayload(const std::string& url, const Direction direction, const C2Payload &payload, std::optional<std::string> data);
/**
* Initializes the SSLContextService onto the HTTP client if one is needed
diff --git a/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp b/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp
index fbb33db7b..b14dacb21 100644
--- a/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp
+++ b/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp
@@ -93,7 +93,7 @@ struct test_profile {
bool invalid_checksum{false};
};
-void run_variance(std::string test_file_location, bool isSecure, std::string url, const struct test_profile &profile) {
+void run_variance(const std::string& test_file_location, bool isSecure, const std::string& url, const struct test_profile &profile) {
SiteToSiteTestHarness harness(isSecure);
std::string in_port = "471deef6-2a6e-4a7d-912a-81cc17e3a204";
diff --git a/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp b/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
index 45938306a..37a2d85e9 100644
--- a/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
+++ b/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
@@ -103,7 +103,7 @@ TEST_CASE("HTTPTestsWithNoResourceClaimPOST", "[httptest1]") {
auto records = reporter->getEvents();
auto record = session->get();
REQUIRE(record == nullptr);
- REQUIRE(records.size() == 0);
+ REQUIRE(records.empty());
reporter = session->getProvenanceReporter();
@@ -117,7 +117,7 @@ TEST_CASE("HTTPTestsWithNoResourceClaimPOST", "[httptest1]") {
session->commit();
records = reporter->getEvents();
// FIXME(fgerlits): this test is very weak, as `records` is empty
- for (auto provEventRecord : records) {
+ for (const auto& provEventRecord : records) {
REQUIRE(provEventRecord->getComponentType() == TestHTTPServer::PROCESSOR_NAME);
}
@@ -197,7 +197,7 @@ TEST_CASE("HTTPTestsWithResourceClaimPOST", "[httptest1]") {
auto records = reporter->getEvents();
record = session->get();
REQUIRE(record == nullptr);
- REQUIRE(records.size() == 0);
+ REQUIRE(records.empty());
listenhttp->incrementActiveTasks();
listenhttp->setScheduledState(core::ScheduledState::RUNNING);
@@ -215,7 +215,7 @@ TEST_CASE("HTTPTestsWithResourceClaimPOST", "[httptest1]") {
session2->commit();
records = reporter->getEvents();
// FIXME(fgerlits): this test is very weak, as `records` is empty
- for (auto provEventRecord : records) {
+ for (const auto& provEventRecord : records) {
REQUIRE(provEventRecord->getComponentType() == listenhttp->getName());
}
@@ -238,14 +238,14 @@ TEST_CASE("HTTPTestsPostNoResourceClaim", "[httptest1]") {
auto records = plan->getProvenanceRecords();
std::shared_ptr<core::FlowFile> record = plan->getCurrentFlowFile();
REQUIRE(record == nullptr);
- REQUIRE(records.size() == 0);
+ REQUIRE(records.empty());
plan->reset();
testController.runSession(plan);
records = plan->getProvenanceRecords();
// FIXME(fgerlits): this test is very weak, as `records` is empty
- for (auto provEventRecord : records) {
+ for (const auto& provEventRecord : records) {
REQUIRE(provEventRecord->getComponentType() == TestHTTPServer::PROCESSOR_NAME);
}
diff --git a/extensions/jni/jvm/JniFlowFile.cpp b/extensions/jni/jvm/JniFlowFile.cpp
index 523ec9f8a..a4861e0ed 100644
--- a/extensions/jni/jvm/JniFlowFile.cpp
+++ b/extensions/jni/jvm/JniFlowFile.cpp
@@ -41,7 +41,7 @@ extern "C" {
namespace minifi = org::apache::nifi::minifi;
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getId(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
@@ -49,7 +49,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getId(JNIEnv
return id;
}
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getEntryDate(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
@@ -57,7 +57,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getEntryDate(
return entryDate;
}
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLineageStartDate(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
@@ -65,7 +65,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLineageSta
return val;
}
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLineageStartIndex(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
@@ -73,7 +73,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLineageSta
return val;
}
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLastQueueDatePrim(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
@@ -81,7 +81,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLastQueueD
return val;
}
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getQueueDateIndex(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
@@ -89,7 +89,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getQueueDateI
return val;
}
JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniFlowFile_isPenalized(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
@@ -97,7 +97,7 @@ JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniFlowFile_isPenalize
return val;
}
JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniFlowFile_getAttribute(JNIEnv *env, jobject obj, jstring key) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
@@ -106,14 +106,14 @@ JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniFlowFile_getAttribut
return env->NewStringUTF(value.c_str());
}
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getSize(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
jlong val = ff->getSize();
return val;
}
JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniFlowFile_getUUIDStr(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
@@ -121,7 +121,7 @@ JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniFlowFile_getUUIDStr
}
JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniFlowFile_getAttributes(JNIEnv *env, jobject obj) {
- minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
+ auto *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
jclass mapClass = env->FindClass("java/util/HashMap");
@@ -136,7 +136,7 @@ JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniFlowFile_getAttribut
jmethodID put = env->GetMethodID(mapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
- for (auto kf : ff->getAttributes()) {
+ for (const auto& kf : ff->getAttributes()) {
env->CallObjectMethod(hashMap, put, env->NewStringUTF(kf.first.c_str()), env->NewStringUTF(kf.second.c_str()));
minifi::jni::ThrowIf(env);
}
diff --git a/extensions/libarchive/ArchiveTests.h b/extensions/libarchive/ArchiveTests.h
index a8d60cd5f..36fdb1955 100644
--- a/extensions/libarchive/ArchiveTests.h
+++ b/extensions/libarchive/ArchiveTests.h
@@ -55,9 +55,9 @@ FN_VEC_T build_test_archive_order(int, const char**);
OrderedTestArchive build_ordered_test_archive(int, const char**, const char**);
-void build_test_archive(std::string, TAE_MAP_T entries, FN_VEC_T order = FN_VEC_T());
-void build_test_archive(std::string, OrderedTestArchive);
+void build_test_archive(const std::string&, const TAE_MAP_T& entries, FN_VEC_T order = FN_VEC_T());
+void build_test_archive(const std::string&, OrderedTestArchive&);
-bool check_archive_contents(std::string, TAE_MAP_T entries, bool check_attributes = true, FN_VEC_T order = FN_VEC_T());
-bool check_archive_contents(std::string, OrderedTestArchive, bool check_attributes = true);
+bool check_archive_contents(const std::string&, const TAE_MAP_T& entries, bool check_attributes = true, const FN_VEC_T& order = FN_VEC_T());
+bool check_archive_contents(const std::string&, const OrderedTestArchive&, bool check_attributes = true);
diff --git a/extensions/libarchive/BinFiles.cpp b/extensions/libarchive/BinFiles.cpp
index 9dd0084b8..82b31c282 100644
--- a/extensions/libarchive/BinFiles.cpp
+++ b/extensions/libarchive/BinFiles.cpp
@@ -80,7 +80,7 @@ void BinFiles::onSchedule(core::ProcessContext *context, core::ProcessSessionFac
}
}
-void BinFiles::preprocessFlowFile(core::ProcessContext* /*context*/, core::ProcessSession* /*session*/, std::shared_ptr<core::FlowFile> flow) {
+void BinFiles::preprocessFlowFile(core::ProcessContext* /*context*/, core::ProcessSession* /*session*/, const std::shared_ptr<core::FlowFile>& flow) {
// handle backward compatibility with old segment attributes
std::string value;
if (!flow->getAttribute(BinFiles::FRAGMENT_COUNT_ATTRIBUTE, value) && flow->getAttribute(BinFiles::SEGMENT_COUNT_ATTRIBUTE, value)) {
@@ -113,7 +113,7 @@ void BinManager::gatherReadyBins() {
emptyQueue.push_back(group_id);
}
}
- for (auto group : emptyQueue) {
+ for (const auto& group : emptyQueue) {
// erase from the map if the queue is empty for the group
groupBinMap_.erase(group);
}
@@ -156,7 +156,7 @@ void BinManager::getReadyBin(std::deque<std::unique_ptr<Bin>> &retBins) {
}
}
-bool BinManager::offer(const std::string &group, std::shared_ptr<core::FlowFile> flow) {
+bool BinManager::offer(const std::string &group, const std::shared_ptr<core::FlowFile>& flow) {
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.
@@ -279,7 +279,7 @@ void BinFiles::onTrigger(const std::shared_ptr<core::ProcessContext> &context, c
void BinFiles::transferFlowsToFail(core::ProcessContext* /*context*/, core::ProcessSession *session, std::unique_ptr<Bin> &bin) {
std::deque<std::shared_ptr<core::FlowFile>> &flows = bin->getFlowFile();
- for (auto flow : flows) {
+ for (const auto& flow : flows) {
session->transfer(flow, Failure);
}
flows.clear();
@@ -287,7 +287,7 @@ void BinFiles::transferFlowsToFail(core::ProcessContext* /*context*/, core::Proc
void BinFiles::addFlowsToSession(core::ProcessContext* /*context*/, core::ProcessSession *session, std::unique_ptr<Bin> &bin) {
std::deque<std::shared_ptr<core::FlowFile>> &flows = bin->getFlowFile();
- for (auto flow : flows) {
+ for (const auto& flow : flows) {
session->add(flow);
}
}
diff --git a/extensions/libarchive/BinFiles.h b/extensions/libarchive/BinFiles.h
index fc72ec147..71cece114 100644
--- a/extensions/libarchive/BinFiles.h
+++ b/extensions/libarchive/BinFiles.h
@@ -162,7 +162,7 @@ class BinManager {
binCount_ = 0;
}
// Adds the given flowFile to the first available bin in which it fits for the given group or creates a new bin in the specified group if necessary.
- bool offer(const std::string &group, std::shared_ptr<core::FlowFile> flow);
+ bool offer(const std::string &group, const std::shared_ptr<core::FlowFile>& flow);
// gather ready bins once the bin are full enough or exceed bin age
void gatherReadyBins();
// marks oldest bin as ready
@@ -253,7 +253,7 @@ class BinFiles : public core::Processor {
protected:
// Allows general pre-processing of a flow file before it is offered to a bin. This is called before getGroupId().
- virtual void preprocessFlowFile(core::ProcessContext *context, core::ProcessSession *session, std::shared_ptr<core::FlowFile> flow);
+ virtual void preprocessFlowFile(core::ProcessContext *context, core::ProcessSession *session, const std::shared_ptr<core::FlowFile>& flow);
// Returns a group ID representing a bin. This allows flow files to be binned into like groups
virtual std::string getGroupId(core::ProcessContext* /*context*/, std::shared_ptr<core::FlowFile> /*flow*/) {
return "";
diff --git a/extensions/libarchive/MergeContent.cpp b/extensions/libarchive/MergeContent.cpp
index c067a5a00..4a2d69f7d 100644
--- a/extensions/libarchive/MergeContent.cpp
+++ b/extensions/libarchive/MergeContent.cpp
@@ -36,7 +36,7 @@ void MergeContent::initialize() {
setSupportedRelationships(relationships());
}
-std::string MergeContent::readContent(std::string path) {
+std::string MergeContent::readContent(const std::string& path) {
std::string contents;
std::ifstream in(path.c_str(), std::ios::in | std::ios::binary);
if (in) {
@@ -159,7 +159,7 @@ bool MergeContent::checkDefragment(std::unique_ptr<Bin> &bin) {
catch (...) {
return false;
}
- for (auto flow : flows) {
+ for (const auto& flow : flows) {
std::string value;
if (!flow->getAttribute(BinFiles::FRAGMENT_ID_ATTRIBUTE, value))
return false;
@@ -262,7 +262,7 @@ bool MergeContent::processBin(core::ProcessContext *context, core::ProcessSessio
// we successfully merge the flow
session->transfer(merge_flow, Merge);
std::deque<std::shared_ptr<core::FlowFile>> &flows = bin->getFlowFile();
- for (auto flow : flows) {
+ for (const auto& flow : flows) {
session->transfer(flow, Original);
}
logger_->log_info("Merge FlowFile record UUID %s, payload length %d", merge_flow->getUUIDStr(), merge_flow->getSize());
diff --git a/extensions/libarchive/MergeContent.h b/extensions/libarchive/MergeContent.h
index 5d986280d..40bf1096b 100644
--- a/extensions/libarchive/MergeContent.h
+++ b/extensions/libarchive/MergeContent.h
@@ -363,7 +363,7 @@ class MergeContent : public processors::BinFiles {
std::string footerContent_;
std::string demarcatorContent_;
std::string attributeStrategy_;
- static std::string readContent(std::string path);
+ static std::string readContent(const std::string& path);
};
} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/script/lua/LuaScriptEngine.cpp b/extensions/script/lua/LuaScriptEngine.cpp
index 6e82d592c..48183c7b1 100644
--- a/extensions/script/lua/LuaScriptEngine.cpp
+++ b/extensions/script/lua/LuaScriptEngine.cpp
@@ -23,6 +23,7 @@
#include "LuaScriptEngine.h"
#include "LuaProcessSession.h"
+#include "utils/StringUtils.h"
namespace org::apache::nifi::minifi::lua {
@@ -62,9 +63,9 @@ LuaScriptEngine::LuaScriptEngine() {
void LuaScriptEngine::executeScriptWithAppendedModulePaths(std::string& script) {
for (const auto& module_path : module_paths_) {
if (std::filesystem::is_regular_file(std::filesystem::status(module_path))) {
- script = "package.path = package.path .. \";" + module_path + "\"\n" + script;
+ script = utils::StringUtils::join_pack("package.path = package.path .. \";", module_path, "\"\n", script);
} else {
- script = "package.path = package.path .. \";" + module_path + "/?.lua\"\n" + script;
+ script = utils::StringUtils::join_pack("package.path = package.path .. \";", module_path, "/?.lua\"\n", script);
}
}
lua_.script(script, sol::script_throw_on_error);
diff --git a/extensions/script/lua/LuaScriptEngine.h b/extensions/script/lua/LuaScriptEngine.h
index 8873335c9..0838d121f 100644
--- a/extensions/script/lua/LuaScriptEngine.h
+++ b/extensions/script/lua/LuaScriptEngine.h
@@ -31,11 +31,7 @@
#include "LuaProcessSession.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace lua {
+namespace org::apache::nifi::minifi::lua {
class LuaScriptEngine : public script::ScriptEngine {
public:
@@ -115,8 +111,4 @@ class LuaScriptEngine : public script::ScriptEngine {
sol::state lua_;
};
-} /* namespace lua */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::lua
diff --git a/extensions/script/python/PyProcessSession.cpp b/extensions/script/python/PyProcessSession.cpp
index 78b92dd57..d9047e0e0 100644
--- a/extensions/script/python/PyProcessSession.cpp
+++ b/extensions/script/python/PyProcessSession.cpp
@@ -23,11 +23,7 @@
#include "PyProcessSession.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;
@@ -53,8 +49,8 @@ std::shared_ptr<script::ScriptFlowFile> PyProcessSession::get() {
return result;
}
-void PyProcessSession::transfer(std::shared_ptr<script::ScriptFlowFile> script_flow_file,
- core::Relationship relationship) {
+void PyProcessSession::transfer(const std::shared_ptr<script::ScriptFlowFile>& script_flow_file,
+ const core::Relationship& relationship) {
if (!session_) {
throw std::runtime_error("Access of ProcessSession after it has been released");
}
@@ -68,7 +64,7 @@ void PyProcessSession::transfer(std::shared_ptr<script::ScriptFlowFile> script_f
session_->transfer(flow_file, relationship);
}
-void PyProcessSession::read(std::shared_ptr<script::ScriptFlowFile> script_flow_file,
+void PyProcessSession::read(const std::shared_ptr<script::ScriptFlowFile>& script_flow_file,
py::object input_stream_callback) {
if (!session_) {
throw std::runtime_error("Access of ProcessSession after it has been released");
@@ -85,7 +81,7 @@ void PyProcessSession::read(std::shared_ptr<script::ScriptFlowFile> script_flow_
});
}
-void PyProcessSession::write(std::shared_ptr<script::ScriptFlowFile> script_flow_file,
+void PyProcessSession::write(const std::shared_ptr<script::ScriptFlowFile>& script_flow_file,
py::object output_stream_callback) {
if (!session_) {
throw std::runtime_error("Access of ProcessSession after it has been released");
@@ -112,7 +108,7 @@ std::shared_ptr<script::ScriptFlowFile> PyProcessSession::create() {
return result;
}
-std::shared_ptr<script::ScriptFlowFile> PyProcessSession::create(std::shared_ptr<script::ScriptFlowFile> flow_file) {
+std::shared_ptr<script::ScriptFlowFile> PyProcessSession::create(const std::shared_ptr<script::ScriptFlowFile>& flow_file) {
if (!session_) {
throw std::runtime_error("Access of ProcessSession after it has been released");
}
@@ -139,8 +135,4 @@ void PyProcessSession::releaseCoreResources() {
session_.reset();
}
-} /* namespace python */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::python
diff --git a/extensions/script/python/PyProcessSession.h b/extensions/script/python/PyProcessSession.h
index 2cdee8a3e..5637159b9 100644
--- a/extensions/script/python/PyProcessSession.h
+++ b/extensions/script/python/PyProcessSession.h
@@ -29,11 +29,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;
@@ -43,10 +39,10 @@ class PyProcessSession {
std::shared_ptr<script::ScriptFlowFile> get();
std::shared_ptr<script::ScriptFlowFile> create();
- std::shared_ptr<script::ScriptFlowFile> create(std::shared_ptr<script::ScriptFlowFile> flow_file);
- void transfer(std::shared_ptr<script::ScriptFlowFile> flow_file, core::Relationship relationship);
- void read(std::shared_ptr<script::ScriptFlowFile> flow_file, py::object input_stream_callback);
- void write(std::shared_ptr<script::ScriptFlowFile> flow_file, py::object output_stream_callback);
+ std::shared_ptr<script::ScriptFlowFile> create(const std::shared_ptr<script::ScriptFlowFile>& flow_file);
+ void transfer(const std::shared_ptr<script::ScriptFlowFile>& flow_file, const core::Relationship& relationship);
+ void read(const std::shared_ptr<script::ScriptFlowFile>& flow_file, py::object input_stream_callback);
+ void write(const std::shared_ptr<script::ScriptFlowFile>& flow_file, py::object output_stream_callback);
/**
* Sometimes we want to release shared pointers to core resources when
@@ -63,10 +59,6 @@ class PyProcessSession {
std::shared_ptr<core::ProcessSession> session_;
};
-} /* 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/python/PythonBindings.h b/extensions/script/python/PythonBindings.h
index 443e74f77..15f68b3c7 100644
--- a/extensions/script/python/PythonBindings.h
+++ b/extensions/script/python/PythonBindings.h
@@ -50,7 +50,7 @@ PYBIND11_EMBEDDED_MODULE(minifi_native, m) { // NOLINT
.def("create",
static_cast<std::shared_ptr<script::ScriptFlowFile> (python::PyProcessSession::*)()>(&python::PyProcessSession::create))
.def("create",
- static_cast<std::shared_ptr<script::ScriptFlowFile> (python::PyProcessSession::*)(std::shared_ptr<script::ScriptFlowFile>)>(&python::PyProcessSession::create))
+ static_cast<std::shared_ptr<script::ScriptFlowFile> (python::PyProcessSession::*)(const std::shared_ptr<script::ScriptFlowFile>&)>(&python::PyProcessSession::create))
.def("read", &python::PyProcessSession::read)
.def("write", &python::PyProcessSession::write)
.def("transfer", &python::PyProcessSession::transfer);
diff --git a/extensions/sftp/client/SFTPClient.cpp b/extensions/sftp/client/SFTPClient.cpp
index 39872d309..7afcc98df 100644
--- a/extensions/sftp/client/SFTPClient.cpp
+++ b/extensions/sftp/client/SFTPClient.cpp
@@ -724,7 +724,7 @@ bool SFTPClient::listDirectory(const std::string& path, bool follow_symlinks,
attrs = orig_attrs;
}
}
- children_result.emplace_back(std::string(filename.data()), std::string(longentry.data()), std::move(attrs));
+ children_result.emplace_back(std::string(filename.data()), std::string(longentry.data()), attrs);
} while (true);
return true;
}
diff --git a/extensions/standard-processors/processors/DefragmentText.cpp b/extensions/standard-processors/processors/DefragmentText.cpp
index 18d83f65e..623534889 100644
--- a/extensions/standard-processors/processors/DefragmentText.cpp
+++ b/extensions/standard-processors/processors/DefragmentText.cpp
@@ -94,7 +94,7 @@ void DefragmentText::onTrigger(core::ProcessContext*, core::ProcessSession* sess
auto flowFiles = flow_file_store_.getNewFlowFiles();
for (auto& file : flowFiles) {
if (file)
- processNextFragment(session, gsl::not_null(std::move(file)));
+ processNextFragment(session, gsl::not_null(file));
}
{
std::shared_ptr<core::FlowFile> original_flow_file = session->get();
diff --git a/extensions/standard-processors/tests/integration/TestExecuteProcess.cpp b/extensions/standard-processors/tests/integration/TestExecuteProcess.cpp
index c16c59ddf..7b932244e 100644
--- a/extensions/standard-processors/tests/integration/TestExecuteProcess.cpp
+++ b/extensions/standard-processors/tests/integration/TestExecuteProcess.cpp
@@ -87,17 +87,15 @@ int main(int /*argc*/, char ** /*argv*/) {
core::ProcessSessionFactory factory(contextset);
processor->onSchedule(contextset.get(), &factory);
- for (int i = 0; i < 1; i++) {
- processor_workers.push_back(std::thread([processor, test_repo, &is_ready]() {
- auto node = std::make_shared<core::ProcessorNode>(processor.get());
- auto context = std::make_shared<core::ProcessContext>(node, nullptr, test_repo, test_repo);
- context->setProperty(org::apache::nifi::minifi::processors::ExecuteProcess::Command, "sleep 0.5");
- auto session = std::make_shared<core::ProcessSession>(context);
- while (!is_ready.load(std::memory_order_relaxed)) {
- }
- processor->onTrigger(context.get(), session.get());
- }));
- }
+ processor_workers.push_back(std::thread([processor, test_repo, &is_ready]() {
+ auto node = std::make_shared<core::ProcessorNode>(processor.get());
+ auto context = std::make_shared<core::ProcessContext>(node, nullptr, test_repo, test_repo);
+ context->setProperty(org::apache::nifi::minifi::processors::ExecuteProcess::Command, "sleep 0.5");
+ auto session = std::make_shared<core::ProcessSession>(context);
+ while (!is_ready.load(std::memory_order_relaxed)) {
+ }
+ processor->onTrigger(context.get(), session.get());
+ }));
is_ready.store(true, std::memory_order_relaxed);
diff --git a/extensions/standard-processors/tests/unit/ProcessorTests.cpp b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
index fe00f439c..d563baf59 100644
--- a/extensions/standard-processors/tests/unit/ProcessorTests.cpp
+++ b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
@@ -225,7 +225,7 @@ TEST_CASE("Test GetFile Ignore", "[getfileCreate3]") {
records = reporter->getEvents();
- for (auto provEventRecord : records) {
+ for (const auto& provEventRecord : records) {
REQUIRE(provEventRecord->getComponentType() == processor->getName());
}
session->commit();
@@ -445,7 +445,7 @@ TEST_CASE("Test Find file", "[getfileCreate3]") {
records = plan->getProvenanceRecords();
record = plan->getCurrentFlowFile();
- for (auto provEventRecord : records) {
+ for (const auto& provEventRecord : records) {
REQUIRE(provEventRecord->getComponentType() == processor->getName());
}
std::shared_ptr<core::FlowFile> ffr = plan->getCurrentFlowFile();
@@ -459,7 +459,7 @@ TEST_CASE("Test Find file", "[getfileCreate3]") {
newRecord.DeSerialize(gsl::make_span(entry.second).as_span<const std::byte>());
bool found = false;
- for (auto provRec : records) {
+ for (const auto& provRec : records) {
if (provRec->getEventId() == newRecord.getEventId()) {
REQUIRE(provRec->getEventId() == newRecord.getEventId());
REQUIRE(provRec->getComponentId() == newRecord.getComponentId());
diff --git a/extensions/standard-processors/tests/unit/TailFileTests.cpp b/extensions/standard-processors/tests/unit/TailFileTests.cpp
index 1bd4319a5..387f579a2 100644
--- a/extensions/standard-processors/tests/unit/TailFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/TailFileTests.cpp
@@ -43,6 +43,7 @@
#include "TailFile.h"
#include "LogAttribute.h"
#include "utils/TestUtils.h"
+#include "utils/StringUtils.h"
using namespace std::literals::chrono_literals;
@@ -1349,7 +1350,7 @@ TEST_CASE("TailFile handles the Delimiter setting correctly", "[delimiter]") {
auto temp_directory = testController.createTempDirectory();
std::string delimiter = test_case.second;
- std::string full_file_name = createTempFile(temp_directory, "test.log", "one" + delimiter + "two" + delimiter);
+ std::string full_file_name = createTempFile(temp_directory, "test.log", utils::StringUtils::join_pack("one", delimiter, "two", delimiter));
auto plan = testController.createPlan();
diff --git a/libminifi/include/RemoteProcessorGroupPort.h b/libminifi/include/RemoteProcessorGroupPort.h
index 98663ed69..c78413ccb 100644
--- a/libminifi/include/RemoteProcessorGroupPort.h
+++ b/libminifi/include/RemoteProcessorGroupPort.h
@@ -17,8 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_REMOTEPROCESSORGROUPPORT_H_
-#define LIBMINIFI_INCLUDE_REMOTEPROCESSORGROUPPORT_H_
+#pragma once
#include <string>
#include <utility>
@@ -37,10 +36,7 @@
#include "core/logging/LoggerConfiguration.h"
#include "utils/Export.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
+namespace org::apache::nifi::minifi {
/**
* Count down latch implementation that's used across
@@ -241,8 +237,4 @@ class RemoteProcessorGroupPort : public core::Processor {
static const char* RPG_SSL_CONTEXT_SERVICE_NAME;
};
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-#endif // LIBMINIFI_INCLUDE_REMOTEPROCESSORGROUPPORT_H_
+} // namespace org::apache::nifi::minifi
diff --git a/libminifi/include/core/controller/StandardControllerServiceNode.h b/libminifi/include/core/controller/StandardControllerServiceNode.h
index 8a710d6e8..90c693a65 100644
--- a/libminifi/include/core/controller/StandardControllerServiceNode.h
+++ b/libminifi/include/core/controller/StandardControllerServiceNode.h
@@ -15,8 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_CORE_CONTROLLER_STANDARDCONTROLLERSERVICENODE_H_
-#define LIBMINIFI_INCLUDE_CORE_CONTROLLER_STANDARDCONTROLLERSERVICENODE_H_
+#pragma once
#include <memory>
#include <string>
@@ -26,12 +25,7 @@
#include "core/logging/LoggerConfiguration.h"
#include "core/ProcessGroup.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace controller {
+namespace org::apache::nifi::minifi::core::controller {
class StandardControllerServiceNode : public ControllerServiceNode {
public:
@@ -90,11 +84,4 @@ class StandardControllerServiceNode : public ControllerServiceNode {
std::shared_ptr<logging::Logger> logger_;
};
-} // namespace controller
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // LIBMINIFI_INCLUDE_CORE_CONTROLLER_STANDARDCONTROLLERSERVICENODE_H_
+} // namespace org::apache::nifi::minifi::core::controller
diff --git a/libminifi/include/core/reporting/SiteToSiteProvenanceReportingTask.h b/libminifi/include/core/reporting/SiteToSiteProvenanceReportingTask.h
index 6ac010a2f..e9a1083da 100644
--- a/libminifi/include/core/reporting/SiteToSiteProvenanceReportingTask.h
+++ b/libminifi/include/core/reporting/SiteToSiteProvenanceReportingTask.h
@@ -17,8 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_CORE_REPORTING_SITETOSITEPROVENANCEREPORTINGTASK_H_
-#define LIBMINIFI_INCLUDE_CORE_REPORTING_SITETOSITEPROVENANCEREPORTINGTASK_H_
+#pragma once
#include <mutex>
#include <memory>
@@ -30,12 +29,7 @@
#include "io/StreamFactory.h"
#include "core/logging/LoggerConfiguration.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace reporting {
+namespace org::apache::nifi::minifi::core::reporting {
//! SiteToSiteProvenanceReportingTask Class
class SiteToSiteProvenanceReportingTask : public minifi::RemoteProcessorGroupPort {
@@ -93,11 +87,4 @@ class SiteToSiteProvenanceReportingTask : public minifi::RemoteProcessorGroupPor
// SiteToSiteProvenanceReportingTask
-} // namespace reporting
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // LIBMINIFI_INCLUDE_CORE_REPORTING_SITETOSITEPROVENANCEREPORTINGTASK_H_
+} // namespace org::apache::nifi::minifi::core::reporting
diff --git a/libminifi/include/core/yaml/YamlConnectionParser.h b/libminifi/include/core/yaml/YamlConnectionParser.h
index fe6f58ed8..6c906eabe 100644
--- a/libminifi/include/core/yaml/YamlConnectionParser.h
+++ b/libminifi/include/core/yaml/YamlConnectionParser.h
@@ -27,12 +27,7 @@
#include "yaml-cpp/yaml.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace yaml {
+namespace org::apache::nifi::minifi::core::yaml {
class YamlConnectionParser {
public:
@@ -63,9 +58,4 @@ class YamlConnectionParser {
const std::shared_ptr<logging::Logger> logger_;
};
-} // namespace yaml
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::core::yaml
diff --git a/libminifi/include/io/tls/TLSServerSocket.h b/libminifi/include/io/tls/TLSServerSocket.h
index 35160c200..af465f99c 100644
--- a/libminifi/include/io/tls/TLSServerSocket.h
+++ b/libminifi/include/io/tls/TLSServerSocket.h
@@ -15,8 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_IO_TLS_TLSSERVERSOCKET_H_
-#define LIBMINIFI_INCLUDE_IO_TLS_TLSSERVERSOCKET_H_
+#pragma once
#include <memory>
#include <string>
@@ -25,11 +24,7 @@
#include "TLSSocket.h"
#include "../ServerSocket.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace io {
+namespace org::apache::nifi::minifi::io {
/**
* Purpose: Server socket abstraction that makes focusing the accept/block paradigm
@@ -74,9 +69,4 @@ class TLSServerSocket : public BaseServerSocket, public TLSSocket {
std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<TLSServerSocket>::getLogger();
};
-} // namespace io
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-#endif // LIBMINIFI_INCLUDE_IO_TLS_TLSSERVERSOCKET_H_
+} // namespace org::apache::nifi::minifi::io
diff --git a/libminifi/include/io/tls/TLSSocket.h b/libminifi/include/io/tls/TLSSocket.h
index 5296fb14c..2ed107b7f 100644
--- a/libminifi/include/io/tls/TLSSocket.h
+++ b/libminifi/include/io/tls/TLSSocket.h
@@ -15,8 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_IO_TLS_TLSSOCKET_H_
-#define LIBMINIFI_INCLUDE_IO_TLS_TLSSOCKET_H_
+#pragma once
#include <openssl/err.h>
#include <openssl/ssl.h>
@@ -33,11 +32,7 @@
#include "io/ClientSocket.h"
#include "properties/Configure.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace io {
+namespace org::apache::nifi::minifi::io {
#define TLS_GOOD 0
#define TLS_ERROR_CONTEXT 1
@@ -110,9 +105,9 @@ class TLSSocket : public Socket {
/**
* Move constructor.
*/
- TLSSocket(TLSSocket &&);
+ TLSSocket(TLSSocket &&) noexcept;
- TLSSocket& operator=(TLSSocket&&);
+ TLSSocket& operator=(TLSSocket&&) noexcept;
~TLSSocket() override;
@@ -176,10 +171,4 @@ class TLSSocket : public Socket {
std::map<int, SSL*> ssl_map_;
};
-} // namespace io
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
-#endif // LIBMINIFI_INCLUDE_IO_TLS_TLSSOCKET_H_
+} // namespace org::apache::nifi::minifi::io
diff --git a/libminifi/include/utils/ClassUtils.h b/libminifi/include/utils/ClassUtils.h
index 3d82c4322..c24d87757 100644
--- a/libminifi/include/utils/ClassUtils.h
+++ b/libminifi/include/utils/ClassUtils.h
@@ -14,17 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_UTILS_CLASSUTILS_H_
-#define LIBMINIFI_INCLUDE_UTILS_CLASSUTILS_H_
+#pragma once
#include <string>
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
-namespace ClassUtils {
+namespace org::apache::nifi::minifi::utils::ClassUtils {
/**
* Shortens class names via the canonical representation ( package with name )
@@ -34,11 +28,4 @@ namespace ClassUtils {
*/
bool shortenClassName(const std::string &class_name, std::string &out);
-} /* namespace ClassUtils */
-} /* namespace utils */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
-
-#endif /* LIBMINIFI_INCLUDE_UTILS_CLASSUTILS_H_ */
+} // namespace org::apache::nifi::minifi::utils::ClassUtils
diff --git a/libminifi/include/utils/RegexUtils.h b/libminifi/include/utils/RegexUtils.h
index 410af0670..d09c4e793 100644
--- a/libminifi/include/utils/RegexUtils.h
+++ b/libminifi/include/utils/RegexUtils.h
@@ -129,8 +129,8 @@ class Regex {
Regex(std::string value, const std::vector<Mode> &mode);
Regex(const Regex &);
Regex& operator=(const Regex &);
- Regex(Regex&& other);
- Regex& operator=(Regex&& other);
+ Regex(Regex&& other) noexcept;
+ Regex& operator=(Regex&& other) noexcept;
#ifndef NO_MORE_REGFREEE
~Regex();
#endif
diff --git a/libminifi/include/utils/StringUtils.h b/libminifi/include/utils/StringUtils.h
index b48e8eef6..942f0e13a 100644
--- a/libminifi/include/utils/StringUtils.h
+++ b/libminifi/include/utils/StringUtils.h
@@ -161,7 +161,7 @@ class StringUtils {
* @param output output float
* @param cp failure policy
*/
- static bool StringToFloat(std::string input, float &output, FailurePolicy cp = RETURN);
+ static bool StringToFloat(const std::string& input, float &output, FailurePolicy cp = RETURN);
static std::string replaceEnvironmentVariables(std::string source_string);
diff --git a/libminifi/src/RemoteProcessorGroupPort.cpp b/libminifi/src/RemoteProcessorGroupPort.cpp
index 7160f7b21..55df0cae9 100644
--- a/libminifi/src/RemoteProcessorGroupPort.cpp
+++ b/libminifi/src/RemoteProcessorGroupPort.cpp
@@ -258,7 +258,7 @@ std::pair<std::string, int> RemoteProcessorGroupPort::refreshRemoteSite2SiteInfo
if (nifi_instances_.empty())
return std::make_pair("", -1);
- for (auto nifi : nifi_instances_) {
+ for (const auto& nifi : nifi_instances_) {
std::string host = nifi.host_;
#ifdef WIN32
if ("localhost" == host) {
diff --git a/libminifi/src/c2/C2Agent.cpp b/libminifi/src/c2/C2Agent.cpp
index b22dce01d..5785be368 100644
--- a/libminifi/src/c2/C2Agent.cpp
+++ b/libminifi/src/c2/C2Agent.cpp
@@ -122,7 +122,7 @@ void C2Agent::checkTriggers() {
// handle the response the same way. This means that
// acknowledgements will be sent to the c2 server for every trigger action.
// this is expected
- extractPayload(std::move(triggerAction));
+ extractPayload(triggerAction);
// call reset if the trigger supports this activity
trigger->reset();
} else {
@@ -346,7 +346,7 @@ void C2Agent::handle_c2_server_response(const C2ContentResponse &resp) {
case Operation::RESTART: {
update_sink_->stop();
C2Payload response(Operation::ACKNOWLEDGE, resp.ident, true);
- protocol_.load()->consumePayload(std::move(response));
+ protocol_.load()->consumePayload(response);
restart_needed_ = true;
}
break;
@@ -409,7 +409,7 @@ C2Payload C2Agent::prepareConfigurationOptions(const C2ContentResponse &resp) co
auto unsanitized_keys = configuration_->getConfiguredKeys();
std::vector<std::string> keys;
std::copy_if(unsanitized_keys.begin(), unsanitized_keys.end(), std::back_inserter(keys),
- [](std::string key) {return key.find("pass") == std::string::npos;});
+ [](const std::string& key) {return key.find("pass") == std::string::npos;});
C2Payload response(Operation::ACKNOWLEDGE, resp.ident, true);
C2Payload options(Operation::ACKNOWLEDGE);
@@ -625,13 +625,13 @@ void C2Agent::handlePropertyUpdate(const C2ContentResponse &resp) {
}
};
- for (auto entry : resp.operation_arguments) {
+ for (const auto& [name, value] : resp.operation_arguments) {
bool persist = (
- entry.second.getAnnotation("persist")
+ value.getAnnotation("persist")
| utils::map(&AnnotatedValue::to_string)
| utils::flatMap(utils::StringUtils::toBool)).value_or(true);
PropertyChangeLifetime lifetime = persist ? PropertyChangeLifetime::PERSISTENT : PropertyChangeLifetime::TRANSIENT;
- changeUpdateState(update_property(entry.first, entry.second.to_string(), lifetime));
+ changeUpdateState(update_property(name, value.to_string(), lifetime));
}
// apply changes and persist properties requested to be persisted
const bool propertyWasUpdated = result == state::UpdateState::FULLY_APPLIED || result == state::UpdateState::PARTIALLY_APPLIED;
@@ -739,7 +739,7 @@ utils::TaskRescheduleInfo C2Agent::produce() {
std::make_move_iterator(payload_batch.end()),
[&] (C2Payload&& payload) {
try {
- C2Payload && response = protocol_.load()->consumePayload(std::move(payload));
+ C2Payload response = protocol_.load()->consumePayload(payload);
enqueue_c2_server_response(std::move(response));
}
catch(const std::exception &e) {
@@ -775,7 +775,7 @@ utils::TaskRescheduleInfo C2Agent::produce() {
utils::TaskRescheduleInfo C2Agent::consume() {
if (!responses.empty()) {
const auto consume_success = responses.consume([this] (C2Payload&& payload) {
- extractPayload(std::move(payload));
+ extractPayload(payload);
});
if (!consume_success) {
extractPayload(C2Payload{ Operation::HEARTBEAT });
diff --git a/libminifi/src/c2/C2Client.cpp b/libminifi/src/c2/C2Client.cpp
index c7adee079..139661909 100644
--- a/libminifi/src/c2/C2Client.cpp
+++ b/libminifi/src/c2/C2Client.cpp
@@ -33,6 +33,7 @@
#include "utils/file/FileSystem.h"
#include "utils/file/FileUtils.h"
#include "utils/gsl.h"
+#include "utils/StringUtils.h"
namespace org::apache::nifi::minifi::c2 {
@@ -123,7 +124,7 @@ void C2Client::loadC2ResponseConfiguration(const std::string &prefix) {
for (const std::string& metricsClass : classes) {
try {
- std::string option = prefix + "." + metricsClass;
+ std::string option = utils::StringUtils::join_pack(prefix, ".", metricsClass);
std::string classOption = option + ".classes";
std::string nameOption = option + ".name";
@@ -135,7 +136,7 @@ void C2Client::loadC2ResponseConfiguration(const std::string &prefix) {
if (configuration_->get(classOption, class_definitions)) {
loadNodeClasses(class_definitions, new_node);
} else {
- std::string optionName = option + "." + name;
+ std::string optionName = utils::StringUtils::join_pack(option, ".", name);
loadC2ResponseConfiguration(optionName, new_node);
}
@@ -156,7 +157,7 @@ std::shared_ptr<state::response::ResponseNode> C2Client::loadC2ResponseConfigura
for (const std::string& metricsClass : classes) {
try {
- std::string option = prefix + "." + metricsClass;
+ std::string option = utils::StringUtils::join_pack(prefix, ".", metricsClass);
std::string classOption = option + ".classes";
std::string nameOption = option + ".name";
@@ -180,7 +181,7 @@ std::shared_ptr<state::response::ResponseNode> C2Client::loadC2ResponseConfigura
std::static_pointer_cast<state::response::ObjectNode>(prev_node)->add_node(new_node);
}
} else {
- std::string optionName = option + "." + name;
+ std::string optionName = utils::StringUtils::join_pack(option, ".", name);
auto sub_node = loadC2ResponseConfiguration(optionName, new_node);
std::static_pointer_cast<state::response::ObjectNode>(prev_node)->add_node(sub_node);
}
diff --git a/libminifi/src/core/controller/StandardControllerServiceNode.cpp b/libminifi/src/core/controller/StandardControllerServiceNode.cpp
index 955524512..fd6fa325b 100644
--- a/libminifi/src/core/controller/StandardControllerServiceNode.cpp
+++ b/libminifi/src/core/controller/StandardControllerServiceNode.cpp
@@ -20,12 +20,7 @@
#include <memory>
#include <mutex>
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace controller {
+namespace org::apache::nifi::minifi::core::controller {
bool StandardControllerServiceNode::enable() {
Property property("Linked Services", "Referenced Controller Services");
@@ -33,7 +28,7 @@ bool StandardControllerServiceNode::enable() {
logger_->log_trace("Enabling CSN %s", getName());
if (getProperty(property.getName(), property)) {
active = true;
- for (auto linked_service : property.getValues()) {
+ for (const auto& linked_service : property.getValues()) {
std::shared_ptr<ControllerServiceNode> csNode = provider->getControllerServiceNode(linked_service);
if (nullptr != csNode) {
std::lock_guard<std::mutex> lock(mutex_);
@@ -46,7 +41,7 @@ bool StandardControllerServiceNode::enable() {
if (nullptr != impl) {
std::lock_guard<std::mutex> lock(mutex_);
std::vector<std::shared_ptr<ControllerService> > services;
- for (auto service : linked_controller_services_) {
+ for (const auto& service : linked_controller_services_) {
services.push_back(service->getControllerServiceImplementation());
}
impl->setLinkedControllerServices(services);
@@ -55,9 +50,4 @@ bool StandardControllerServiceNode::enable() {
return true;
}
-} /* namespace controller */
-} /* namespace core */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::core::controller
diff --git a/libminifi/src/core/reporting/SiteToSiteProvenanceReportingTask.cpp b/libminifi/src/core/reporting/SiteToSiteProvenanceReportingTask.cpp
index 85d8af0d7..950977728 100644
--- a/libminifi/src/core/reporting/SiteToSiteProvenanceReportingTask.cpp
+++ b/libminifi/src/core/reporting/SiteToSiteProvenanceReportingTask.cpp
@@ -46,12 +46,7 @@
#include "FlowController.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace reporting {
+namespace org::apache::nifi::minifi::core::reporting {
const char *SiteToSiteProvenanceReportingTask::ProvenanceAppStr = "MiNiFi Flow";
@@ -102,7 +97,7 @@ void SiteToSiteProvenanceReportingTask::getJsonReport(const std::shared_ptr<core
rapidjson::Document array(rapidjson::kArrayType);
rapidjson::Document::AllocatorType &alloc = array.GetAllocator();
- for (auto sercomp : records) {
+ for (const auto& sercomp : records) {
std::shared_ptr<provenance::ProvenanceEventRecord> record = std::dynamic_pointer_cast<provenance::ProvenanceEventRecord>(sercomp);
if (nullptr == record) {
break;
@@ -131,7 +126,7 @@ void SiteToSiteProvenanceReportingTask::getJsonReport(const std::shared_ptr<core
recordJson.AddMember("remoteIdentifier", getStringValue(record->getSourceSystemFlowFileIdentifier(), alloc), alloc);
recordJson.AddMember("alternateIdentifier", getStringValue(record->getAlternateIdentifierUri(), alloc), alloc);
- for (auto attr : record->getAttributes()) {
+ for (const auto& attr : record->getAttributes()) {
setJsonStr(attr.first, attr.second, updatedAttributesJson, alloc);
}
recordJson.AddMember("updatedAttributes", updatedAttributesJson, alloc);
@@ -202,9 +197,4 @@ void SiteToSiteProvenanceReportingTask::onTrigger(const std::shared_ptr<core::Pr
returnProtocol(std::move(protocol_));
}
-} /* namespace reporting */
-} /* namespace core */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::core::reporting
diff --git a/libminifi/src/core/yaml/YamlConnectionParser.cpp b/libminifi/src/core/yaml/YamlConnectionParser.cpp
index b19e90eb0..5e246d8bc 100644
--- a/libminifi/src/core/yaml/YamlConnectionParser.cpp
+++ b/libminifi/src/core/yaml/YamlConnectionParser.cpp
@@ -24,7 +24,7 @@ namespace org::apache::nifi::minifi::core::yaml {
void YamlConnectionParser::addNewRelationshipToConnection(const std::string& relationship_name, minifi::Connection& connection) const {
core::Relationship relationship(relationship_name, "");
logger_->log_debug("parseConnection: relationship => [%s]", relationship_name);
- connection.addRelationship(std::move(relationship));
+ connection.addRelationship(relationship);
}
void YamlConnectionParser::addFunnelRelationshipToConnection(minifi::Connection& connection) const {
diff --git a/libminifi/src/io/tls/TLSServerSocket.cpp b/libminifi/src/io/tls/TLSServerSocket.cpp
index 3a67c4b2f..b3a473a6b 100644
--- a/libminifi/src/io/tls/TLSServerSocket.cpp
+++ b/libminifi/src/io/tls/TLSServerSocket.cpp
@@ -48,11 +48,7 @@
#include "utils/GeneralUtils.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace io {
+namespace org::apache::nifi::minifi::io {
TLSServerSocket::TLSServerSocket(const std::shared_ptr<TLSContext> &context, const std::string &hostname, const uint16_t port, const uint16_t listeners = -1)
: TLSSocket(context, hostname, port, listeners),
@@ -70,7 +66,7 @@ TLSServerSocket::~TLSServerSocket() {
* @return result of the creation operation.
*/
void TLSServerSocket::registerCallback(std::function<bool()> accept_function, std::function<void(io::BaseStream *)> handler) {
- auto fx = [this](std::function<bool()> /*accept_function*/, std::function<void(io::BaseStream *)> handler) {
+ auto fx = [this](const std::function<bool()>& /*accept_function*/, const std::function<void(io::BaseStream *)>& handler) {
while (running_) {
int fd = select_descriptor(1000);
if (fd >= 0) {
@@ -145,8 +141,4 @@ void TLSServerSocket::close_fd(int fd) {
close_ssl(fd);
}
-} // namespace io
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::io
diff --git a/libminifi/src/io/tls/TLSSocket.cpp b/libminifi/src/io/tls/TLSSocket.cpp
index fa4585197..98de6c8d8 100644
--- a/libminifi/src/io/tls/TLSSocket.cpp
+++ b/libminifi/src/io/tls/TLSSocket.cpp
@@ -35,11 +35,7 @@
#include "utils/gsl.h"
#include "utils/tls/TLSUtils.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace io {
+namespace org::apache::nifi::minifi::io {
TLSContext::TLSContext(const std::shared_ptr<Configure> &configure, std::shared_ptr<minifi::controllers::SSLContextService> ssl_service)
: SocketContext(configure),
@@ -130,7 +126,7 @@ int16_t TLSContext::initialize(bool server_method) {
}
// load CA certificates
if (ssl_service_ != nullptr || configure_->get(Configure::nifi_security_client_ca_certificate, caCertificate)) {
- retp = SSL_CTX_load_verify_locations(local_context.get(), caCertificate.c_str(), 0);
+ retp = SSL_CTX_load_verify_locations(local_context.get(), caCertificate.c_str(), nullptr);
if (retp == 0) {
logger_->log_error("Can not load CA certificate, Exiting, error : %s", std::strerror(errno));
error_value = TLS_ERROR_CERT_ERROR;
@@ -150,7 +146,7 @@ TLSSocket::~TLSSocket() {
}
void TLSSocket::close() {
- if (ssl_ != 0) {
+ if (ssl_ != nullptr) {
SSL_free(ssl_);
ssl_ = nullptr;
}
@@ -176,7 +172,7 @@ TLSSocket::TLSSocket(const std::shared_ptr<TLSContext> &context, const std::stri
context_ = context;
}
-TLSSocket::TLSSocket(TLSSocket &&other)
+TLSSocket::TLSSocket(TLSSocket &&other) noexcept
: Socket(std::move(other)),
context_{ std::exchange(other.context_, nullptr) } {
std::lock_guard<std::mutex> lg{ other.ssl_mutex_ }; // NOLINT(bugprone-use-after-move)
@@ -187,7 +183,7 @@ TLSSocket::TLSSocket(TLSSocket &&other)
ssl_map_ = std::exchange(other.ssl_map_, {}); // NOLINT(bugprone-use-after-move)
}
-TLSSocket& TLSSocket::operator=(TLSSocket&& other) {
+TLSSocket& TLSSocket::operator=(TLSSocket&& other) noexcept {
if (&other == this) return *this;
this->Socket::operator=(static_cast<Socket&&>(other));
std::lock_guard<std::mutex> lg{ other.ssl_mutex_ };
@@ -276,9 +272,9 @@ int16_t TLSSocket::select_descriptor(const uint16_t msec) {
std::lock_guard<std::recursive_mutex> guard(selection_mutex_);
if (msec > 0)
- select(socket_max_ + 1, &read_fds_, NULL, NULL, &tv);
+ select(socket_max_ + 1, &read_fds_, nullptr, nullptr, &tv);
else
- select(socket_max_ + 1, &read_fds_, NULL, NULL, NULL);
+ select(socket_max_ + 1, &read_fds_, nullptr, nullptr, nullptr);
for (int i = 0; i <= socket_max_; i++) {
if (!FD_ISSET(i, &read_fds_)) continue;
@@ -451,8 +447,4 @@ size_t TLSSocket::read(gsl::span<std::byte> buffer) {
return total_read;
}
-} /* namespace io */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::io
diff --git a/libminifi/src/utils/ClassUtils.cpp b/libminifi/src/utils/ClassUtils.cpp
index 52914fc49..ecd557054 100644
--- a/libminifi/src/utils/ClassUtils.cpp
+++ b/libminifi/src/utils/ClassUtils.cpp
@@ -23,18 +23,14 @@
#include "utils/StringUtils.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
+namespace org::apache::nifi::minifi::utils {
bool ClassUtils::shortenClassName(const std::string &class_name, std::string &out) {
std::string class_delim = "::";
auto class_split = utils::StringUtils::split(class_name, class_delim);
// support . and ::
if (class_split.size() <= 1) {
- if (class_name.find(".") != std::string::npos) {
+ if (class_name.find('.') != std::string::npos) {
class_delim = ".";
class_split = utils::StringUtils::split(class_name, class_delim);
} else {
@@ -53,9 +49,4 @@ bool ClassUtils::shortenClassName(const std::string &class_name, std::string &ou
return true;
}
-} // 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 d87f11c11..8374fd230 100644
--- a/libminifi/src/utils/RegexUtils.cpp
+++ b/libminifi/src/utils/RegexUtils.cpp
@@ -145,7 +145,7 @@ Regex& Regex::operator=(const Regex& other) {
return *this;
}
-Regex::Regex(Regex&& other)
+Regex::Regex(Regex&& other) noexcept
#ifndef NO_MORE_REGFREEE
: valid_(false),
regex_mode_(REG_EXTENDED)
@@ -154,7 +154,7 @@ Regex::Regex(Regex&& other)
*this = std::move(other);
}
-Regex& Regex::operator=(Regex&& other) {
+Regex& Regex::operator=(Regex&& other) noexcept {
if (this == &other) {
return *this;
}
diff --git a/libminifi/src/utils/StringUtils.cpp b/libminifi/src/utils/StringUtils.cpp
index c7d55b11b..f3a59a081 100644
--- a/libminifi/src/utils/StringUtils.cpp
+++ b/libminifi/src/utils/StringUtils.cpp
@@ -116,7 +116,7 @@ std::vector<std::string> StringUtils::splitAndTrimRemovingEmpty(const std::strin
return result;
}
-bool StringUtils::StringToFloat(std::string input, float &output, FailurePolicy cp /*= RETURN*/) {
+bool StringUtils::StringToFloat(const std::string& input, float &output, FailurePolicy cp /*= RETURN*/) {
try {
output = std::stof(input);
} catch (const std::invalid_argument &ie) {
@@ -156,7 +156,7 @@ std::string StringUtils::replaceEnvironmentVariables(std::string source_string)
beg_seq += 2;
continue;
}
- end_seq = source_string.find("}", beg_seq + 2);
+ end_seq = source_string.find('}', beg_seq + 2);
if (end_seq == std::string::npos) {
break;
}
@@ -215,7 +215,7 @@ std::string StringUtils::replaceMap(std::string source_string, const std::map<st
}
}
- std::sort(replacements.begin(), replacements.end(), [](const std::pair<size_t, std::pair<size_t, std::string>> a,
+ std::sort(replacements.begin(), replacements.end(), [](const std::pair<size_t, std::pair<size_t, std::string>> &a,
const std::pair<size_t, std::pair<size_t, std::string>> &b) {
return a.first > b.first;
});
diff --git a/libminifi/test/archive-tests/ManipulateArchiveTests.cpp b/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
index 65965d16d..b3e2f5d59 100644
--- a/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
+++ b/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
@@ -45,7 +45,7 @@ const char* MODIFY_DEST = "modified";
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) {
+bool run_archive_test(OrderedTestArchive& input_archive, const OrderedTestArchive& output_archive, const PROP_MAP_T& properties, bool check_attributes = true) {
TestController testController;
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::FocusArchiveEntry>();
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::UnfocusArchiveEntry>();
@@ -74,8 +74,8 @@ bool run_archive_test(OrderedTestArchive input_archive, OrderedTestArchive outpu
std::shared_ptr<core::Processor> maprocessor = plan->addProcessor("ManipulateArchive", "testManipulateArchive", core::Relationship("success", "description"), true);
- for (auto kv : properties) {
- plan->setProperty(maprocessor, kv.first, kv.second);
+ for (const auto& [name, value] : properties) {
+ plan->setProperty(maprocessor, name, value);
}
std::shared_ptr<core::Processor> putfile2 = plan->addProcessor("PutFile", "PutFile2", core::Relationship("success", "description"), true);
@@ -96,14 +96,14 @@ bool run_archive_test(OrderedTestArchive input_archive, OrderedTestArchive outpu
return check_archive_contents(output_path, output_archive, check_attributes);
}
-bool run_archive_test(TAE_MAP_T input_map, TAE_MAP_T output_map, PROP_MAP_T properties, bool check_attributes = true) {
+bool run_archive_test(TAE_MAP_T input_map, TAE_MAP_T output_map, const PROP_MAP_T& properties, bool check_attributes = true) {
OrderedTestArchive input_archive;
OrderedTestArchive output_archive;
// An empty vector is treated as "ignore order"
input_archive.order = output_archive.order = FN_VEC_T();
- input_archive.map = input_map;
- output_archive.map = output_map;
+ input_archive.map = std::move(input_map);
+ output_archive.map = std::move(output_map);
return run_archive_test(input_archive, output_archive, properties, check_attributes);
}
diff --git a/libminifi/test/archive-tests/MergeFileTests.cpp b/libminifi/test/archive-tests/MergeFileTests.cpp
index 3318085e5..dc5e3ba64 100644
--- a/libminifi/test/archive-tests/MergeFileTests.cpp
+++ b/libminifi/test/archive-tests/MergeFileTests.cpp
@@ -70,7 +70,7 @@ class FixedBuffer {
explicit FixedBuffer(std::size_t capacity) : capacity_(capacity) {
buf_.reset(new uint8_t[capacity_]);
}
- FixedBuffer(FixedBuffer&& other) : buf_(std::move(other.buf_)), size_(other.size_), capacity_(other.capacity_) {
+ FixedBuffer(FixedBuffer&& other) noexcept : buf_(std::move(other.buf_)), size_(other.size_), capacity_(other.capacity_) {
other.size_ = 0;
other.capacity_ = 0;
}
diff --git a/libminifi/test/archive-tests/util/ArchiveTests.cpp b/libminifi/test/archive-tests/util/ArchiveTests.cpp
index fac83b0b1..ab678dd87 100644
--- a/libminifi/test/archive-tests/util/ArchiveTests.cpp
+++ b/libminifi/test/archive-tests/util/ArchiveTests.cpp
@@ -68,7 +68,7 @@ OrderedTestArchive build_ordered_test_archive(int NUM_FILES, const char** FILE_N
return ret;
}
-void build_test_archive(std::string path, TAE_MAP_T entries, FN_VEC_T order) {
+void build_test_archive(const std::string& path, const TAE_MAP_T& entries, FN_VEC_T order) {
std::cout << "Creating " << path << std::endl;
archive * test_archive = archive_write_new();
@@ -81,7 +81,7 @@ void build_test_archive(std::string path, TAE_MAP_T entries, FN_VEC_T order) {
order.push_back(kvp.first);
}
- for (std::string name : order) {
+ for (const std::string& name : order) {
TestArchiveEntry test_entry = entries.at(name);
std::cout << "Adding entry: " << name << std::endl;
@@ -104,11 +104,11 @@ void build_test_archive(std::string path, TAE_MAP_T entries, FN_VEC_T order) {
archive_write_close(test_archive);
}
-void build_test_archive(std::string path, OrderedTestArchive ordered_archive) {
+void build_test_archive(const std::string& path, OrderedTestArchive& ordered_archive) {
build_test_archive(path, ordered_archive.map, ordered_archive.order);
}
-bool check_archive_contents(std::string path, TAE_MAP_T entries, bool check_attributes, FN_VEC_T order) {
+bool check_archive_contents(const std::string& path, const TAE_MAP_T& entries, bool check_attributes, const FN_VEC_T& order) {
FN_VEC_T read_names;
FN_VEC_T extra_names;
bool ok = true;
@@ -133,7 +133,7 @@ bool check_archive_contents(std::string path, TAE_MAP_T entries, bool check_attr
} else {
read_names.push_back(name);
TestArchiveEntry test_entry = it->second;
- size_t size = gsl::narrow<size_t>(archive_entry_size(entry));
+ auto size = gsl::narrow<size_t>(archive_entry_size(entry));
std::cout << "Checking archive entry: " << name << std::endl;
@@ -179,7 +179,7 @@ bool check_archive_contents(std::string path, TAE_MAP_T entries, bool check_attr
if (!extra_names.empty()) {
ok = false;
std::cout << "Extra files found: ";
- for (std::string filename : extra_names)
+ for (const std::string& filename : extra_names)
std::cout << filename << " ";
std::cout << std::endl;
}
@@ -195,7 +195,7 @@ bool check_archive_contents(std::string path, TAE_MAP_T entries, bool check_attr
} else {
std::set<std::string> read_names_set(read_names.begin(), read_names.end());
std::set<std::string> test_file_entries_set;
- std::transform(entries.begin(), entries.end(), std::inserter(test_file_entries_set, test_file_entries_set.end()), [](std::pair<std::string, TestArchiveEntry> p) {return p.first;});
+ std::transform(entries.begin(), entries.end(), std::inserter(test_file_entries_set, test_file_entries_set.end()), [](const std::pair<std::string, TestArchiveEntry>& p) {return p.first;});
REQUIRE(read_names_set == test_file_entries_set);
}
@@ -203,6 +203,6 @@ bool check_archive_contents(std::string path, TAE_MAP_T entries, bool check_attr
return ok;
}
-bool check_archive_contents(std::string path, OrderedTestArchive archive, bool check_attributes) {
+bool check_archive_contents(const std::string& path, const OrderedTestArchive& archive, bool check_attributes) {
return check_archive_contents(path, archive.map, check_attributes, archive.order);
}
diff --git a/libminifi/test/rocksdb-tests/RocksDBTests.cpp b/libminifi/test/rocksdb-tests/RocksDBTests.cpp
index 6420a04de..6e6e93514 100644
--- a/libminifi/test/rocksdb-tests/RocksDBTests.cpp
+++ b/libminifi/test/rocksdb-tests/RocksDBTests.cpp
@@ -48,6 +48,7 @@ struct RocksDBTest : TestController {
rocksdb::DB* db_ptr = nullptr;
std::vector<rocksdb::ColumnFamilyHandle*> cf_handle_ptrs;
std::vector<rocksdb::ColumnFamilyDescriptor> cf_descs;
+ cf_descs.reserve(cf_names.size());
for (auto& cf_name : cf_names) {
cf_descs.emplace_back(cf_name, rocksdb::ColumnFamilyOptions{});
}
diff --git a/libminifi/test/sql-tests/mocks/MockConnectors.cpp b/libminifi/test/sql-tests/mocks/MockConnectors.cpp
index 1e4d7570c..6854a97f3 100644
--- a/libminifi/test/sql-tests/mocks/MockConnectors.cpp
+++ b/libminifi/test/sql-tests/mocks/MockConnectors.cpp
@@ -146,6 +146,7 @@ std::unique_ptr<MockRowset> MockRowset::select(const std::vector<std::string>& c
rowset = std::make_unique<MockRowset>(column_names_, column_types_);
} else {
std::vector<DataType> col_types;
+ col_types.reserve(cols.size());
for (const auto& col : cols) {
col_types.push_back(column_types_.at(getColumnIndex(col)));
}
@@ -156,6 +157,7 @@ std::unique_ptr<MockRowset> MockRowset::select(const std::vector<std::string>& c
for (const auto& row : rows_) {
if (condition(row)) {
std::vector<std::string> values;
+ values.reserve(used_cols.size());
for (const auto& col : used_cols) {
values.push_back(row.getValue(col));
}
diff --git a/libminifi/test/unit/BackTraceTests.cpp b/libminifi/test/unit/BackTraceTests.cpp
index 27fbc5401..4366f7a38 100644
--- a/libminifi/test/unit/BackTraceTests.cpp
+++ b/libminifi/test/unit/BackTraceTests.cpp
@@ -35,9 +35,9 @@ class WorkerNumberExecutions : public utils::AfterExecute<int> {
: tasks(tasks) {
}
- explicit WorkerNumberExecutions(WorkerNumberExecutions && other)
- : runs(std::move(other.runs)),
- tasks(std::move(other.tasks)) {
+ explicit WorkerNumberExecutions(WorkerNumberExecutions && other) noexcept
+ : runs(other.runs),
+ tasks(other.tasks) {
}
bool isFinished(const int &result) override {
diff --git a/libminifi/test/unit/ExpectedTest.cpp b/libminifi/test/unit/ExpectedTest.cpp
index 0bff815e4..26ac4dbe7 100644
--- a/libminifi/test/unit/ExpectedTest.cpp
+++ b/libminifi/test/unit/ExpectedTest.cpp
@@ -52,7 +52,7 @@ TEST_CASE("expected map", "[expected][map]") {
{
const nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::map(mul2);
+ auto ret = std::move(e) | utils::map(mul2); // NOLINT(performance-move-const-arg)
REQUIRE(ret);
REQUIRE(*ret == 42);
}
@@ -80,7 +80,7 @@ TEST_CASE("expected map", "[expected][map]") {
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::map(mul2);
+ auto ret = std::move(e) | utils::map(mul2); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
@@ -111,7 +111,7 @@ TEST_CASE("expected map", "[expected][map]") {
{
const nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::map(ret_void);
+ auto ret = std::move(e) | utils::map(ret_void); // NOLINT(performance-move-const-arg)
REQUIRE(ret);
STATIC_REQUIRE(
(std::is_same<decltype(ret), nonstd::expected<void, int>>::value));
@@ -143,7 +143,7 @@ TEST_CASE("expected map", "[expected][map]") {
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::map(ret_void);
+ auto ret = std::move(e) | utils::map(ret_void); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
STATIC_REQUIRE(
(std::is_same<decltype(ret), nonstd::expected<void, int>>::value));
@@ -186,7 +186,7 @@ TEST_CASE("expected flatMap", "[expected][flatMap]") {
{
const nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::flatMap(succeed);
+ auto ret = std::move(e) | utils::flatMap(succeed); // NOLINT(performance-move-const-arg)
REQUIRE(ret);
REQUIRE(*ret == 42);
}
@@ -214,7 +214,7 @@ TEST_CASE("expected flatMap", "[expected][flatMap]") {
{
const nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::flatMap(fail);
+ auto ret = std::move(e) | utils::flatMap(fail); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
REQUIRE(ret.error() == 17);
}
@@ -242,7 +242,7 @@ TEST_CASE("expected flatMap", "[expected][flatMap]") {
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::flatMap(succeed);
+ auto ret = std::move(e) | utils::flatMap(succeed); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
@@ -270,7 +270,7 @@ TEST_CASE("expected flatMap", "[expected][flatMap]") {
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::flatMap(fail);
+ auto ret = std::move(e) | utils::flatMap(fail); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
@@ -321,7 +321,7 @@ TEST_CASE("expected orElse", "[expected][orElse]") {
{
const nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::orElse(succeed);
+ auto ret = std::move(e) | utils::orElse(succeed); // NOLINT(performance-move-const-arg)
REQUIRE(ret);
REQUIRE(*ret == 21);
}
@@ -359,7 +359,7 @@ TEST_CASE("expected orElse", "[expected][orElse]") {
{
const nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::orElse(fail);
+ auto ret = std::move(e) | utils::orElse(fail); // NOLINT(performance-move-const-arg)
REQUIRE(ret);
REQUIRE(*ret == 21);
}
@@ -396,7 +396,7 @@ TEST_CASE("expected orElse", "[expected][orElse]") {
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::orElse(succeed);
+ auto ret = std::move(e) | utils::orElse(succeed); // NOLINT(performance-move-const-arg)
REQUIRE(ret);
REQUIRE(*ret == 42);
}
@@ -461,14 +461,14 @@ TEST_CASE("expected orElse", "[expected][orElse]") {
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::orElse(fail);
+ auto ret = std::move(e) | utils::orElse(fail); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
REQUIRE(ret.error() == 17);
}
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::orElse(failvoid);
+ auto ret = std::move(e) | utils::orElse(failvoid); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
@@ -480,7 +480,7 @@ TEST_CASE("expected valueOrElse", "[expected][valueOrElse]") {
REQUIRE(42 == (ex | utils::valueOrElse([] { return 42; })));
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 std::exception(); }), std::exception);
+ REQUIRE_THROWS_AS(ex | utils::valueOrElse([](std::string){ throw std::exception(); }), std::exception); // NOLINT(performance-unnecessary-value-param)
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/IdTests.cpp b/libminifi/test/unit/IdTests.cpp
index a24b8661d..b993f7bcd 100644
--- a/libminifi/test/unit/IdTests.cpp
+++ b/libminifi/test/unit/IdTests.cpp
@@ -77,7 +77,7 @@ TEST_CASE("Test Generate Move", "[id]") {
auto generated = generator->generate();
auto str = generated.to_string();
- utils::Identifier moved = std::move(generated);
+ utils::Identifier moved = std::move(generated); // NOLINT(performance-move-const-arg)
auto str2 = moved.to_string();
REQUIRE(str == str2);
}
diff --git a/libminifi/test/unit/ThreadPoolTests.cpp b/libminifi/test/unit/ThreadPoolTests.cpp
index eec7c9ced..ae05cd56d 100644
--- a/libminifi/test/unit/ThreadPoolTests.cpp
+++ b/libminifi/test/unit/ThreadPoolTests.cpp
@@ -33,9 +33,9 @@ class WorkerNumberExecutions : public utils::AfterExecute<int> {
: tasks(tasks) {
}
- explicit WorkerNumberExecutions(WorkerNumberExecutions && other)
- : runs(std::move(other.runs)),
- tasks(std::move(other.tasks)) {
+ explicit WorkerNumberExecutions(WorkerNumberExecutions && other) noexcept
+ : runs(other.runs),
+ tasks(other.tasks) {
}
bool isFinished(const int &result) override {