You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by fg...@apache.org on 2022/07/26 12:44:52 UTC
[nifi-minifi-cpp] 01/04: MINIFICPP-1860 Fix clang-tidy readability issues
This is an automated email from the ASF dual-hosted git repository.
fgerlits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 70714a1505a5d4343514e2c23d8c818a56de32ce
Author: Gabor Gyimesi <ga...@gmail.com>
AuthorDate: Mon Jun 20 14:00:47 2022 +0200
MINIFICPP-1860 Fix clang-tidy readability issues
Signed-off-by: Ferenc Gerlits <fg...@gmail.com>
This closes #1354
---
.clang-tidy | 34 +++++++++++++-
controller/MiNiFiController.cpp | 4 +-
encrypt-config/ArgParser.cpp | 17 ++-----
encrypt-config/ArgParser.h | 6 +--
encrypt-config/EncryptConfig.h | 2 +-
extensions/aws/processors/PutS3Object.cpp | 4 +-
extensions/aws/processors/PutS3Object.h | 2 +-
extensions/aws/processors/S3Processor.cpp | 2 +-
extensions/aws/s3/S3Wrapper.h | 6 +--
extensions/civetweb/processors/ListenHTTP.cpp | 4 +-
extensions/civetweb/processors/ListenHTTP.h | 10 ++---
extensions/civetweb/protocols/RESTReceiver.cpp | 4 +-
extensions/civetweb/protocols/RESTReceiver.h | 6 +--
extensions/coap/nanofi/coap_functions.c | 9 ++--
extensions/coap/protocols/CoapC2Protocol.cpp | 13 ++++--
extensions/coap/protocols/CoapC2Protocol.h | 4 +-
extensions/coap/tests/CoapC2VerifyHeartbeat.cpp | 9 ++--
extensions/expression-language/Expression.cpp | 24 +++++-----
.../integration/UpdateAttributeIntegrationTest.cpp | 4 +-
extensions/gcp/processors/FetchGCSObject.h | 2 +-
extensions/gcp/processors/ListGCSBucket.h | 2 +-
extensions/gcp/processors/PutGCSObject.cpp | 2 +-
extensions/gcp/processors/PutGCSObject.h | 2 +-
extensions/http-curl/client/HTTPClient.cpp | 24 ++++------
extensions/http-curl/client/HTTPClient.h | 2 +-
extensions/http-curl/client/HTTPStream.h | 2 +-
extensions/http-curl/processors/InvokeHTTP.h | 2 +-
extensions/http-curl/protocols/AgentPrinter.h | 2 +-
extensions/http-curl/protocols/RESTSender.cpp | 3 +-
extensions/http-curl/sitetosite/HTTPProtocol.h | 2 +-
.../http-curl/tests/C2MultipleCommandsTest.cpp | 2 +-
extensions/http-curl/tests/C2NullConfiguration.cpp | 4 +-
extensions/http-curl/tests/C2PauseResumeTest.cpp | 4 +-
.../C2VerifyResourceConsumptionInHeartbeat.cpp | 4 +-
.../http-curl/tests/C2VerifyServeResults.cpp | 4 +-
.../http-curl/tests/unit/HTTPClientTests.cpp | 2 +-
extensions/jni/ExecuteJavaProcessor.cpp | 17 ++-----
extensions/jni/ExecuteJavaProcessor.h | 2 +-
extensions/jni/jvm/JavaControllerService.cpp | 4 +-
extensions/libarchive/ArchiveMetadata.h | 4 +-
extensions/libarchive/BinFiles.h | 4 +-
extensions/libarchive/MergeContent.cpp | 9 ++--
extensions/libarchive/MergeContent.h | 8 ++--
extensions/librdkafka/ConsumeKafka.cpp | 8 ++--
extensions/librdkafka/ConsumeKafka.h | 2 +-
extensions/librdkafka/KafkaConnection.cpp | 2 +-
extensions/librdkafka/PublishKafka.cpp | 3 +-
extensions/mqtt/processors/ConsumeMQTT.cpp | 4 +-
extensions/mqtt/processors/ConvertBase.cpp | 2 +-
extensions/mqtt/processors/ConvertUpdate.cpp | 3 +-
extensions/mqtt/protocol/MQTTC2Protocol.cpp | 3 +-
extensions/opc/src/fetchopc.cpp | 2 +-
extensions/opc/src/opc.cpp | 2 +-
extensions/opencv/MotionDetector.cpp | 15 ++-----
.../SourceInitiatedSubscriptionListener.cpp | 6 ---
.../SourceInitiatedSubscriptionListener.h | 6 +--
extensions/pcap/CapturePacket.cpp | 20 +++------
extensions/rocksdb-repos/FlowFileRepository.h | 2 +-
extensions/script/lua/LuaScriptEngine.cpp | 15 ++-----
.../script/python/ExecutePythonProcessor.cpp | 21 +++------
extensions/sftp/client/SFTPClient.cpp | 7 +--
extensions/sftp/client/SFTPClient.h | 2 +-
extensions/sftp/processors/FetchSFTP.cpp | 8 ----
extensions/sftp/processors/ListSFTP.cpp | 13 +-----
extensions/sftp/processors/PutSFTP.cpp | 7 ---
extensions/sftp/processors/SFTPProcessorBase.cpp | 6 ---
extensions/sftp/tests/ListSFTPTests.cpp | 5 ++-
extensions/sftp/tests/PutSFTPTests.cpp | 2 +-
extensions/sftp/tests/tools/SFTPTestServer.cpp | 2 +-
extensions/sftp/tests/tools/SFTPTestServer.h | 2 +-
extensions/splunk/QuerySplunkIndexingStatus.cpp | 4 +-
extensions/splunk/SplunkHECProcessor.cpp | 2 +-
extensions/splunk/SplunkHECProcessor.h | 2 +-
extensions/sql/data/JSONSQLWriter.h | 2 +-
extensions/sql/data/SQLRowsetProcessor.h | 2 +-
extensions/sql/processors/QueryDatabaseTable.cpp | 6 +--
extensions/sql/services/DatabaseService.cpp | 1 -
...UnorderedMapPersistableKeyValueStoreService.cpp | 5 +--
.../processors/AttributesToJSON.cpp | 14 ++----
.../processors/AttributesToJSON.h | 2 +-
.../processors/DefragmentText.cpp | 10 +++--
.../processors/DefragmentText.h | 8 ++--
.../standard-processors/processors/ExtractText.cpp | 3 +-
.../standard-processors/processors/FetchFile.cpp | 6 +--
.../standard-processors/processors/FetchFile.h | 2 +-
.../standard-processors/processors/PutFile.cpp | 18 +++-----
.../standard-processors/processors/PutFile.h | 2 +-
.../standard-processors/processors/TailFile.cpp | 34 +++++++-------
.../standard-processors/processors/TailFile.h | 8 ++--
.../tests/integration/SecureSocketGetTCPTest.cpp | 3 +-
.../TLSClientSocketSupportedProtocolsTest.cpp | 9 ++--
.../tests/unit/AttributesToJSONTests.cpp | 4 +-
.../tests/unit/GenerateFlowFileTests.cpp | 4 +-
.../tests/unit/GetFileTests.cpp | 16 ++++---
.../tests/unit/ProcessorTests.cpp | 8 ++--
.../tests/unit/RetryFlowFileTests.cpp | 6 +--
.../tests/unit/RouteTextTests.cpp | 4 +-
.../tests/unit/TailFileTests.cpp | 11 +++--
extensions/systemd/ConsumeJournald.cpp | 10 +----
extensions/usb-camera/GetUSBCamera.cpp | 14 ++----
libminifi/include/FlowControlProtocol.h | 6 +--
libminifi/include/ResourceClaim.h | 2 +-
libminifi/include/c2/C2Agent.h | 4 +-
libminifi/include/core/FlowConfiguration.h | 6 +--
libminifi/include/core/ProcessSession.h | 2 +-
libminifi/include/core/logging/Logger.h | 2 +-
.../reporting/SiteToSiteProvenanceReportingTask.h | 2 +-
.../core/repository/VolatileContentRepository.h | 2 +-
libminifi/include/core/yaml/YamlConfiguration.h | 18 ++++----
libminifi/include/io/BufferStream.h | 2 +-
libminifi/include/io/ZlibStream.h | 2 +-
libminifi/include/provenance/Provenance.h | 5 +--
libminifi/include/utils/StringUtils.h | 6 +--
libminifi/include/utils/file/FilePattern.h | 2 +-
libminifi/src/FlowControlProtocol.cpp | 12 ++---
libminifi/src/RemoteProcessorGroupPort.cpp | 24 ++++------
libminifi/src/ResourceClaim.cpp | 16 +++----
libminifi/src/c2/C2Agent.cpp | 6 ++-
libminifi/src/c2/ControllerSocketProtocol.cpp | 5 ++-
.../src/controllers/NetworkPrioritizerService.cpp | 8 +---
libminifi/src/controllers/SSLContextService.cpp | 2 +-
.../controllers/UpdatePolicyControllerService.cpp | 3 +-
libminifi/src/core/Connectable.cpp | 26 ++---------
libminifi/src/core/FlowConfiguration.cpp | 19 +++-----
libminifi/src/core/Processor.cpp | 39 +++++-----------
libminifi/src/core/ProcessorNode.cpp | 15 ++-----
libminifi/src/core/logging/Logger.cpp | 21 +++------
libminifi/src/core/logging/LoggerConfiguration.cpp | 9 ++--
.../core/repository/VolatileContentRepository.cpp | 19 ++------
libminifi/src/core/yaml/YamlConfiguration.cpp | 52 +++++++++-------------
libminifi/src/core/yaml/YamlConnectionParser.cpp | 19 ++------
libminifi/src/io/ClientSocket.cpp | 1 -
libminifi/src/provenance/Provenance.cpp | 14 ++----
.../src/serialization/FlowFileV3Serializer.cpp | 12 +----
libminifi/src/sitetosite/Peer.cpp | 6 +--
libminifi/src/sitetosite/SiteToSiteClient.cpp | 24 +++-------
libminifi/src/utils/Id.cpp | 3 +-
libminifi/src/utils/StringUtils.cpp | 9 ++--
libminifi/src/utils/file/FileUtils.cpp | 16 ++-----
libminifi/src/utils/net/Socket.cpp | 4 +-
libminifi/test/TestBase.cpp | 4 +-
libminifi/test/TestBase.h | 8 ++--
.../test/archive-tests/CompressContentTests.cpp | 12 ++---
.../test/archive-tests/ManipulateArchiveTests.cpp | 3 +-
libminifi/test/aws-tests/PutS3ObjectTests.cpp | 4 +-
.../integration/OnScheduleErrorHandlingTests.cpp | 3 +-
libminifi/test/pcap-tests/PcapTest.cpp | 4 +-
libminifi/test/sensors-tests/SensorTests.cpp | 4 +-
.../test/sql-tests/SQLColumnIdentifierTests.cpp | 2 +-
libminifi/test/sql-tests/mocks/MockConnectors.h | 2 +-
libminifi/test/unit/BackTraceTests.cpp | 8 +---
libminifi/test/unit/ClassUtilsTests.cpp | 3 +-
libminifi/test/unit/FileUtilsTests.cpp | 48 +++++++++++---------
libminifi/test/unit/RegexUtilsTests.cpp | 6 +--
libminifi/test/unit/ThreadPoolTests.cpp | 8 +---
main/AgentDocs.cpp | 2 +-
main/AgentDocs.h | 2 +-
main/MainHelper.cpp | 8 ++--
main/MiNiFiMain.cpp | 3 +-
159 files changed, 514 insertions(+), 732 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index 39f9721d6..224d7c595 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -58,5 +58,37 @@ Checks: >
modernize-use-override,
modernize-use-transparent-functors,
modernize-use-uncaught-exceptions,
- modernize-use-using
+ modernize-use-using,
+ readability-avoid-const-params-in-decls,
+ readability-const-return-type,
+ readability-container-contains,
+ readability-container-data-pointer,
+ readability-container-size-empty,
+ readability-convert-member-functions-to-static,
+ readability-delete-null-pointer,
+ readability-duplicate-include,
+ readability-function-size,
+ readability-identifier-naming,
+ readability-inconsistent-declaration-parameter-name,
+ readability-isolate-declaration,
+ readability-make-member-function-const,
+ readability-misleading-indentation,
+ readability-misplaced-array-index,
+ readability-non-const-parameter,
+ readability-redundant-access-specifiers,
+ readability-redundant-control-flow,
+ readability-redundant-declaration,
+ readability-redundant-function-ptr-dereference,
+ readability-redundant-member-init,
+ readability-redundant-preprocessor,
+ readability-redundant-smartptr-get,
+ readability-redundant-string-cstr,
+ readability-redundant-string-init,
+ readability-simplify-boolean-expr,
+ readability-simplify-subscript-expr,
+ readability-static-definition-in-anonymous-namespace,
+ readability-string-compare,
+ readability-uniqueptr-delete-release,
+ readability-uppercase-literal-suffix,
+ readability-use-anyofallof
FormatStyle: 'file'
diff --git a/controller/MiNiFiController.cpp b/controller/MiNiFiController.cpp
index ae0303b50..6f55e9b45 100644
--- a/controller/MiNiFiController.cpp
+++ b/controller/MiNiFiController.cpp
@@ -82,7 +82,9 @@ int main(int argc, char **argv) {
auto stream_factory_ = minifi::io::StreamFactory::getInstance(configuration);
- std::string host = "localhost", portStr, caCert;
+ std::string host = "localhost";
+ std::string portStr;
+ std::string caCert;
int port = -1;
cxxopts::Options options("MiNiFiController", "MiNiFi local agent controller");
diff --git a/encrypt-config/ArgParser.cpp b/encrypt-config/ArgParser.cpp
index f02e5b238..5a1a2839d 100644
--- a/encrypt-config/ArgParser.cpp
+++ b/encrypt-config/ArgParser.cpp
@@ -25,11 +25,7 @@
#include "utils/CollectionUtils.h"
#include "CommandException.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace encrypt_config {
+namespace org::apache::nifi::minifi::encrypt_config {
const std::vector<Argument> Arguments::registered_args_{
{std::set<std::string>{"--minifi-home", "-m"},
@@ -149,7 +145,7 @@ Arguments Arguments::parse(int argc, char* argv[]) {
std::optional<Flag> Arguments::getFlag(const std::string &name) {
for (const auto& flag : registered_flags_) {
- if (flag.names.count(name) > 0) {
+ if (flag.names.contains(name)) {
return flag;
}
}
@@ -158,16 +154,11 @@ std::optional<Flag> Arguments::getFlag(const std::string &name) {
std::optional<Argument> Arguments::getArg(const std::string &key) {
for (const auto& arg : registered_args_) {
- if (arg.names.count(key) > 0) {
+ if (arg.names.contains(key)) {
return arg;
}
}
return {};
}
-} // namespace encrypt_config
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
-
+} // namespace org::apache::nifi::minifi::encrypt_config
diff --git a/encrypt-config/ArgParser.h b/encrypt-config/ArgParser.h
index a25c32872..fda3570d8 100644
--- a/encrypt-config/ArgParser.h
+++ b/encrypt-config/ArgParser.h
@@ -46,10 +46,10 @@ class Arguments {
void set(const std::string& key, const std::string& value);
- void set(const std::string& bool_key);
+ void set(const std::string& flag);
static std::optional<Argument> getArg(const std::string& key);
- static std::optional<Flag> getFlag(const std::string& flag);
+ static std::optional<Flag> getFlag(const std::string& name);
public:
static Arguments parse(int argc, char* argv[]);
@@ -61,7 +61,7 @@ class Arguments {
[[nodiscard]] bool isSet(const std::string& flag) const;
private:
- [[nodiscard]] std::optional<std::string> get(const Argument& key) const;
+ [[nodiscard]] std::optional<std::string> get(const Argument& arg) const;
std::map<std::string, std::string> args_;
std::set<std::string> flags_;
diff --git a/encrypt-config/EncryptConfig.h b/encrypt-config/EncryptConfig.h
index f17878e26..c89bed16c 100644
--- a/encrypt-config/EncryptConfig.h
+++ b/encrypt-config/EncryptConfig.h
@@ -46,7 +46,7 @@ class EncryptConfig {
std::string hexDecodeAndValidateKey(const std::string& key, const std::string& key_name) const;
void writeEncryptionKeyToBootstrapFile(const utils::crypto::Bytes& encryption_key) const;
- void encryptSensitiveProperties(const EncryptionKeys& encryption_key) const;
+ void encryptSensitiveProperties(const EncryptionKeys& keys) const;
const std::string minifi_home_;
EncryptionKeys keys_;
diff --git a/extensions/aws/processors/PutS3Object.cpp b/extensions/aws/processors/PutS3Object.cpp
index 6fe350d2a..b312e9b53 100644
--- a/extensions/aws/processors/PutS3Object.cpp
+++ b/extensions/aws/processors/PutS3Object.cpp
@@ -41,7 +41,7 @@ void PutS3Object::fillUserMetadata(const std::shared_ptr<core::ProcessContext> &
const auto &dynamic_prop_keys = context->getDynamicPropertyKeys();
bool first_property = true;
for (const auto &prop_key : dynamic_prop_keys) {
- std::string prop_value = "";
+ std::string prop_value;
if (context->getDynamicProperty(prop_key, prop_value) && !prop_value.empty()) {
logger_->log_debug("PutS3Object: DynamicProperty: [%s] -> [%s]", prop_key, prop_value);
user_metadata_map_.emplace(prop_key, prop_value);
@@ -76,7 +76,7 @@ void PutS3Object::onSchedule(const std::shared_ptr<core::ProcessContext> &contex
fillUserMetadata(context);
}
-std::string PutS3Object::parseAccessControlList(const std::string &comma_separated_list) const {
+std::string PutS3Object::parseAccessControlList(const std::string &comma_separated_list) {
auto users = minifi::utils::StringUtils::split(comma_separated_list, ",");
for (auto& user : users) {
auto trimmed_user = minifi::utils::StringUtils::trim(user);
diff --git a/extensions/aws/processors/PutS3Object.h b/extensions/aws/processors/PutS3Object.h
index ee8b89589..13f0cbd60 100644
--- a/extensions/aws/processors/PutS3Object.h
+++ b/extensions/aws/processors/PutS3Object.h
@@ -141,7 +141,7 @@ class PutS3Object : public S3Processor {
}
void fillUserMetadata(const std::shared_ptr<core::ProcessContext> &context);
- std::string parseAccessControlList(const std::string &comma_separated_list) const;
+ static std::string parseAccessControlList(const std::string &comma_separated_list);
bool setCannedAcl(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::FlowFile> &flow_file, aws::s3::PutObjectRequestParameters &put_s3_request_params) const;
bool setAccessControl(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::FlowFile> &flow_file, aws::s3::PutObjectRequestParameters &put_s3_request_params) const;
void setAttributes(
diff --git a/extensions/aws/processors/S3Processor.cpp b/extensions/aws/processors/S3Processor.cpp
index e1b9813ac..34cd77bad 100644
--- a/extensions/aws/processors/S3Processor.cpp
+++ b/extensions/aws/processors/S3Processor.cpp
@@ -113,7 +113,7 @@ void S3Processor::onSchedule(const std::shared_ptr<core::ProcessContext>& contex
throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Bucket property missing or invalid");
}
- if (!context->getProperty(Region.getName(), client_config_->region) || client_config_->region.empty() || REGIONS.count(client_config_->region) == 0) {
+ if (!context->getProperty(Region.getName(), client_config_->region) || client_config_->region.empty() || !REGIONS.contains(client_config_->region)) {
throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Region property missing or invalid");
}
logger_->log_debug("S3Processor: Region [%s]", client_config_->region);
diff --git a/extensions/aws/s3/S3Wrapper.h b/extensions/aws/s3/S3Wrapper.h
index 3c547b11c..6e32ec428 100644
--- a/extensions/aws/s3/S3Wrapper.h
+++ b/extensions/aws/s3/S3Wrapper.h
@@ -205,9 +205,9 @@ class S3Wrapper {
S3Wrapper();
explicit S3Wrapper(std::unique_ptr<S3RequestSender>&& request_sender);
- std::optional<PutObjectResult> putObject(const PutObjectRequestParameters& options, std::shared_ptr<Aws::IOStream> data_stream);
- bool deleteObject(const DeleteObjectRequestParameters& options);
- std::optional<GetObjectResult> getObject(const GetObjectRequestParameters& get_object_params, io::BaseStream& fetched_body);
+ std::optional<PutObjectResult> putObject(const PutObjectRequestParameters& put_object_params, std::shared_ptr<Aws::IOStream> data_stream);
+ bool deleteObject(const DeleteObjectRequestParameters& params);
+ std::optional<GetObjectResult> getObject(const GetObjectRequestParameters& get_object_params, io::BaseStream& out_body);
std::optional<std::vector<ListedObjectAttributes>> listBucket(const ListRequestParameters& params);
std::optional<std::map<std::string, std::string>> getObjectTags(const GetObjectTagsParameters& params);
std::optional<HeadObjectResult> headObject(const HeadObjectRequestParameters& head_object_params);
diff --git a/extensions/civetweb/processors/ListenHTTP.cpp b/extensions/civetweb/processors/ListenHTTP.cpp
index a9d554570..31d146852 100644
--- a/extensions/civetweb/processors/ListenHTTP.cpp
+++ b/extensions/civetweb/processors/ListenHTTP.cpp
@@ -131,7 +131,7 @@ void ListenHTTP::onSchedule(core::ProcessContext *context, core::ProcessSessionF
}
if (context->getProperty(SSLVerifyPeer.getName(), sslVerifyPeer)) {
- if (sslVerifyPeer.empty() || sslVerifyPeer.compare("no") == 0) {
+ if (sslVerifyPeer.empty() || sslVerifyPeer == "no") {
logger_->log_debug("ListenHTTP will not verify peers");
} else {
logger_->log_debug("ListenHTTP will verify peers");
@@ -432,7 +432,7 @@ void ListenHTTP::Handler::writeBody(mg_connection *conn, const mg_request_info *
std::lock_guard<std::mutex> guard(uri_map_mutex_);
std::string req_uri = request_uri_str.substr(base_uri_.size() + 1);
- if (response_uri_map_.count(req_uri)) {
+ if (response_uri_map_.contains(req_uri)) {
response = response_uri_map_[req_uri];
}
}
diff --git a/extensions/civetweb/processors/ListenHTTP.h b/extensions/civetweb/processors/ListenHTTP.h
index 7bb82af5c..a25ec4c73 100644
--- a/extensions/civetweb/processors/ListenHTTP.h
+++ b/extensions/civetweb/processors/ListenHTTP.h
@@ -109,8 +109,8 @@ class ListenHTTP : public core::Processor {
public:
Handler(std::string base_uri,
core::ProcessContext *context,
- std::string &&authDNPattern,
- std::string &&headersAsAttributesPattern);
+ std::string &&auth_dn_regex,
+ std::string &&header_as_attrs_regex);
bool handlePost(CivetServer *server, struct mg_connection *conn) override;
bool handleGet(CivetServer *server, struct mg_connection *conn) override;
bool handleHead(CivetServer *server, struct mg_connection *conn) override;
@@ -124,12 +124,12 @@ class ListenHTTP : public core::Processor {
bool dequeueRequest(FlowFileBufferPair &flow_file_buffer_pair);
private:
- void sendHttp500(struct mg_connection *conn);
- void sendHttp503(struct mg_connection *conn);
+ static void sendHttp500(struct mg_connection *conn);
+ static void sendHttp503(struct mg_connection *conn);
bool authRequest(mg_connection *conn, const mg_request_info *req_info) const;
void setHeaderAttributes(const mg_request_info *req_info, const std::shared_ptr<core::FlowFile> &flow_file) const;
void writeBody(mg_connection *conn, const mg_request_info *req_info, bool include_payload = true);
- std::unique_ptr<io::BufferStream> createContentBuffer(struct mg_connection *conn, const struct mg_request_info *req_info);
+ static std::unique_ptr<io::BufferStream> createContentBuffer(struct mg_connection *conn, const struct mg_request_info *req_info);
void enqueueRequest(mg_connection *conn, const mg_request_info *req_info, std::unique_ptr<io::BufferStream>);
std::string base_uri_;
diff --git a/extensions/civetweb/protocols/RESTReceiver.cpp b/extensions/civetweb/protocols/RESTReceiver.cpp
index c40504479..0fce43d4a 100644
--- a/extensions/civetweb/protocols/RESTReceiver.cpp
+++ b/extensions/civetweb/protocols/RESTReceiver.cpp
@@ -46,7 +46,9 @@ void RESTReceiver::initialize(core::controller::ControllerServiceProvider* contr
HeartbeatReporter::initialize(controller, updateSink, configure);
logger_->log_trace("Initializing rest receiver");
if (nullptr != configuration_) {
- std::string listeningPort, rootUri = "/", caCert;
+ std::string listeningPort;
+ std::string rootUri = "/";
+ std::string caCert;
configuration_->get(Configuration::nifi_c2_rest_listener_port, "c2.rest.listener.port", listeningPort);
configuration_->get(Configuration::nifi_c2_rest_listener_cacert, "c2.rest.listener.cacert", caCert);
if (!listeningPort.empty() && !rootUri.empty()) {
diff --git a/extensions/civetweb/protocols/RESTReceiver.h b/extensions/civetweb/protocols/RESTReceiver.h
index b62ac19ed..f8c326e77 100644
--- a/extensions/civetweb/protocols/RESTReceiver.h
+++ b/extensions/civetweb/protocols/RESTReceiver.h
@@ -45,7 +45,7 @@ class RESTReceiver : public RESTProtocol, public HeartbeatReporter {
void initialize(core::controller::ControllerServiceProvider* controller, state::StateMonitor* updateSink,
const std::shared_ptr<Configure> &configure) override;
- int16_t heartbeat(const C2Payload &heartbeat) override;
+ int16_t heartbeat(const C2Payload &payload) override;
protected:
class ListeningProtocol : public CivetHandler {
@@ -77,9 +77,9 @@ class RESTReceiver : public RESTProtocol, public HeartbeatReporter {
std::string resp_;
};
- std::unique_ptr<CivetServer> start_webserver(const std::string &port, std::string &rooturi, CivetHandler *handler, std::string &ca_cert);
+ static std::unique_ptr<CivetServer> start_webserver(const std::string &port, std::string &rooturi, CivetHandler *handler, std::string &ca_cert);
- std::unique_ptr<CivetServer> start_webserver(const std::string &port, std::string &rooturi, CivetHandler *handler);
+ static std::unique_ptr<CivetServer> start_webserver(const std::string &port, std::string &rooturi, CivetHandler *handler);
std::unique_ptr<CivetServer> listener;
std::unique_ptr<ListeningProtocol> handler;
diff --git a/extensions/coap/nanofi/coap_functions.c b/extensions/coap/nanofi/coap_functions.c
index cd883c731..3d7fa4273 100644
--- a/extensions/coap/nanofi/coap_functions.c
+++ b/extensions/coap/nanofi/coap_functions.c
@@ -42,7 +42,8 @@ int create_session(coap_context_t **ctx, coap_session_t **session, const char *n
int getaddrres;
struct addrinfo hints;
coap_proto_t proto = COAP_PROTO_UDP;
- struct addrinfo *result, *interface_itr;
+ struct addrinfo *result;
+ struct addrinfo *interface_itr;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; // ipv4 or ipv6
@@ -84,7 +85,8 @@ int create_session(coap_context_t **ctx, coap_session_t **session, const char *n
int create_endpoint_context(coap_context_t **ctx, const char *node, const char *port) {
struct addrinfo hints;
- struct addrinfo *result, *interface_itr;
+ struct addrinfo *result;
+ struct addrinfo *interface_itr;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; // ipv4 or ipv6
@@ -182,7 +184,8 @@ void response_handler(struct coap_context_t *ctx, struct coap_session_t *session
}
int resolve_address(const struct coap_str_const_t *server, struct sockaddr *destination) {
- struct addrinfo *result, *iterative_obj;
+ struct addrinfo *result;
+ struct addrinfo *iterative_obj;
struct addrinfo hints;
static char addrstr[256];
int error, len = -1;
diff --git a/extensions/coap/protocols/CoapC2Protocol.cpp b/extensions/coap/protocols/CoapC2Protocol.cpp
index d2539afd9..74c4421f5 100644
--- a/extensions/coap/protocols/CoapC2Protocol.cpp
+++ b/extensions/coap/protocols/CoapC2Protocol.cpp
@@ -125,7 +125,10 @@ int CoapProtocol::writeHeartbeat(io::BaseStream *stream, const minifi::c2::C2Pay
queueParser.foreach([this, stream](const minifi::c2::C2Payload &component) {
auto myParser = minifi::c2::PayloadParser::getInstance(component);
stream->write(component.getLabel());
- uint64_t datasize = 0, datasizemax = 0, qsize = 0, sizemax = 0;
+ uint64_t datasize = 0;
+ uint64_t datasizemax = 0;
+ uint64_t qsize = 0;
+ uint64_t sizemax = 0;
try {
datasize = myParser.getAs<uint64_t>("dataSize");
datasizemax = myParser.getAs<uint64_t>("dataSizeMax");
@@ -159,7 +162,7 @@ int CoapProtocol::writeHeartbeat(io::BaseStream *stream, const minifi::c2::C2Pay
return 0;
}
-minifi::c2::Operation CoapProtocol::getOperation(int type) const {
+minifi::c2::Operation CoapProtocol::getOperation(int type) {
switch (type) {
case 0:
return minifi::c2::Operation::ACKNOWLEDGE;
@@ -256,7 +259,8 @@ minifi::c2::C2Payload CoapProtocol::serialize(const minifi::c2::C2Payload &paylo
for (int i = 0; i < size; i++) {
uint8_t operationType;
uint16_t argsize = 0;
- std::string operand, id;
+ std::string operand;
+ std::string id;
REQUIRE_SIZE_IF(1, responseStream.read(operationType))
REQUIRE_VALID(responseStream.read(id, false))
REQUIRE_VALID(responseStream.read(operand, false))
@@ -273,7 +277,8 @@ minifi::c2::C2Payload CoapProtocol::serialize(const minifi::c2::C2Payload &paylo
new_command.ident = id;
responseStream.read(argsize);
for (int j = 0; j < argsize; j++) {
- std::string key, value;
+ std::string key;
+ std::string value;
REQUIRE_VALID(responseStream.read(key))
REQUIRE_VALID(responseStream.read(value))
new_command.operation_arguments[key] = value;
diff --git a/extensions/coap/protocols/CoapC2Protocol.h b/extensions/coap/protocols/CoapC2Protocol.h
index fe5420a69..c39275522 100644
--- a/extensions/coap/protocols/CoapC2Protocol.h
+++ b/extensions/coap/protocols/CoapC2Protocol.h
@@ -89,7 +89,7 @@ class CoapProtocol : public minifi::c2::RESTSender {
* @param type input type
* @return Operation
*/
- minifi::c2::Operation getOperation(int type) const;
+ static minifi::c2::Operation getOperation(int type);
/**
* Writes a heartbeat to the provided BaseStream ptr.
@@ -105,7 +105,7 @@ class CoapProtocol : public minifi::c2::RESTSender {
* @param payload payload to serialize
* @return result 0 if success failure otherwise
*/
- int writeAcknowledgement(io::BaseStream *stream, const minifi::c2::C2Payload &payload);
+ static int writeAcknowledgement(io::BaseStream *stream, const minifi::c2::C2Payload &payload);
minifi::c2::C2Payload serialize(const minifi::c2::C2Payload &payload);
diff --git a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp
index e8748eeca..0a2c1ad3b 100644
--- a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp
+++ b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp
@@ -99,10 +99,12 @@ class VerifyCoAPServer : public CoapIntegrationBase {
const auto* const inv = dynamic_cast<minifi::processors::InvokeHTTP*>(proc);
assert(inv != nullptr);
- std::string url = "";
+ std::string url;
inv->getProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
- std::string port, scheme, path;
+ std::string port;
+ std::string scheme;
+ std::string path;
parse_http_components(url, port, scheme, path);
uint16_t newport = std::stoi(port) + 2;
@@ -133,7 +135,8 @@ class VerifyCoAPServer : public CoapIntegrationBase {
{
// should result in valid operation
minifi::io::BufferStream stream;
- uint16_t version = 0, size = 1;
+ uint16_t version = 0;
+ uint16_t size = 1;
uint8_t operation = 1;
stream.write(version);
stream.write(size);
diff --git a/extensions/expression-language/Expression.cpp b/extensions/expression-language/Expression.cpp
index f856bff20..f25da3f9b 100644
--- a/extensions/expression-language/Expression.cpp
+++ b/extensions/expression-language/Expression.cpp
@@ -116,9 +116,11 @@ Value expr_hostname(const std::vector<Value> &args) {
hostname[1023] = '\0';
gethostname(hostname, 1023);
- if (args.size() > 0 && args[0].asBoolean()) {
+ if (!args.empty() && args[0].asBoolean()) {
int status;
- struct addrinfo hints, *result, *addr_cursor;
+ struct addrinfo hints;
+ struct addrinfo *result;
+ struct addrinfo *addr_cursor;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
@@ -154,7 +156,9 @@ Value expr_ip(const std::vector<Value>& /*args*/) {
int status;
char ip_str[INET6_ADDRSTRLEN];
struct sockaddr_in *addr;
- struct addrinfo hints, *result, *addr_cursor;
+ struct addrinfo hints;
+ struct addrinfo *result;
+ struct addrinfo *addr_cursor;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
@@ -1011,7 +1015,7 @@ Value expr_ifElse(const std::vector<Value> &args) {
}
Expression make_allAttributes(const std::string &function_name, const std::vector<Expression> &args) {
- if (args.size() < 1) {
+ if (args.empty()) {
std::stringstream message_ss;
message_ss << "Expression language function " << function_name << " called with " << args.size() << " argument(s), but " << 1 << " are required";
throw std::runtime_error(message_ss.str());
@@ -1056,7 +1060,7 @@ Expression make_allAttributes(const std::string &function_name, const std::vecto
}
Expression make_anyAttribute(const std::string &function_name, const std::vector<Expression> &args) {
- if (args.size() < 1) {
+ if (args.empty()) {
std::stringstream message_ss;
message_ss << "Expression language function " << function_name << " called with " << args.size() << " argument(s), but " << 1 << " are required";
throw std::runtime_error(message_ss.str());
@@ -1101,7 +1105,7 @@ Expression make_anyAttribute(const std::string &function_name, const std::vector
}
Expression make_allMatchingAttributes(const std::string &function_name, const std::vector<Expression> &args) {
- if (args.size() < 1) {
+ if (args.empty()) {
std::stringstream message_ss;
message_ss << "Expression language function " << function_name << " called with " << args.size() << " argument(s), but " << 1 << " are required";
throw std::runtime_error(message_ss.str());
@@ -1154,7 +1158,7 @@ Expression make_allMatchingAttributes(const std::string &function_name, const st
}
Expression make_anyMatchingAttribute(const std::string &function_name, const std::vector<Expression> &args) {
- if (args.size() < 1) {
+ if (args.empty()) {
std::stringstream message_ss;
message_ss << "Expression language function " << function_name << " called with " << args.size() << " argument(s), but " << 1 << " are required";
throw std::runtime_error(message_ss.str());
@@ -1501,11 +1505,7 @@ Expression make_function_composition(const Expression &arg, const std::vector<st
}
bool Expression::is_dynamic() const {
- if (val_fn_) {
- return true;
- } else {
- return false;
- }
+ return static_cast<bool>(val_fn_);
}
Expression Expression::operator+(const Expression &other_expr) const {
diff --git a/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp b/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp
index 48316ae72..28c3dc140 100644
--- a/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp
+++ b/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp
@@ -53,7 +53,9 @@ class TestHarness : public IntegrationBase {
};
int main(int argc, char **argv) {
- std::string key_dir, test_file_location, url;
+ std::string key_dir;
+ std::string test_file_location;
+ std::string url;
if (argc > 1) {
test_file_location = argv[1];
}
diff --git a/extensions/gcp/processors/FetchGCSObject.h b/extensions/gcp/processors/FetchGCSObject.h
index 794e7b4cd..74a5e5ea1 100644
--- a/extensions/gcp/processors/FetchGCSObject.h
+++ b/extensions/gcp/processors/FetchGCSObject.h
@@ -61,7 +61,7 @@ class FetchGCSObject : public GCSProcessor {
ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS
void initialize() override;
- void onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
+ void onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &session_factory) override;
void onTrigger(const std::shared_ptr<core::ProcessContext>& context, const std::shared_ptr<core::ProcessSession>& session) override;
private:
diff --git a/extensions/gcp/processors/ListGCSBucket.h b/extensions/gcp/processors/ListGCSBucket.h
index d2ca79a38..9539d2e89 100644
--- a/extensions/gcp/processors/ListGCSBucket.h
+++ b/extensions/gcp/processors/ListGCSBucket.h
@@ -56,7 +56,7 @@ class ListGCSBucket : public GCSProcessor {
ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS
void initialize() override;
- void onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
+ void onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &session_factory) override;
void onTrigger(const std::shared_ptr<core::ProcessContext>& context, const std::shared_ptr<core::ProcessSession>& session) override;
private:
diff --git a/extensions/gcp/processors/PutGCSObject.cpp b/extensions/gcp/processors/PutGCSObject.cpp
index 9578e0896..2bee2ae43 100644
--- a/extensions/gcp/processors/PutGCSObject.cpp
+++ b/extensions/gcp/processors/PutGCSObject.cpp
@@ -76,7 +76,7 @@ class UploadToGCSCallback {
}
void setIfGenerationMatch(std::optional<bool> overwrite) {
- if (overwrite.has_value() && overwrite.value() == false) {
+ if (overwrite.has_value() && !overwrite.value()) {
if_generation_match_ = gcs::IfGenerationMatch(0);
} else {
if_generation_match_ = gcs::IfGenerationMatch();
diff --git a/extensions/gcp/processors/PutGCSObject.h b/extensions/gcp/processors/PutGCSObject.h
index 854dbae62..6611932cf 100644
--- a/extensions/gcp/processors/PutGCSObject.h
+++ b/extensions/gcp/processors/PutGCSObject.h
@@ -79,7 +79,7 @@ class PutGCSObject : public GCSProcessor {
ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS
void initialize() override;
- void onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
+ void onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &session_factory) override;
void onTrigger(const std::shared_ptr<core::ProcessContext>& context, const std::shared_ptr<core::ProcessSession>& session) override;
private:
diff --git a/extensions/http-curl/client/HTTPClient.cpp b/extensions/http-curl/client/HTTPClient.cpp
index 382087244..42dc658d9 100644
--- a/extensions/http-curl/client/HTTPClient.cpp
+++ b/extensions/http-curl/client/HTTPClient.cpp
@@ -22,12 +22,15 @@
#include <memory>
#include <string>
#include <vector>
+#include <utility>
#include "Exception.h"
#include "utils/gsl.h"
#include "utils/StringUtils.h"
#include "core/Resource.h"
#include "utils/RegexUtils.h"
+#include "range/v3/algorithm/all_of.hpp"
+#include "range/v3/action/transform.hpp"
namespace org::apache::nifi::minifi::utils {
@@ -456,15 +459,10 @@ bool HTTPClient::isValidHttpHeaderField(std::string_view field_name) {
// RFC822 3.1.2: The field-name must be composed of printable ASCII characters
// (i.e., characters that have values between 33. and 126., decimal, except colon).
- for (auto ch : field_name) {
- if (ch < 33 || ch > 126 || ch == ':') {
- return false;
- }
- }
- return true;
+ return ranges::all_of(field_name, [](char c) { return c >= 33 && c <= 126 && c != ':'; });
}
-std::string HTTPClient::replaceInvalidCharactersInHttpHeaderFieldName(std::string_view field_name) {
+std::string HTTPClient::replaceInvalidCharactersInHttpHeaderFieldName(std::string field_name) {
if (field_name.empty()) {
return "X-MiNiFi-Empty-Attribute-Name";
}
@@ -472,14 +470,10 @@ std::string HTTPClient::replaceInvalidCharactersInHttpHeaderFieldName(std::strin
std::string result;
// RFC822 3.1.2: The field-name must be composed of printable ASCII characters
// (i.e., characters that have values between 33. and 126., decimal, except colon).
- for (auto ch : field_name) {
- if (ch < 33 || ch > 126 || ch == ':') {
- result += '-';
- } else {
- result += ch;
- }
- }
- return result;
+ ranges::actions::transform(field_name, [](char ch) {
+ return (ch >= 33 && ch <= 126 && ch != ':') ? ch : '-';
+ });
+ return field_name;
}
REGISTER_RESOURCE(HTTPClient, InternalResource);
diff --git a/extensions/http-curl/client/HTTPClient.h b/extensions/http-curl/client/HTTPClient.h
index 934baf1b3..d2ef25e12 100644
--- a/extensions/http-curl/client/HTTPClient.h
+++ b/extensions/http-curl/client/HTTPClient.h
@@ -237,7 +237,7 @@ class HTTPClient : public BaseHTTPClient, public core::Connectable {
}
static bool isValidHttpHeaderField(std::string_view field_name);
- static std::string replaceInvalidCharactersInHttpHeaderFieldName(std::string_view field_name);
+ static std::string replaceInvalidCharactersInHttpHeaderFieldName(std::string field_name);
private:
static int onProgress(void *client, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
diff --git a/extensions/http-curl/client/HTTPStream.h b/extensions/http-curl/client/HTTPStream.h
index 536d314bf..05cc365c0 100644
--- a/extensions/http-curl/client/HTTPStream.h
+++ b/extensions/http-curl/client/HTTPStream.h
@@ -39,7 +39,7 @@ class HttpStream : public io::BaseStream {
* File Stream constructor that accepts an fstream shared pointer.
* It must already be initialized for read and write.
*/
- explicit HttpStream(std::shared_ptr<utils::HTTPClient> http_client_);
+ explicit HttpStream(std::shared_ptr<utils::HTTPClient> client);
virtual ~HttpStream() {
forceClose();
diff --git a/extensions/http-curl/processors/InvokeHTTP.h b/extensions/http-curl/processors/InvokeHTTP.h
index 4e11150c3..0b4766f0c 100644
--- a/extensions/http-curl/processors/InvokeHTTP.h
+++ b/extensions/http-curl/processors/InvokeHTTP.h
@@ -149,7 +149,7 @@ class InvokeHTTP : public core::Processor {
* @param statuscode http response code.
*/
void route(const std::shared_ptr<core::FlowFile> &request, const std::shared_ptr<core::FlowFile> &response, const std::shared_ptr<core::ProcessSession> &session,
- const std::shared_ptr<core::ProcessContext> &context, bool isSuccess, int64_t statusCode);
+ const std::shared_ptr<core::ProcessContext> &context, bool is_success, int64_t status_code);
bool shouldEmitFlowFile() const;
[[nodiscard]] bool appendHeaders(const core::FlowFile& flow_file, /*std::invocable<std::string, std::string>*/ auto append_header);
diff --git a/extensions/http-curl/protocols/AgentPrinter.h b/extensions/http-curl/protocols/AgentPrinter.h
index e384b85c3..4a679b1ef 100644
--- a/extensions/http-curl/protocols/AgentPrinter.h
+++ b/extensions/http-curl/protocols/AgentPrinter.h
@@ -44,7 +44,7 @@ class AgentPrinter : public HeartbeatJsonSerializer, public HeartbeatReporter {
/**
* Accepts the heartbeat, only extracting AgentInformation.
*/
- int16_t heartbeat(const C2Payload &heartbeat) override;
+ int16_t heartbeat(const C2Payload &payload) override;
/**
* Overrides extracting the agent information from the payload.
diff --git a/extensions/http-curl/protocols/RESTSender.cpp b/extensions/http-curl/protocols/RESTSender.cpp
index 6e87809e1..a6cbe7d27 100644
--- a/extensions/http-curl/protocols/RESTSender.cpp
+++ b/extensions/http-curl/protocols/RESTSender.cpp
@@ -39,7 +39,8 @@ void RESTSender::initialize(core::controller::ControllerServiceProvider* control
RESTProtocol::initialize(controller, configure);
// base URL when one is not specified.
if (nullptr != configure) {
- std::string update_str, ssl_context_service_str;
+ std::string update_str;
+ std::string ssl_context_service_str;
configure->get(Configuration::nifi_c2_rest_url, "c2.rest.url", rest_uri_);
configure->get(Configuration::nifi_c2_rest_url_ack, "c2.rest.url.ack", ack_uri_);
if (configure->get(Configuration::nifi_c2_rest_ssl_context_service, "c2.rest.ssl.context.service", ssl_context_service_str)) {
diff --git a/extensions/http-curl/sitetosite/HTTPProtocol.h b/extensions/http-curl/sitetosite/HTTPProtocol.h
index 005f53055..0b048b5e5 100644
--- a/extensions/http-curl/sitetosite/HTTPProtocol.h
+++ b/extensions/http-curl/sitetosite/HTTPProtocol.h
@@ -131,7 +131,7 @@ class HttpSiteToSiteClient : public sitetosite::SiteToSiteClient {
void tearDown() override;
- std::optional<utils::Identifier> parseTransactionId(const std::string &uri);
+ static std::optional<utils::Identifier> parseTransactionId(const std::string &uri);
std::unique_ptr<utils::HTTPClient> create_http_client(const std::string &uri, const std::string &method = "POST", bool setPropertyHeaders = false) {
std::unique_ptr<utils::HTTPClient> http_client_ = std::make_unique<utils::HTTPClient>(uri, ssl_context_service_);
diff --git a/extensions/http-curl/tests/C2MultipleCommandsTest.cpp b/extensions/http-curl/tests/C2MultipleCommandsTest.cpp
index beb6e53f4..a8d58ab53 100644
--- a/extensions/http-curl/tests/C2MultipleCommandsTest.cpp
+++ b/extensions/http-curl/tests/C2MultipleCommandsTest.cpp
@@ -35,7 +35,7 @@ class AckAuditor {
bool isAcknowledged(const std::string& operation_id) const {
std::lock_guard<std::mutex> guard(acknowledged_operations_mutex_);
- return acknowledged_operations_.count(operation_id) > 0;
+ return acknowledged_operations_.contains(operation_id);
}
void addVerifier(std::function<void(const rapidjson::Document&)> verifier) {
diff --git a/extensions/http-curl/tests/C2NullConfiguration.cpp b/extensions/http-curl/tests/C2NullConfiguration.cpp
index 3a773ea93..42eb134af 100644
--- a/extensions/http-curl/tests/C2NullConfiguration.cpp
+++ b/extensions/http-curl/tests/C2NullConfiguration.cpp
@@ -72,7 +72,9 @@ class VerifyC2Server : public HTTPIntegrationBase {
std::string url;
inv->getProperty(processors::InvokeHTTP::URL.getName(), url);
- std::string port, scheme, path;
+ std::string port;
+ std::string scheme;
+ std::string path;
parse_http_components(url, port, scheme, path);
configuration->set(Configuration::nifi_c2_enable, "true");
configuration->set(Configuration::nifi_c2_agent_class, "test");
diff --git a/extensions/http-curl/tests/C2PauseResumeTest.cpp b/extensions/http-curl/tests/C2PauseResumeTest.cpp
index 0721bd38e..d8294d849 100644
--- a/extensions/http-curl/tests/C2PauseResumeTest.cpp
+++ b/extensions/http-curl/tests/C2PauseResumeTest.cpp
@@ -150,7 +150,9 @@ int main(int argc, char **argv) {
assert(inv != nullptr);
std::string url;
inv->getProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
- std::string port, scheme, path;
+ std::string port;
+ std::string scheme;
+ std::string path;
std::unique_ptr<TestServer> server;
parse_http_components(url, port, scheme, path);
server = std::make_unique<TestServer>(port, path, &responder);
diff --git a/extensions/http-curl/tests/C2VerifyResourceConsumptionInHeartbeat.cpp b/extensions/http-curl/tests/C2VerifyResourceConsumptionInHeartbeat.cpp
index c329abbd8..c9db85c2b 100644
--- a/extensions/http-curl/tests/C2VerifyResourceConsumptionInHeartbeat.cpp
+++ b/extensions/http-curl/tests/C2VerifyResourceConsumptionInHeartbeat.cpp
@@ -47,7 +47,7 @@ class ResourceConsumptionInHeartbeatHandler : public HeartbeatHandler {
}
protected:
- void verifySystemResourceConsumption(const rapidjson::Document& root, bool firstCall) {
+ static void verifySystemResourceConsumption(const rapidjson::Document& root, bool firstCall) {
assert(root.HasMember("deviceInfo"));
auto& device_info = root["deviceInfo"];
@@ -73,7 +73,7 @@ class ResourceConsumptionInHeartbeatHandler : public HeartbeatHandler {
assert(system_info["machinearch"].GetStringLength() > 0);
}
- void verifyProcessResourceConsumption(const rapidjson::Document& root, bool firstCall) {
+ static void verifyProcessResourceConsumption(const rapidjson::Document& root, bool firstCall) {
assert(root.HasMember("agentInfo"));
auto& agent_info = root["agentInfo"];
diff --git a/extensions/http-curl/tests/C2VerifyServeResults.cpp b/extensions/http-curl/tests/C2VerifyServeResults.cpp
index fc54fd7aa..1d64bb4c5 100644
--- a/extensions/http-curl/tests/C2VerifyServeResults.cpp
+++ b/extensions/http-curl/tests/C2VerifyServeResults.cpp
@@ -69,7 +69,9 @@ class VerifyC2Server : public HTTPIntegrationBase {
std::string url;
inv->getProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
- std::string port, scheme, path;
+ std::string port;
+ std::string scheme;
+ std::string path;
parse_http_components(url, port, scheme, path);
configuration->set(org::apache::nifi::minifi::Configuration::nifi_c2_enable, "true");
configuration->set(org::apache::nifi::minifi::Configuration::nifi_c2_agent_class, "test");
diff --git a/extensions/http-curl/tests/unit/HTTPClientTests.cpp b/extensions/http-curl/tests/unit/HTTPClientTests.cpp
index 15b3225df..87e1050da 100644
--- a/extensions/http-curl/tests/unit/HTTPClientTests.cpp
+++ b/extensions/http-curl/tests/unit/HTTPClientTests.cpp
@@ -31,7 +31,7 @@ TEST_CASE("HTTPClientTestChunkedResponse", "[basic]") {
class Responder : public CivetHandler {
public:
- void send_response(struct mg_connection *conn) {
+ static void send_response(struct mg_connection *conn) {
mg_printf(conn, "HTTP/1.1 200 OK\r\n");
mg_printf(conn, "Content-Type: application/octet-stream\r\n");
mg_printf(conn, "Transfer-Encoding: chunked\r\n");
diff --git a/extensions/jni/ExecuteJavaProcessor.cpp b/extensions/jni/ExecuteJavaProcessor.cpp
index c220db915..7febe9a06 100644
--- a/extensions/jni/ExecuteJavaProcessor.cpp
+++ b/extensions/jni/ExecuteJavaProcessor.cpp
@@ -43,12 +43,7 @@
#include "jvm/JniMethod.h"
#include "jvm/JniLogger.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace jni {
-namespace processors {
+namespace org::apache::nifi::minifi::jni::processors {
core::Property ExecuteJavaProcessor::JVMControllerService(core::PropertyBuilder::createProperty("JVM Controller Service")
->withDescription("Name of controller service defined within this flow")
@@ -154,7 +149,7 @@ void ExecuteJavaProcessor::onSchedule(const std::shared_ptr<core::ProcessContext
try {
for (const auto &onScheduledName : onScheduledNames) {
- current_processor_class.callVoidMethod(env, clazzInstance, onScheduledName.first.c_str(), onScheduledName.second, context_instance_);
+ current_processor_class.callVoidMethod(env, clazzInstance, onScheduledName.first, onScheduledName.second, context_instance_);
}
} catch (std::runtime_error &re) {
// this can be ignored.
@@ -227,10 +222,4 @@ void ExecuteJavaProcessor::onTrigger(const std::shared_ptr<core::ProcessContext>
REGISTER_RESOURCE_AS(ExecuteJavaProcessor, Processor, ("ExecuteJavaClass"));
-} /* namespace processors */
-} /* namespace jni */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
-
+} // namespace org::apache::nifi::minifi::jni::processors
diff --git a/extensions/jni/ExecuteJavaProcessor.h b/extensions/jni/ExecuteJavaProcessor.h
index b334d2957..73550336d 100644
--- a/extensions/jni/ExecuteJavaProcessor.h
+++ b/extensions/jni/ExecuteJavaProcessor.h
@@ -252,7 +252,7 @@ class ExecuteJavaProcessor : public core::Processor {
return factory;
}
- JNINativeMethod registerNativeMethod(const std::string &name, const std::string ¶ms, const void *ptr);
+ static JNINativeMethod registerNativeMethod(const std::string &name, const std::string ¶ms, const void *ptr);
JavaClass jni_logger_class_;
diff --git a/extensions/jni/jvm/JavaControllerService.cpp b/extensions/jni/jvm/JavaControllerService.cpp
index 03e8ead84..f2596c27e 100644
--- a/extensions/jni/jvm/JavaControllerService.cpp
+++ b/extensions/jni/jvm/JavaControllerService.cpp
@@ -66,7 +66,9 @@ void JavaControllerService::onEnable() {
core::Property prop = NarDirectory;
- std::string nardir, narscratch, nardocs;
+ std::string nardir;
+ std::string narscratch;
+ std::string nardocs;
if (getProperty(NarDirectory.getName(), prop)) {
nardir = prop.getValue().to_string();
}
diff --git a/extensions/libarchive/ArchiveMetadata.h b/extensions/libarchive/ArchiveMetadata.h
index dff5345ae..712c1287d 100644
--- a/extensions/libarchive/ArchiveMetadata.h
+++ b/extensions/libarchive/ArchiveMetadata.h
@@ -64,7 +64,7 @@ class ArchiveMetadata {
ArchiveEntryIterator find(const std::string& name);
ArchiveEntryIterator eraseEntry(ArchiveEntryIterator position);
- ArchiveEntryIterator insertEntry(ArchiveEntryIterator it, const ArchiveEntryMetadata& entry);
+ ArchiveEntryIterator insertEntry(ArchiveEntryIterator position, const ArchiveEntryMetadata& entry);
void seedTempPaths(org::apache::nifi::minifi::utils::file::FileManager* file_man, bool keep);
@@ -82,7 +82,7 @@ class ArchiveStack {
void push(const ArchiveMetadata& metadata) { stack_.push_back(metadata); }
ArchiveMetadata pop() { auto x = top(); stack_.pop_back(); return x; }
ArchiveMetadata top() const { return stack_.back(); }
- void loadJson(const rapidjson::Value& input);
+ void loadJson(const rapidjson::Value& lensStack);
void loadJsonString(const std::string& input);
std::string toJsonString() const;
rapidjson::Document toJson() const;
diff --git a/extensions/libarchive/BinFiles.h b/extensions/libarchive/BinFiles.h
index d3ede9e2a..fc72ec147 100644
--- a/extensions/libarchive/BinFiles.h
+++ b/extensions/libarchive/BinFiles.h
@@ -263,9 +263,9 @@ class BinFiles : public core::Processor {
return false;
}
// transfer flows to failure in bin
- void transferFlowsToFail(core::ProcessContext *context, core::ProcessSession *session, std::unique_ptr<Bin> &bin);
+ static void transferFlowsToFail(core::ProcessContext *context, core::ProcessSession *session, std::unique_ptr<Bin> &bin);
// moves owned flows to session
- void addFlowsToSession(core::ProcessContext *context, core::ProcessSession *session, std::unique_ptr<Bin> &bin);
+ static void addFlowsToSession(core::ProcessContext *context, core::ProcessSession *session, std::unique_ptr<Bin> &bin);
BinManager binManager_;
diff --git a/extensions/libarchive/MergeContent.cpp b/extensions/libarchive/MergeContent.cpp
index 7e1b3b53b..c067a5a00 100644
--- a/extensions/libarchive/MergeContent.cpp
+++ b/extensions/libarchive/MergeContent.cpp
@@ -43,7 +43,7 @@ std::string MergeContent::readContent(std::string path) {
in.seekg(0, std::ios::end);
contents.resize(gsl::narrow<size_t>(in.tellg()));
in.seekg(0, std::ios::beg);
- in.read(&contents[0], contents.size());
+ in.read(contents.data(), contents.size());
in.close();
}
return (contents);
@@ -129,7 +129,7 @@ void MergeContent::validatePropertyOptions() {
}
std::string MergeContent::getGroupId(core::ProcessContext*, std::shared_ptr<core::FlowFile> flow) {
- std::string groupId = "";
+ std::string groupId;
std::string value;
if (!correlationAttributeName_.empty()) {
if (flow->getAttribute(correlationAttributeName_, value))
@@ -209,10 +209,7 @@ bool MergeContent::processBin(core::ProcessContext *context, core::ProcessSessio
int indexFirst = std::stoi(value);
second->getAttribute(BinFiles::FRAGMENT_INDEX_ATTRIBUTE, value);
int indexSecond = std::stoi(value);
- if (indexSecond > indexFirst)
- return true;
- else
- return false;
+ return indexSecond > indexFirst;
});
}
diff --git a/extensions/libarchive/MergeContent.h b/extensions/libarchive/MergeContent.h
index 0824bdf84..5d986280d 100644
--- a/extensions/libarchive/MergeContent.h
+++ b/extensions/libarchive/MergeContent.h
@@ -62,8 +62,8 @@ class BinaryConcatenationMerge : public MergeBin {
public:
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;
+ void 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) override;
// Nest Callback Class for write stream
class WriteCallback {
public:
@@ -345,7 +345,7 @@ class MergeContent : public processors::BinFiles {
// Returns a group ID representing a bin. This allows flow files to be binned into like groups
std::string getGroupId(core::ProcessContext *context, std::shared_ptr<core::FlowFile> flow) override;
// check whether the defragment bin is validate
- bool checkDefragment(std::unique_ptr<Bin> &bin);
+ static bool checkDefragment(std::unique_ptr<Bin> &bin);
private:
void validatePropertyOptions();
@@ -363,7 +363,7 @@ class MergeContent : public processors::BinFiles {
std::string footerContent_;
std::string demarcatorContent_;
std::string attributeStrategy_;
- std::string readContent(std::string path);
+ static std::string readContent(std::string path);
};
} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/librdkafka/ConsumeKafka.cpp b/extensions/librdkafka/ConsumeKafka.cpp
index 49bc833b7..c3144965d 100644
--- a/extensions/librdkafka/ConsumeKafka.cpp
+++ b/extensions/librdkafka/ConsumeKafka.cpp
@@ -220,7 +220,7 @@ void ConsumeKafka::configure_new_connection(core::ProcessContext& context) {
}
}
-std::string ConsumeKafka::extract_message(const rd_kafka_message_t& rkmessage) const {
+std::string ConsumeKafka::extract_message(const rd_kafka_message_t& rkmessage) {
if (RD_KAFKA_RESP_ERR_NO_ERROR != rkmessage.err) {
throw minifi::Exception(ExceptionType::PROCESSOR_EXCEPTION, "ConsumeKafka: received error message from broker: " + std::to_string(rkmessage.err) + " " + rd_kafka_err2str(rkmessage.err));
}
@@ -315,7 +315,7 @@ std::vector<std::pair<std::string, std::string>> ConsumeKafka::get_flowfile_attr
std::vector<std::pair<std::string, std::string>> attributes_from_headers;
for (const std::string& header_name : headers_to_add_as_attributes_) {
const std::vector<std::string> matching_headers = get_matching_headers(message, header_name);
- if (matching_headers.size()) {
+ if (!matching_headers.empty()) {
attributes_from_headers.emplace_back(header_name, utils::get_encoded_string(resolve_duplicate_headers(matching_headers), message_header_encoding_attr_to_enum()));
}
}
@@ -339,7 +339,7 @@ std::optional<std::vector<std::shared_ptr<FlowFileRecord>>> ConsumeKafka::transf
for (const auto& message : pending_messages_) {
std::string message_content = extract_message(*message);
std::vector<std::pair<std::string, std::string>> attributes_from_headers = get_flowfile_attributes_from_message_header(*message);
- std::vector<std::string> split_message{ message_demarcator_.size() ?
+ std::vector<std::string> split_message{ !message_demarcator_.empty() ?
utils::StringUtils::split(message_content, message_demarcator_) :
std::vector<std::string>{ message_content }};
for (auto& flowfile_content : split_message) {
@@ -382,7 +382,7 @@ void ConsumeKafka::onTrigger(core::ProcessContext* /* context */, core::ProcessS
std::unique_lock<std::mutex> lock(do_not_call_on_trigger_concurrently_);
logger_->log_debug("ConsumeKafka onTrigger");
- if (pending_messages_.size()) {
+ if (!pending_messages_.empty()) {
process_pending_messages(*session);
return;
}
diff --git a/extensions/librdkafka/ConsumeKafka.h b/extensions/librdkafka/ConsumeKafka.h
index 4ff9fc78a..d279de612 100644
--- a/extensions/librdkafka/ConsumeKafka.h
+++ b/extensions/librdkafka/ConsumeKafka.h
@@ -146,7 +146,7 @@ class ConsumeKafka : public KafkaProcessorBase {
void create_topic_partition_list();
void extend_config_from_dynamic_properties(const core::ProcessContext& context);
void configure_new_connection(core::ProcessContext& context);
- std::string extract_message(const rd_kafka_message_t& rkmessage) const;
+ static std::string extract_message(const rd_kafka_message_t& rkmessage);
std::vector<std::unique_ptr<rd_kafka_message_t, utils::rd_kafka_message_deleter>> poll_kafka_messages();
utils::KafkaEncoding key_attr_encoding_attr_to_enum() const;
utils::KafkaEncoding message_header_encoding_attr_to_enum() const;
diff --git a/extensions/librdkafka/KafkaConnection.cpp b/extensions/librdkafka/KafkaConnection.cpp
index 6675a8756..72d02cd10 100644
--- a/extensions/librdkafka/KafkaConnection.cpp
+++ b/extensions/librdkafka/KafkaConnection.cpp
@@ -74,7 +74,7 @@ rd_kafka_t *KafkaConnection::getConnection() const {
}
bool KafkaConnection::hasTopic(const std::string &topic) const {
- return topics_.count(topic);
+ return topics_.contains(topic);
}
std::shared_ptr<KafkaTopic> KafkaConnection::getTopic(const std::string &topic) const {
diff --git a/extensions/librdkafka/PublishKafka.cpp b/extensions/librdkafka/PublishKafka.cpp
index d000eb0be..066c32527 100644
--- a/extensions/librdkafka/PublishKafka.cpp
+++ b/extensions/librdkafka/PublishKafka.cpp
@@ -349,7 +349,8 @@ void PublishKafka::onSchedule(const std::shared_ptr<core::ProcessContext> &conte
interrupted_ = false;
// Try to get a KafkaConnection
- std::string client_id, brokers;
+ std::string client_id;
+ std::string brokers;
if (!context->getProperty(ClientName, client_id, nullptr)) {
throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Client Name property missing or invalid");
}
diff --git a/extensions/mqtt/processors/ConsumeMQTT.cpp b/extensions/mqtt/processors/ConsumeMQTT.cpp
index 93805f125..fe24538f0 100644
--- a/extensions/mqtt/processors/ConsumeMQTT.cpp
+++ b/extensions/mqtt/processors/ConsumeMQTT.cpp
@@ -94,8 +94,8 @@ void ConsumeMQTT::onTrigger(const std::shared_ptr<core::ProcessContext>& /*conte
logger_->log_error("ConsumeMQTT fail for the flow with UUID %s", processFlowFile->getUUIDStr());
session->remove(processFlowFile);
} else {
- session->putAttribute(processFlowFile, MQTT_BROKER_ATTRIBUTE, uri_.c_str());
- session->putAttribute(processFlowFile, MQTT_TOPIC_ATTRIBUTE, topic_.c_str());
+ session->putAttribute(processFlowFile, MQTT_BROKER_ATTRIBUTE, uri_);
+ session->putAttribute(processFlowFile, MQTT_TOPIC_ATTRIBUTE, topic_);
logger_->log_debug("ConsumeMQTT processing success for the flow with UUID %s topic %s", processFlowFile->getUUIDStr(), topic_);
session->transfer(processFlowFile, Success);
}
diff --git a/extensions/mqtt/processors/ConvertBase.cpp b/extensions/mqtt/processors/ConvertBase.cpp
index 81658a679..db9e2be98 100644
--- a/extensions/mqtt/processors/ConvertBase.cpp
+++ b/extensions/mqtt/processors/ConvertBase.cpp
@@ -30,7 +30,7 @@ void ConvertBase::initialize() {
}
void ConvertBase::onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory>& /*sessionFactory*/) {
- std::string controller_service_name = "";
+ std::string controller_service_name;
if (context->getProperty(MQTTControllerService.getName(), controller_service_name) && !controller_service_name.empty()) {
auto service = context->getControllerService(controller_service_name);
mqtt_service_ = std::static_pointer_cast<controllers::MQTTControllerService>(service);
diff --git a/extensions/mqtt/processors/ConvertUpdate.cpp b/extensions/mqtt/processors/ConvertUpdate.cpp
index c604595f1..dcbef511b 100644
--- a/extensions/mqtt/processors/ConvertUpdate.cpp
+++ b/extensions/mqtt/processors/ConvertUpdate.cpp
@@ -39,7 +39,8 @@ void ConvertUpdate::onTrigger(const std::shared_ptr<core::ProcessContext> &conte
if (!update.empty()) {
io::BufferStream stream(update);
- std::string returnTopic, url;
+ std::string returnTopic;
+ std::string url;
if (returnTopic.empty() || url.empty()) {
logger_->log_debug("topic and/or URL are empty");
diff --git a/extensions/mqtt/protocol/MQTTC2Protocol.cpp b/extensions/mqtt/protocol/MQTTC2Protocol.cpp
index 4509efde5..4c3132edf 100644
--- a/extensions/mqtt/protocol/MQTTC2Protocol.cpp
+++ b/extensions/mqtt/protocol/MQTTC2Protocol.cpp
@@ -37,7 +37,8 @@ void MQTTC2Protocol::initialize(core::controller::ControllerServiceProvider* con
agent_identifier_ = configure->getAgentIdentifier();
std::stringstream outputStream;
- std::string updateTopicOpt, heartbeatTopicOpt;
+ std::string updateTopicOpt;
+ std::string heartbeatTopicOpt;
if (configure->get(minifi::Configuration::nifi_c2_mqtt_heartbeat_topic, heartbeatTopicOpt)) {
heartbeat_topic_ = heartbeatTopicOpt;
} else {
diff --git a/extensions/opc/src/fetchopc.cpp b/extensions/opc/src/fetchopc.cpp
index 67f696b94..f3bee03c8 100644
--- a/extensions/opc/src/fetchopc.cpp
+++ b/extensions/opc/src/fetchopc.cpp
@@ -75,7 +75,7 @@ namespace org::apache::nifi::minifi::processors {
}
context->getProperty(Lazy.getName(), value);
- lazy_mode_ = value == "On" ? true : false;
+ lazy_mode_ = value == "On";
}
void FetchOPCProcessor::onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) {
diff --git a/extensions/opc/src/opc.cpp b/extensions/opc/src/opc.cpp
index 842a8467d..71d9f9482 100644
--- a/extensions/opc/src/opc.cpp
+++ b/extensions/opc/src/opc.cpp
@@ -41,7 +41,7 @@ namespace org::apache::nifi::minifi::opc {
namespace {
void add_value_to_variant(UA_Variant *variant, std::string &value) {
- UA_String ua_value = UA_STRING(&value[0]);
+ UA_String ua_value = UA_STRING(value.data());
UA_Variant_setScalarCopy(variant, &ua_value, &UA_TYPES[UA_TYPES_STRING]);
}
diff --git a/extensions/opencv/MotionDetector.cpp b/extensions/opencv/MotionDetector.cpp
index 59ebb4163..2a1d5bb17 100644
--- a/extensions/opencv/MotionDetector.cpp
+++ b/extensions/opencv/MotionDetector.cpp
@@ -24,11 +24,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 MotionDetector::ImageEncoding(
core::PropertyBuilder::createProperty("Image Encoding")
@@ -98,7 +94,8 @@ void MotionDetector::onSchedule(const std::shared_ptr<core::ProcessContext> &con
bool MotionDetector::detectAndDraw(cv::Mat &frame) {
cv::Mat gray;
- cv::Mat img_diff, thresh;
+ cv::Mat img_diff;
+ cv::Mat thresh;
std::vector<cv::Mat> contours;
logger_->log_trace("Detect and Draw");
@@ -209,8 +206,4 @@ void MotionDetector::notifyStop() {
REGISTER_RESOURCE(MotionDetector, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.cpp b/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.cpp
index 18b363345..1816b67de 100644
--- a/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.cpp
+++ b/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.cpp
@@ -133,12 +133,6 @@ const core::Property SourceInitiatedSubscriptionListener::ConnectionRetryCount(
const core::Relationship SourceInitiatedSubscriptionListener::Success("success", "All Events are routed to success");
-constexpr char const* SourceInitiatedSubscriptionListener::ATTRIBUTE_WEF_REMOTE_MACHINEID;
-constexpr char const* SourceInitiatedSubscriptionListener::ATTRIBUTE_WEF_REMOTE_IP;
-
-constexpr char const* SourceInitiatedSubscriptionListener::INITIAL_EXISTING_EVENTS_STRATEGY_NONE;
-constexpr char const* SourceInitiatedSubscriptionListener::INITIAL_EXISTING_EVENTS_STRATEGY_ALL;
-
SourceInitiatedSubscriptionListener::SourceInitiatedSubscriptionListener(const std::string& name, const utils::Identifier& uuid)
: Processor(name, uuid)
, session_factory_(nullptr)
diff --git a/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.h b/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.h
index 8d7c7e908..cf02f2275 100644
--- a/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.h
+++ b/extensions/openwsman/processors/SourceInitiatedSubscriptionListener.h
@@ -117,9 +117,9 @@ class SourceInitiatedSubscriptionListener : public core::Processor {
bool handleSubscriptions(struct mg_connection* conn, const std::string& endpoint, WsXmlDocH request);
static int enumerateEventCallback(WsXmlNodeH node, void* data);
- std::string getSoapAction(WsXmlDocH doc);
- std::string getMachineId(WsXmlDocH doc);
- bool isAckRequested(WsXmlDocH doc);
+ static std::string getSoapAction(WsXmlDocH doc);
+ static std::string getMachineId(WsXmlDocH doc);
+ static bool isAckRequested(WsXmlDocH doc);
void sendResponse(struct mg_connection* conn, const std::string& machineId, const std::string& remoteIp, char* xml_buf, size_t xml_buf_size);
static std::string millisecondsToXsdDuration(std::chrono::milliseconds milliseconds);
diff --git a/extensions/pcap/CapturePacket.cpp b/extensions/pcap/CapturePacket.cpp
index 5ca8768be..5b71c0791 100644
--- a/extensions/pcap/CapturePacket.cpp
+++ b/extensions/pcap/CapturePacket.cpp
@@ -44,11 +44,7 @@
#include "utils/ByteArrayCallback.h"
#include "utils/RegexUtils.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
std::shared_ptr<utils::IdGenerator> CapturePacket::id_generator_ = utils::IdGenerator::getIdGenerator();
@@ -76,7 +72,7 @@ std::string CapturePacket::generate_new_pcap(const std::string &base_path) {
void CapturePacket::packet_callback(pcpp::RawPacket* packet, pcpp::PcapLiveDevice* /*dev*/, void* data) {
// parse the packet
- PacketMovers* capture_mechanism = reinterpret_cast<PacketMovers*>(data);
+ auto capture_mechanism = reinterpret_cast<PacketMovers*>(data);
CapturePacketMechanism *capture;
@@ -102,8 +98,8 @@ void CapturePacket::packet_callback(pcpp::RawPacket* packet, pcpp::PcapLiveDevic
}
CapturePacketMechanism *CapturePacket::create_new_capture(const std::string &base_path, int64_t *max_size) {
- CapturePacketMechanism *new_capture = new CapturePacketMechanism(base_path, generate_new_pcap(base_path), max_size);
- new_capture->writer_ = new pcpp::PcapFileWriterDevice(new_capture->getFile().c_str());
+ auto new_capture = new CapturePacketMechanism(base_path, generate_new_pcap(base_path), max_size);
+ new_capture->writer_ = new pcpp::PcapFileWriterDevice(new_capture->getFile());
if (!new_capture->writer_->open())
throw std::runtime_error{utils::StringUtils::join_pack("Failed to open PcapFileWriterDevice with file ", new_capture->getFile())};
@@ -155,7 +151,7 @@ void CapturePacket::onSchedule(const std::shared_ptr<core::ProcessContext> &cont
if (!allowed_interfaces.empty()) {
bool found_match = false;
- std::string matching_regex = "";
+ std::string matching_regex;
for (const auto &filter : allowed_interfaces) {
utils::Regex r(filter);
utils::SMatch m;
@@ -222,8 +218,4 @@ void CapturePacket::onTrigger(const std::shared_ptr<core::ProcessContext> &conte
REGISTER_RESOURCE(CapturePacket, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/rocksdb-repos/FlowFileRepository.h b/extensions/rocksdb-repos/FlowFileRepository.h
index 197d4e1c3..6906979d2 100644
--- a/extensions/rocksdb-repos/FlowFileRepository.h
+++ b/extensions/rocksdb-repos/FlowFileRepository.h
@@ -217,7 +217,7 @@ class FlowFileRepository : public core::Repository {
* Returns true if a checkpoint is needed at startup
* @return true if a checkpoint is needed.
*/
- bool need_checkpoint(minifi::internal::OpenRocksDb& opendb);
+ static bool need_checkpoint(minifi::internal::OpenRocksDb& opendb);
/**
* Prunes stored flow files.
diff --git a/extensions/script/lua/LuaScriptEngine.cpp b/extensions/script/lua/LuaScriptEngine.cpp
index 7884eeb2d..6e82d592c 100644
--- a/extensions/script/lua/LuaScriptEngine.cpp
+++ b/extensions/script/lua/LuaScriptEngine.cpp
@@ -24,14 +24,9 @@
#include "LuaScriptEngine.h"
#include "LuaProcessSession.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace lua {
+namespace org::apache::nifi::minifi::lua {
-LuaScriptEngine::LuaScriptEngine()
- : lua_() {
+LuaScriptEngine::LuaScriptEngine() {
lua_.open_libraries(sol::lib::base,
sol::lib::os,
sol::lib::coroutine,
@@ -102,8 +97,4 @@ void LuaScriptEngine::evalFile(const std::string &file_name) {
}
}
-} /* namespace lua */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::lua
diff --git a/extensions/script/python/ExecutePythonProcessor.cpp b/extensions/script/python/ExecutePythonProcessor.cpp
index e8548161a..5f6b6ddaa 100644
--- a/extensions/script/python/ExecutePythonProcessor.cpp
+++ b/extensions/script/python/ExecutePythonProcessor.cpp
@@ -30,12 +30,7 @@
#include "core/PropertyBuilder.h"
#include "core/Resource.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace python {
-namespace processors {
+namespace org::apache::nifi::minifi::python::processors {
const core::Property ExecutePythonProcessor::ScriptFile(core::PropertyBuilder::createProperty("Script File")
->withDescription("Path to script file to execute. Only one of Script File or Script Body may be used")
@@ -122,7 +117,7 @@ void ExecutePythonProcessor::onTrigger(const std::shared_ptr<core::ProcessContex
void ExecutePythonProcessor::appendPathForImportModules() {
std::string module_directory;
getProperty(ModuleDirectory.getName(), module_directory);
- if (module_directory.size()) {
+ if (!module_directory.empty()) {
python_script_engine_->setModulePaths(utils::StringUtils::splitAndTrimRemovingEmpty(module_directory, ","));
}
}
@@ -145,8 +140,8 @@ void ExecutePythonProcessor::loadScript() {
throw std::runtime_error("Neither Script Body nor Script File is available to execute");
}
- if (script_file.size()) {
- if (script_body.size()) {
+ if (!script_file.empty()) {
+ if (!script_body.empty()) {
throw std::runtime_error("Only one of Script File or Script Body may be used");
}
script_file_path_ = script_file;
@@ -155,7 +150,6 @@ void ExecutePythonProcessor::loadScript() {
return;
}
script_to_exec_ = script_body;
- return;
}
void ExecutePythonProcessor::reloadScriptIfUsingScriptFileProperty() {
@@ -184,9 +178,4 @@ std::unique_ptr<PythonScriptEngine> ExecutePythonProcessor::createScriptEngine()
REGISTER_RESOURCE(ExecutePythonProcessor, Processor);
-} /* namespace processors */
-} /* namespace python */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::python::processors
diff --git a/extensions/sftp/client/SFTPClient.cpp b/extensions/sftp/client/SFTPClient.cpp
index bb32138b8..39872d309 100644
--- a/extensions/sftp/client/SFTPClient.cpp
+++ b/extensions/sftp/client/SFTPClient.cpp
@@ -97,8 +97,6 @@ static SFTPError libssh2_sftp_error_to_sftp_error(unsigned long libssh2_sftp_err
}
}
-constexpr size_t SFTPClient::MAX_BUFFER_SIZE;
-
LastSFTPError::LastSFTPError()
: sftp_error_set_(false)
, libssh2_sftp_error_(LIBSSH2_FX_OK)
@@ -222,10 +220,7 @@ bool SFTPClient::setProxy(ProxyType type, const utils::HTTPProxy& proxy) {
}
std::stringstream proxy_string;
proxy_string << proxy.host << ":" << proxy.port;
- if (curl_easy_setopt(easy_, CURLOPT_PROXY, proxy_string.str().c_str()) != CURLE_OK) {
- return false;
- }
- return true;
+ return curl_easy_setopt(easy_, CURLOPT_PROXY, proxy_string.str().c_str()) == CURLE_OK;
}
bool SFTPClient::setConnectionTimeout(std::chrono::milliseconds timeout) {
diff --git a/extensions/sftp/client/SFTPClient.h b/extensions/sftp/client/SFTPClient.h
index 4129ec1bf..86707858e 100644
--- a/extensions/sftp/client/SFTPClient.h
+++ b/extensions/sftp/client/SFTPClient.h
@@ -149,7 +149,7 @@ class SFTPClient {
int64_t atime;
};
- bool setAttributes(const std::string& path, const SFTPAttributes& attrs);
+ bool setAttributes(const std::string& path, const SFTPAttributes& input);
protected:
/*
diff --git a/extensions/sftp/processors/FetchSFTP.cpp b/extensions/sftp/processors/FetchSFTP.cpp
index eac269d40..b65a4fffe 100644
--- a/extensions/sftp/processors/FetchSFTP.cpp
+++ b/extensions/sftp/processors/FetchSFTP.cpp
@@ -34,14 +34,6 @@
namespace org::apache::nifi::minifi::processors {
-constexpr char const* FetchSFTP::COMPLETION_STRATEGY_NONE;
-constexpr char const* FetchSFTP::COMPLETION_STRATEGY_MOVE_FILE;
-constexpr char const* FetchSFTP::COMPLETION_STRATEGY_DELETE_FILE;
-
-constexpr char const* FetchSFTP::ATTRIBUTE_SFTP_REMOTE_HOST;
-constexpr char const* FetchSFTP::ATTRIBUTE_SFTP_REMOTE_PORT;
-constexpr char const* FetchSFTP::ATTRIBUTE_SFTP_REMOTE_FILENAME;
-
void FetchSFTP::initialize() {
logger_->log_trace("Initializing FetchSFTP");
diff --git a/extensions/sftp/processors/ListSFTP.cpp b/extensions/sftp/processors/ListSFTP.cpp
index 83b67b2bd..4603bf7a0 100644
--- a/extensions/sftp/processors/ListSFTP.cpp
+++ b/extensions/sftp/processors/ListSFTP.cpp
@@ -52,17 +52,6 @@ const std::map<std::string, uint64_t> ListSFTP::LISTING_LAG_MAP = {
{ListSFTP::TARGET_SYSTEM_TIMESTAMP_PRECISION_MINUTES, 60000},
};
-constexpr char const* ListSFTP::LISTING_STRATEGY_TRACKING_TIMESTAMPS;
-constexpr char const* ListSFTP::LISTING_STRATEGY_TRACKING_ENTITIES;
-
-constexpr char const* ListSFTP::TARGET_SYSTEM_TIMESTAMP_PRECISION_AUTO_DETECT;
-constexpr char const* ListSFTP::TARGET_SYSTEM_TIMESTAMP_PRECISION_MILLISECONDS;
-constexpr char const* ListSFTP::TARGET_SYSTEM_TIMESTAMP_PRECISION_SECONDS;
-constexpr char const* ListSFTP::TARGET_SYSTEM_TIMESTAMP_PRECISION_MINUTES;
-
-constexpr char const* ListSFTP::ENTITY_TRACKING_INITIAL_LISTING_TARGET_TRACKING_TIME_WINDOW;
-constexpr char const* ListSFTP::ENTITY_TRACKING_INITIAL_LISTING_TARGET_ALL_AVAILABLE;
-
namespace {
uint64_t toUnixTime(const std::optional<std::chrono::system_clock::time_point> time_point) {
if (!time_point)
@@ -593,7 +582,7 @@ void ListSFTP::listByTrackingTimestamps(
if (files_for_timestamp.first == last_processed_latest_entry_timestamp_) {
/* Filter out previously processed entities. */
for (auto it = files_for_timestamp.second.begin(); it != files_for_timestamp.second.end();) {
- if (latest_identifiers_processed_.count(it->getPath()) != 0U) {
+ if (latest_identifiers_processed_.contains(it->getPath())) {
it = files_for_timestamp.second.erase(it);
} else {
++it;
diff --git a/extensions/sftp/processors/PutSFTP.cpp b/extensions/sftp/processors/PutSFTP.cpp
index b167f649e..e01eaec81 100644
--- a/extensions/sftp/processors/PutSFTP.cpp
+++ b/extensions/sftp/processors/PutSFTP.cpp
@@ -44,13 +44,6 @@
namespace org::apache::nifi::minifi::processors {
-constexpr char const* PutSFTP::CONFLICT_RESOLUTION_REPLACE;
-constexpr char const* PutSFTP::CONFLICT_RESOLUTION_IGNORE;
-constexpr char const* PutSFTP::CONFLICT_RESOLUTION_RENAME;
-constexpr char const* PutSFTP::CONFLICT_RESOLUTION_REJECT;
-constexpr char const* PutSFTP::CONFLICT_RESOLUTION_FAIL;
-constexpr char const* PutSFTP::CONFLICT_RESOLUTION_NONE;
-
void PutSFTP::initialize() {
logger_->log_trace("Initializing PutSFTP");
diff --git a/extensions/sftp/processors/SFTPProcessorBase.cpp b/extensions/sftp/processors/SFTPProcessorBase.cpp
index 1c801759f..3cfb71d9b 100644
--- a/extensions/sftp/processors/SFTPProcessorBase.cpp
+++ b/extensions/sftp/processors/SFTPProcessorBase.cpp
@@ -43,12 +43,6 @@
namespace org::apache::nifi::minifi::processors {
-constexpr char const* SFTPProcessorBase::PROXY_TYPE_DIRECT;
-constexpr char const* SFTPProcessorBase::PROXY_TYPE_HTTP;
-constexpr char const* SFTPProcessorBase::PROXY_TYPE_SOCKS;
-
-constexpr size_t SFTPProcessorBase::CONNECTION_CACHE_MAX_SIZE;
-
SFTPProcessorBase::SFTPProcessorBase(const std::string& name, const utils::Identifier& uuid)
: Processor(name, uuid),
connection_timeout_(0),
diff --git a/extensions/sftp/tests/ListSFTPTests.cpp b/extensions/sftp/tests/ListSFTPTests.cpp
index a51961653..5baa407cf 100644
--- a/extensions/sftp/tests/ListSFTPTests.cpp
+++ b/extensions/sftp/tests/ListSFTPTests.cpp
@@ -142,7 +142,7 @@ class ListSFTPTestsFixture {
auto full_path = ss.str();
std::deque<std::string> parent_dirs;
std::string parent_dir = full_path;
- while ((parent_dir = utils::file::FileUtils::get_parent_path(parent_dir)) != "") {
+ while (!(parent_dir = utils::file::FileUtils::get_parent_path(parent_dir)).empty()) {
parent_dirs.push_front(parent_dir);
}
for (const auto& dir : parent_dirs) {
@@ -235,7 +235,8 @@ TEST_CASE_METHOD(ListSFTPTestsFixture, "ListSFTP list one file writes attributes
auto file = src_dir + "/vfs/nifi_test/tstFile.ext";
auto mtime_str = utils::timeutils::getDateTimeStr(std::chrono::time_point_cast<std::chrono::seconds>(utils::file::to_sys(utils::file::last_write_time(file).value())));
- uint64_t uid, gid;
+ uint64_t uid;
+ uint64_t gid;
REQUIRE(true == utils::file::FileUtils::get_uid_gid(file, uid, gid));
uint32_t permissions;
REQUIRE(true == utils::file::FileUtils::get_permissions(file, permissions));
diff --git a/extensions/sftp/tests/PutSFTPTests.cpp b/extensions/sftp/tests/PutSFTPTests.cpp
index 09e3c99f8..4ef70b0a8 100644
--- a/extensions/sftp/tests/PutSFTPTests.cpp
+++ b/extensions/sftp/tests/PutSFTPTests.cpp
@@ -127,7 +127,7 @@ class PutSFTPTestsFixture {
}
// Create source file
- void createFile(const std::string &dir, const std::string& relative_path, const std::string& content) {
+ static void createFile(const std::string &dir, const std::string& relative_path, const std::string& content) {
std::fstream file;
std::stringstream ss;
ss << dir << "/" << relative_path;
diff --git a/extensions/sftp/tests/tools/SFTPTestServer.cpp b/extensions/sftp/tests/tools/SFTPTestServer.cpp
index 98cf0cebc..7d9223f91 100644
--- a/extensions/sftp/tests/tools/SFTPTestServer.cpp
+++ b/extensions/sftp/tests/tools/SFTPTestServer.cpp
@@ -143,7 +143,7 @@ bool SFTPTestServer::stop() {
return true;
}
-uint16_t SFTPTestServer::getPort() {
+uint16_t SFTPTestServer::getPort() const {
return port_;
}
diff --git a/extensions/sftp/tests/tools/SFTPTestServer.h b/extensions/sftp/tests/tools/SFTPTestServer.h
index 326976651..401b89fa4 100644
--- a/extensions/sftp/tests/tools/SFTPTestServer.h
+++ b/extensions/sftp/tests/tools/SFTPTestServer.h
@@ -40,7 +40,7 @@ class SFTPTestServer {
bool start();
bool stop();
- uint16_t getPort();
+ uint16_t getPort() const;
private:
std::shared_ptr<org::apache::nifi::minifi::core::logging::Logger> logger_ = org::apache::nifi::minifi::core::logging::LoggerFactory<SFTPTestServer>::getLogger();
diff --git a/extensions/splunk/QuerySplunkIndexingStatus.cpp b/extensions/splunk/QuerySplunkIndexingStatus.cpp
index 766379bf6..cb2c2b5c9 100644
--- a/extensions/splunk/QuerySplunkIndexingStatus.cpp
+++ b/extensions/splunk/QuerySplunkIndexingStatus.cpp
@@ -128,9 +128,7 @@ bool flowFileAcknowledgementTimedOut(const gsl::not_null<std::shared_ptr<core::F
if (!splunk_response_time_str.has_value())
return true;
uint64_t splunk_response_time = std::stoull(splunk_response_time_str.value());
- if (system_clock::now() > std::chrono::system_clock::time_point() + std::chrono::milliseconds(splunk_response_time) + max_age)
- return true;
- return false;
+ return system_clock::now() > std::chrono::system_clock::time_point() + std::chrono::milliseconds(splunk_response_time) + max_age;
}
void routeFlowFilesBasedOnIndexingStatus(core::ProcessSession& session,
diff --git a/extensions/splunk/SplunkHECProcessor.cpp b/extensions/splunk/SplunkHECProcessor.cpp
index 344a5b401..4d5684c45 100644
--- a/extensions/splunk/SplunkHECProcessor.cpp
+++ b/extensions/splunk/SplunkHECProcessor.cpp
@@ -45,7 +45,7 @@ std::string SplunkHECProcessor::getNetworkLocation() const {
return hostname_ + ":" + port_;
}
-std::shared_ptr<minifi::controllers::SSLContextService> SplunkHECProcessor::getSSLContextService(core::ProcessContext& context) const {
+std::shared_ptr<minifi::controllers::SSLContextService> SplunkHECProcessor::getSSLContextService(core::ProcessContext& context) {
std::string context_name;
if (context.getProperty(SSLContext.getName(), context_name) && !IsNullOrEmpty(context_name))
return std::dynamic_pointer_cast<minifi::controllers::SSLContextService>(context.getControllerService(context_name));
diff --git a/extensions/splunk/SplunkHECProcessor.h b/extensions/splunk/SplunkHECProcessor.h
index 14cf45833..af1ec6e28 100644
--- a/extensions/splunk/SplunkHECProcessor.h
+++ b/extensions/splunk/SplunkHECProcessor.h
@@ -56,7 +56,7 @@ class SplunkHECProcessor : public core::Processor {
protected:
std::string getNetworkLocation() const;
- std::shared_ptr<minifi::controllers::SSLContextService> getSSLContextService(core::ProcessContext& context) const;
+ static std::shared_ptr<minifi::controllers::SSLContextService> getSSLContextService(core::ProcessContext& context);
void initializeClient(utils::HTTPClient& client, const std::string &url, const std::shared_ptr<minifi::controllers::SSLContextService> ssl_context_service) const;
std::string token_;
diff --git a/extensions/sql/data/JSONSQLWriter.h b/extensions/sql/data/JSONSQLWriter.h
index f01f30409..e4e9af433 100644
--- a/extensions/sql/data/JSONSQLWriter.h
+++ b/extensions/sql/data/JSONSQLWriter.h
@@ -52,7 +52,7 @@ private:
void processColumn(const std::string& name, unsigned long long value) override;
void processColumn(const std::string& name, const char* value) override;
- void addToJSONRow(const std::string& columnName, rapidjson::Value&& jsonValue);
+ void addToJSONRow(const std::string& column_name, rapidjson::Value&& json_value);
rapidjson::Value toJSONString(const std::string& s);
diff --git a/extensions/sql/data/SQLRowsetProcessor.h b/extensions/sql/data/SQLRowsetProcessor.h
index 5f52c4216..de163a254 100644
--- a/extensions/sql/data/SQLRowsetProcessor.h
+++ b/extensions/sql/data/SQLRowsetProcessor.h
@@ -31,7 +31,7 @@ namespace sql {
class SQLRowsetProcessor {
public:
- SQLRowsetProcessor(std::unique_ptr<Rowset> rowset, std::vector<std::reference_wrapper<SQLRowSubscriber>> rowSubscribers);
+ SQLRowsetProcessor(std::unique_ptr<Rowset> rowset, std::vector<std::reference_wrapper<SQLRowSubscriber>> row_subscribers);
size_t process(size_t max);
diff --git a/extensions/sql/processors/QueryDatabaseTable.cpp b/extensions/sql/processors/QueryDatabaseTable.cpp
index 618c6e659..940bf1545 100644
--- a/extensions/sql/processors/QueryDatabaseTable.cpp
+++ b/extensions/sql/processors/QueryDatabaseTable.cpp
@@ -82,7 +82,7 @@ void QueryDatabaseTable::processOnSchedule(core::ProcessContext& context) {
max_value_columns_.clear();
for (auto&& raw_col : utils::StringUtils::splitAndTrimRemovingEmpty(context.getProperty(MaxValueColumnNames).value_or(""), ",")) {
sql::SQLColumnIdentifier col_id(raw_col);
- if (!queried_columns_.empty() && return_columns_.count(col_id) == 0) {
+ if (!queried_columns_.empty() && !return_columns_.contains(col_id)) {
// columns will be explicitly enumerated, we need to add the max value columns as it is not yet queried
queried_columns_ += ", ";
queried_columns_ += raw_col;
@@ -105,7 +105,7 @@ void QueryDatabaseTable::processOnTrigger(core::ProcessContext& /*context*/, cor
std::unordered_map<sql::SQLColumnIdentifier, std::string> new_max_values = max_values_;
sql::MaxCollector maxCollector{selectQuery, new_max_values};
auto column_filter = [&] (const std::string& column_name) {
- return return_columns_.empty() || return_columns_.count(sql::SQLColumnIdentifier(column_name)) != 0;
+ return return_columns_.empty() || return_columns_.contains(sql::SQLColumnIdentifier(column_name));
};
sql::JSONSQLWriter json_writer{output_format_ == OutputType::JSONPretty, column_filter};
FlowFileGenerator flow_file_creator{session, json_writer};
@@ -134,7 +134,7 @@ void QueryDatabaseTable::processOnTrigger(core::ProcessContext& /*context*/, cor
bool QueryDatabaseTable::loadMaxValuesFromStoredState(const std::unordered_map<std::string, std::string> &state) {
std::unordered_map<sql::SQLColumnIdentifier, std::string> new_max_values;
- if (state.count(TABLENAME_KEY) == 0) {
+ if (!state.contains(TABLENAME_KEY)) {
logger_->log_info("State does not specify the table name.");
return false;
}
diff --git a/extensions/sql/services/DatabaseService.cpp b/extensions/sql/services/DatabaseService.cpp
index 6ad209624..434e57a0b 100644
--- a/extensions/sql/services/DatabaseService.cpp
+++ b/extensions/sql/services/DatabaseService.cpp
@@ -21,7 +21,6 @@
#include <memory>
#include <set>
#include "DatabaseService.h"
-#include "DatabaseService.h"
#include "io/validation.h"
#include "properties/Configure.h"
diff --git a/extensions/standard-processors/controllers/UnorderedMapPersistableKeyValueStoreService.cpp b/extensions/standard-processors/controllers/UnorderedMapPersistableKeyValueStoreService.cpp
index 5f98b3c03..9bc826f64 100644
--- a/extensions/standard-processors/controllers/UnorderedMapPersistableKeyValueStoreService.cpp
+++ b/extensions/standard-processors/controllers/UnorderedMapPersistableKeyValueStoreService.cpp
@@ -50,8 +50,6 @@ namespace {
namespace org::apache::nifi::minifi::controllers {
-constexpr int UnorderedMapPersistableKeyValueStoreService::FORMAT_VERSION;
-
const core::Property UnorderedMapPersistableKeyValueStoreService::LinkedServices(
core::PropertyBuilder::createProperty("Linked Services")
->withDescription("Referenced Controller Services")
@@ -236,7 +234,8 @@ bool UnorderedMapPersistableKeyValueStoreService::load() {
std::unordered_map<std::string, std::string> map;
std::string line;
while (std::getline(ifs, line)) {
- std::string key, value;
+ std::string key;
+ std::string value;
if (!parseLine(line, key, value)) {
continue;
}
diff --git a/extensions/standard-processors/processors/AttributesToJSON.cpp b/extensions/standard-processors/processors/AttributesToJSON.cpp
index 15fe97529..3c0c76d09 100644
--- a/extensions/standard-processors/processors/AttributesToJSON.cpp
+++ b/extensions/standard-processors/processors/AttributesToJSON.cpp
@@ -29,11 +29,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 AttributesToJSON::AttributesList(
core::PropertyBuilder::createProperty("Attributes List")
@@ -118,7 +114,7 @@ std::optional<std::unordered_set<std::string>> AttributesToJSON::getAttributesTo
return attributes;
}
-void AttributesToJSON::addAttributeToJson(rapidjson::Document& document, const std::string& key, const std::optional<std::string>& value) {
+void AttributesToJSON::addAttributeToJson(rapidjson::Document& document, const std::string& key, const std::optional<std::string>& value) const {
rapidjson::Value json_key(key.c_str(), document.GetAllocator());
rapidjson::Value json_val;
if (value || !null_value_) {
@@ -169,8 +165,4 @@ void AttributesToJSON::onTrigger(core::ProcessContext* /*context*/, core::Proces
REGISTER_RESOURCE(AttributesToJSON, Processor);
-} // namespace processors
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/standard-processors/processors/AttributesToJSON.h b/extensions/standard-processors/processors/AttributesToJSON.h
index 3116b7cc0..b20f0e3a2 100644
--- a/extensions/standard-processors/processors/AttributesToJSON.h
+++ b/extensions/standard-processors/processors/AttributesToJSON.h
@@ -88,7 +88,7 @@ class AttributesToJSON : public core::Processor {
private:
bool isCoreAttributeToBeFiltered(const std::string& attribute) const;
std::optional<std::unordered_set<std::string>> getAttributesToBeWritten(const core::FlowFile::AttributeMap& flowfile_attributes) const;
- void addAttributeToJson(rapidjson::Document& document, const std::string& key, const std::optional<std::string>& value);
+ void addAttributeToJson(rapidjson::Document& document, const std::string& key, const std::optional<std::string>& value) const;
std::string buildAttributeJsonData(const core::FlowFile::AttributeMap& flowfile_attributes);
std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<AttributesToJSON>::getLogger();
diff --git a/extensions/standard-processors/processors/DefragmentText.cpp b/extensions/standard-processors/processors/DefragmentText.cpp
index d4f94046f..18d83f65e 100644
--- a/extensions/standard-processors/processors/DefragmentText.cpp
+++ b/extensions/standard-processors/processors/DefragmentText.cpp
@@ -143,8 +143,10 @@ void DefragmentText::processNextFragment(core::ProcessSession *session, const gs
void DefragmentText::updateAttributesForSplitFiles(const core::FlowFile& original_flow_file,
const std::shared_ptr<core::FlowFile>& split_before_last_pattern,
const std::shared_ptr<core::FlowFile>& split_after_last_pattern,
- const size_t split_position) const {
- std::string base_name, post_name, offset_str;
+ const size_t split_position) {
+ std::string base_name;
+ std::string post_name;
+ std::string offset_str;
if (!original_flow_file.getAttribute(textfragmentutils::BASE_NAME_ATTRIBUTE, base_name))
return;
if (!original_flow_file.getAttribute(textfragmentutils::POST_NAME_ATTRIBUTE, post_name))
@@ -167,7 +169,9 @@ void DefragmentText::updateAttributesForSplitFiles(const core::FlowFile& origina
namespace {
void updateAppendedAttributes(core::FlowFile& buffered_ff) {
- std::string base_name, post_name, offset_str;
+ std::string base_name;
+ std::string post_name;
+ std::string offset_str;
if (!buffered_ff.getAttribute(textfragmentutils::BASE_NAME_ATTRIBUTE, base_name))
return;
if (!buffered_ff.getAttribute(textfragmentutils::POST_NAME_ATTRIBUTE, post_name))
diff --git a/extensions/standard-processors/processors/DefragmentText.h b/extensions/standard-processors/processors/DefragmentText.h
index 071eb2867..3ec22eb0a 100644
--- a/extensions/standard-processors/processors/DefragmentText.h
+++ b/extensions/standard-processors/processors/DefragmentText.h
@@ -133,10 +133,10 @@ class DefragmentText : public core::Processor {
std::shared_ptr<core::FlowFile> &split_before_last_pattern,
std::shared_ptr<core::FlowFile> &split_after_last_pattern) const;
- void updateAttributesForSplitFiles(const core::FlowFile &original_flow_file,
- const std::shared_ptr<core::FlowFile> &split_before_last_pattern,
- const std::shared_ptr<core::FlowFile> &split_after_last_pattern,
- const size_t split_position) const;
+ static void updateAttributesForSplitFiles(const core::FlowFile &original_flow_file,
+ const std::shared_ptr<core::FlowFile> &split_before_last_pattern,
+ const std::shared_ptr<core::FlowFile> &split_after_last_pattern,
+ const size_t split_position);
};
diff --git a/extensions/standard-processors/processors/ExtractText.cpp b/extensions/standard-processors/processors/ExtractText.cpp
index dc7be63e8..68450057b 100644
--- a/extensions/standard-processors/processors/ExtractText.cpp
+++ b/extensions/standard-processors/processors/ExtractText.cpp
@@ -101,7 +101,8 @@ int64_t ExtractText::ReadCallback::operator()(const std::shared_ptr<io::BaseStre
std::vector<std::byte> buffer;
buffer.resize(std::min(gsl::narrow<size_t>(flowFile_->getSize()), MAX_BUFFER_SIZE));
- std::string attrKey, sizeLimitStr;
+ std::string attrKey;
+ std::string sizeLimitStr;
ctx_->getProperty(Attribute.getName(), attrKey);
ctx_->getProperty(SizeLimit.getName(), sizeLimitStr);
ctx_->getProperty(RegexMode.getName(), regex_mode);
diff --git a/extensions/standard-processors/processors/FetchFile.cpp b/extensions/standard-processors/processors/FetchFile.cpp
index b50afd420..cf18ebeae 100644
--- a/extensions/standard-processors/processors/FetchFile.cpp
+++ b/extensions/standard-processors/processors/FetchFile.cpp
@@ -103,7 +103,7 @@ void FetchFile::onSchedule(const std::shared_ptr<core::ProcessContext> &context,
log_level_when_permission_denied_ = utils::parseEnumProperty<LogLevelOption>(*context, LogLevelWhenPermissionDenied);
}
-std::filesystem::path FetchFile::getFileToFetch(core::ProcessContext& context, const std::shared_ptr<core::FlowFile>& flow_file) const {
+std::filesystem::path FetchFile::getFileToFetch(core::ProcessContext& context, const std::shared_ptr<core::FlowFile>& flow_file) {
std::string file_to_fetch_path;
context.getProperty(FileToFetch, file_to_fetch_path, flow_file);
if (!file_to_fetch_path.empty()) {
@@ -215,9 +215,9 @@ void FetchFile::onTrigger(const std::shared_ptr<core::ProcessContext> &context,
return;
}
- std::string path;
+ std::string file_path;
std::string file_name;
- utils::file::getFileNameAndPath(file_fetch_path_str, path, file_name);
+ utils::file::getFileNameAndPath(file_fetch_path_str, file_path, file_name);
context->getProperty(MoveDestinationDirectory, move_destination_directory_, flow_file);
if (moveWouldFailWithDestinationConflict(file_name)) {
diff --git a/extensions/standard-processors/processors/FetchFile.h b/extensions/standard-processors/processors/FetchFile.h
index 7eda55d3e..e0f09f69c 100644
--- a/extensions/standard-processors/processors/FetchFile.h
+++ b/extensions/standard-processors/processors/FetchFile.h
@@ -103,7 +103,7 @@ class FetchFile : public core::Processor {
template<typename... Args>
void logWithLevel(LogLevelOption log_level, Args&&... args) const;
- std::filesystem::path getFileToFetch(core::ProcessContext& context, const std::shared_ptr<core::FlowFile>& flow_file) const;
+ static std::filesystem::path getFileToFetch(core::ProcessContext& context, const std::shared_ptr<core::FlowFile>& flow_file);
std::string getMoveAbsolutePath(const std::string& file_name) const;
bool moveDestinationConflicts(const std::string& file_name) const;
bool moveWouldFailWithDestinationConflict(const std::string& file_name) const;
diff --git a/extensions/standard-processors/processors/PutFile.cpp b/extensions/standard-processors/processors/PutFile.cpp
index 194ddf223..caa58d235 100644
--- a/extensions/standard-processors/processors/PutFile.cpp
+++ b/extensions/standard-processors/processors/PutFile.cpp
@@ -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 {
std::shared_ptr<utils::IdGenerator> PutFile::id_generator_ = utils::IdGenerator::getIdGenerator();
@@ -172,7 +168,7 @@ void PutFile::onTrigger(core::ProcessContext *context, core::ProcessSession *ses
}
}
-std::string PutFile::tmpWritePath(const std::string &filename, const std::string &directory) const {
+std::string PutFile::tmpWritePath(const std::string &filename, const std::string &directory) {
utils::Identifier tmpFileUuid = id_generator_->generate();
std::stringstream tmpFileSs;
tmpFileSs << directory;
@@ -265,7 +261,7 @@ void PutFile::getPermissions(core::ProcessContext *context) {
}
try {
- permissions_.setValue(std::stoi(permissions_str, 0, 8));
+ permissions_.setValue(std::stoi(permissions_str, nullptr, 8));
} catch(const std::exception&) {
throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Permissions property is invalid");
}
@@ -283,7 +279,7 @@ void PutFile::getDirectoryPermissions(core::ProcessContext *context) {
}
try {
- directory_permissions_.setValue(std::stoi(dir_permissions_str, 0, 8));
+ directory_permissions_.setValue(std::stoi(dir_permissions_str, nullptr, 8));
} catch(const std::exception&) {
throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Directory Permissions property is invalid");
}
@@ -354,8 +350,4 @@ PutFile::ReadCallback::~ReadCallback() {
REGISTER_RESOURCE(PutFile, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/standard-processors/processors/PutFile.h b/extensions/standard-processors/processors/PutFile.h
index 3edaa02f8..ae295dcd4 100644
--- a/extensions/standard-processors/processors/PutFile.h
+++ b/extensions/standard-processors/processors/PutFile.h
@@ -108,7 +108,7 @@ class PutFile : public core::Processor {
* @param filename from which to generate temporary write file path
* @return
*/
- std::string tmpWritePath(const std::string &filename, const std::string &directory) const;
+ static std::string tmpWritePath(const std::string &filename, const std::string &directory);
private:
std::string conflict_resolution_;
diff --git a/extensions/standard-processors/processors/TailFile.cpp b/extensions/standard-processors/processors/TailFile.cpp
index 2017206af..6c614fd9c 100644
--- a/extensions/standard-processors/processors/TailFile.cpp
+++ b/extensions/standard-processors/processors/TailFile.cpp
@@ -50,11 +50,7 @@
#include "core/Resource.h"
#include "utils/RegexUtils.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
const core::Property TailFile::FileName(
core::PropertyBuilder::createProperty("File to Tail")
@@ -383,7 +379,8 @@ void TailFile::onSchedule(const std::shared_ptr<core::ProcessContext> &context,
} else {
tail_mode_ = Mode::SINGLE;
- std::string path, file_name;
+ std::string path;
+ std::string file_name;
if (utils::file::getFileNameAndPath(file_to_tail_, path, file_name)) {
// NOTE: position and checksum will be updated in recoverState() if there is a persisted state for this file
tail_states_.emplace(file_to_tail_, TailState{path, file_name});
@@ -453,7 +450,8 @@ void TailFile::parseStateFileLine(char *buf, std::map<std::string, TailState> &s
value = utils::StringUtils::trimRight(value);
if (key == "FILENAME") {
- std::string fileLocation, fileName;
+ std::string fileLocation;
+ std::string fileName;
if (utils::file::getFileNameAndPath(value, fileLocation, fileName)) {
logger_->log_debug("State migration received path %s, file %s", fileLocation, fileName);
state.emplace(fileName, TailState{fileLocation, fileName});
@@ -472,7 +470,8 @@ void TailFile::parseStateFileLine(char *buf, std::map<std::string, TailState> &s
}
if (key.find(CURRENT_STR) == 0) {
const auto file = key.substr(strlen(CURRENT_STR));
- std::string fileLocation, fileName;
+ std::string fileLocation;
+ std::string fileName;
if (utils::file::getFileNameAndPath(value, fileLocation, fileName)) {
state[file].path_ = fileLocation;
state[file].file_name_ = fileName;
@@ -531,7 +530,8 @@ bool TailFile::getStateFromStateManager(std::map<std::string, TailState> &new_ta
readOptionalInt64(state_map, "file." + std::to_string(i) + ".last_read_time")
}};
- std::string fileLocation, fileName;
+ std::string fileLocation;
+ std::string fileName;
if (utils::file::getFileNameAndPath(current, fileLocation, fileName)) {
logger_->log_debug("Received path %s, file %s", fileLocation, fileName);
new_tail_states.emplace(current, TailState{fileLocation, fileName, position, last_read_time, checksum});
@@ -661,7 +661,7 @@ std::vector<TailState> TailFile::findRotatedFilesAfterLastReadTime(const TailSta
return sortAndSkipMainFilePrefix(state, matched_files_with_mtime);
}
-std::vector<TailState> TailFile::sortAndSkipMainFilePrefix(const TailState &state, std::vector<TailStateWithMtime>& matched_files_with_mtime) const {
+std::vector<TailState> TailFile::sortAndSkipMainFilePrefix(const TailState &state, std::vector<TailStateWithMtime>& matched_files_with_mtime) {
const auto first_by_mtime_then_by_name = [](const auto& left, const auto& right) {
return std::tie(left.mtime_, left.tail_state_.file_name_) <
std::tie(right.mtime_, right.tail_state_.file_name_);
@@ -766,7 +766,7 @@ void TailFile::processSingleFile(const std::shared_ptr<core::ProcessSession> &se
TailState &state) {
std::string fileName = state.file_name_;
- if (utils::file::file_size(full_file_name) == 0u) {
+ if (utils::file::file_size(full_file_name) == 0U) {
logger_->log_warn("Unable to read file %s as it does not exist or has size zero", full_file_name);
return;
}
@@ -839,7 +839,7 @@ void TailFile::updateFlowFileAttributes(const std::string &full_file_name, const
}
}
-void TailFile::updateStateAttributes(TailState &state, uint64_t size, uint64_t checksum) const {
+void TailFile::updateStateAttributes(TailState &state, uint64_t size, uint64_t checksum) {
state.position_ += size;
state.last_read_time_ = std::chrono::file_clock::now();
state.checksum_ = checksum;
@@ -858,7 +858,7 @@ void TailFile::checkForRemovedFiles() {
const std::string &full_file_name = kv.first;
const TailState &state = kv.second;
utils::Regex pattern_regex(file_to_tail_);
- if (utils::file::file_size(state.fileNameWithPath()) == 0u ||
+ if (utils::file::file_size(state.fileNameWithPath()) == 0U ||
!utils::regexMatch(state.file_name_, pattern_regex)) {
file_names_to_remove.push_back(full_file_name);
}
@@ -897,7 +897,7 @@ void TailFile::checkForNewFiles(core::ProcessContext& context) {
}
}
-std::string TailFile::baseDirectoryFromAttributes(const controllers::AttributeProviderService::AttributeMap& attribute_map, core::ProcessContext& context) const {
+std::string TailFile::baseDirectoryFromAttributes(const controllers::AttributeProviderService::AttributeMap& attribute_map, core::ProcessContext& context) {
auto flow_file = std::make_shared<FlowFileRecord>();
for (const auto& [key, value] : attribute_map) {
flow_file->setAttribute(key, value);
@@ -911,8 +911,4 @@ std::chrono::milliseconds TailFile::getLookupFrequency() const {
REGISTER_RESOURCE(TailFile, Processor);
-} // namespace processors
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::processors
diff --git a/extensions/standard-processors/processors/TailFile.h b/extensions/standard-processors/processors/TailFile.h
index 33ab54420..58a9b1122 100644
--- a/extensions/standard-processors/processors/TailFile.h
+++ b/extensions/standard-processors/processors/TailFile.h
@@ -177,24 +177,24 @@ class TailFile : public core::Processor {
std::string parseRollingFilePattern(const TailState &state) const;
std::vector<TailState> findAllRotatedFiles(const TailState &state) const;
std::vector<TailState> findRotatedFilesAfterLastReadTime(const TailState &state) const;
- std::vector<TailState> sortAndSkipMainFilePrefix(const TailState &state, std::vector<TailStateWithMtime>& matched_files_with_mtime) const;
+ static std::vector<TailState> sortAndSkipMainFilePrefix(const TailState &state, std::vector<TailStateWithMtime>& matched_files_with_mtime);
void processFile(const std::shared_ptr<core::ProcessSession> &session,
const std::string &full_file_name,
TailState &state);
void processSingleFile(const std::shared_ptr<core::ProcessSession> &session,
const std::string &full_file_name,
TailState &state);
- bool getStateFromStateManager(std::map<std::string, TailState> &state) const;
+ bool getStateFromStateManager(std::map<std::string, TailState> &new_tail_states) const;
bool getStateFromLegacyStateFile(const std::shared_ptr<core::ProcessContext>& context,
std::map<std::string, TailState> &new_tail_states) const;
void doMultifileLookup(core::ProcessContext& context);
void checkForRemovedFiles();
void checkForNewFiles(core::ProcessContext& context);
- std::string baseDirectoryFromAttributes(const controllers::AttributeProviderService::AttributeMap& attribute_map, core::ProcessContext& context) const;
+ static std::string baseDirectoryFromAttributes(const controllers::AttributeProviderService::AttributeMap& attribute_map, core::ProcessContext& context);
void updateFlowFileAttributes(const std::string &full_file_name, const TailState &state, const std::string &fileName,
const std::string &baseName, const std::string &extension,
std::shared_ptr<core::FlowFile> &flow_file) const;
- void updateStateAttributes(TailState &state, uint64_t size, uint64_t checksum) const;
+ static void updateStateAttributes(TailState &state, uint64_t size, uint64_t checksum);
bool isOldFileInitiallyRead(TailState &state) const;
static const char *CURRENT_STR;
diff --git a/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp b/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp
index f71538e76..bdbac9e28 100644
--- a/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp
+++ b/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp
@@ -138,7 +138,8 @@ static void sigpipe_handle(int /*x*/) {
}
int main(int argc, char **argv) {
- std::string key_dir, test_file_location;
+ std::string key_dir;
+ std::string test_file_location;
if (argc > 1) {
test_file_location = argv[1];
key_dir = argv[2];
diff --git a/extensions/standard-processors/tests/integration/TLSClientSocketSupportedProtocolsTest.cpp b/extensions/standard-processors/tests/integration/TLSClientSocketSupportedProtocolsTest.cpp
index 711db9253..0f15a33d0 100644
--- a/extensions/standard-processors/tests/integration/TLSClientSocketSupportedProtocolsTest.cpp
+++ b/extensions/standard-processors/tests/integration/TLSClientSocketSupportedProtocolsTest.cpp
@@ -100,11 +100,10 @@ class TLSClientSocketSupportedProtocolsTest {
assert(server.hadConnection() == should_be_compatible);
}
- protected:
- std::unique_ptr<minifi::io::TLSSocket> client_socket_;
- std::string host_;
- std::filesystem::path key_dir_;
- std::shared_ptr<minifi::Configure> configuration_;
+ std::unique_ptr<minifi::io::TLSSocket> client_socket_;
+ std::string host_;
+ std::filesystem::path key_dir_;
+ std::shared_ptr<minifi::Configure> configuration_;
};
static void sigpipe_handle(int) {
diff --git a/extensions/standard-processors/tests/unit/AttributesToJSONTests.cpp b/extensions/standard-processors/tests/unit/AttributesToJSONTests.cpp
index 96644997b..4a08fcc20 100644
--- a/extensions/standard-processors/tests/unit/AttributesToJSONTests.cpp
+++ b/extensions/standard-processors/tests/unit/AttributesToJSONTests.cpp
@@ -64,7 +64,7 @@ class AttributesToJSONTestFixture {
utils::putFileToDir(dir_, TEST_FILE_NAME, TEST_FILE_CONTENT);
}
- void assertJSONAttributesFromLog(const std::unordered_map<std::string, std::optional<std::string>>& expected_attributes) {
+ static void assertJSONAttributesFromLog(const std::unordered_map<std::string, std::optional<std::string>>& expected_attributes) {
auto match = LogTestController::getInstance().matchesRegex("key:JSONAttributes value:(.*)");
REQUIRE(match);
assertAttributes(expected_attributes, (*match)[1].str());
@@ -76,7 +76,7 @@ class AttributesToJSONTestFixture {
assertAttributes(expected_attributes, file_contents[0]);
}
- void assertAttributes(const std::unordered_map<std::string, std::optional<std::string>>& expected_attributes, const std::string& output_json) {
+ static void assertAttributes(const std::unordered_map<std::string, std::optional<std::string>>& expected_attributes, const std::string& output_json) {
rapidjson::Document root;
rapidjson::ParseResult ok = root.Parse(output_json.c_str());
REQUIRE(ok);
diff --git a/extensions/standard-processors/tests/unit/GenerateFlowFileTests.cpp b/extensions/standard-processors/tests/unit/GenerateFlowFileTests.cpp
index 8f048c8de..ededc9da4 100644
--- a/extensions/standard-processors/tests/unit/GenerateFlowFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/GenerateFlowFileTests.cpp
@@ -104,12 +104,12 @@ TEST_CASE("GenerateFlowFileWithNonUniqueBinaryData", "[generateflowfiletest]") {
std::ifstream is(path + utils::file::get_separator() + filename, std::ifstream::binary);
is.seekg(0, is.end);
- size_t length = gsl::narrow<size_t>(is.tellg());
+ auto length = gsl::narrow<size_t>(is.tellg());
is.seekg(0, is.beg);
std::vector<char> content(length);
- is.read(&content[0], length);
+ is.read(content.data(), length);
fileContents.push_back(std::move(content));
diff --git a/extensions/standard-processors/tests/unit/GetFileTests.cpp b/extensions/standard-processors/tests/unit/GetFileTests.cpp
index 561f7d29d..d454bca08 100644
--- a/extensions/standard-processors/tests/unit/GetFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/GetFileTests.cpp
@@ -40,11 +40,13 @@ namespace {
class GetFileTestController {
public:
GetFileTestController();
- [[nodiscard]] std::string getFullPath(const std::string filename) 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();
+ void resetTestPlan();
+ private:
TestController test_controller_;
std::shared_ptr<TestPlan> test_plan_;
std::string temp_dir_;
@@ -82,7 +84,7 @@ GetFileTestController::GetFileTestController()
#endif
}
-std::string GetFileTestController::getFullPath(const std::string filename) const {
+std::string GetFileTestController::getFullPath(const std::string& filename) const {
return temp_dir_ + utils::file::FileUtils::get_separator() + filename;
}
@@ -91,13 +93,17 @@ std::string GetFileTestController::getInputFilePath() const {
}
void GetFileTestController::setProperty(const core::Property& property, const std::string& value) {
- test_plan_->setProperty(get_file_processor_, property.getName(), value);
+ test_plan_->setProperty(get_file_processor_, property.getName(), value);
}
void GetFileTestController::runSession() {
test_controller_.runSession(test_plan_);
}
+void GetFileTestController::resetTestPlan() {
+ test_plan_->reset();
+}
+
} // namespace
TEST_CASE("GetFile ignores hidden files and files larger than MaxSize", "[GetFile]") {
@@ -129,7 +135,7 @@ TEST_CASE("GetFile ignores files smaller than MinSize", "[GetFile]") {
TEST_CASE("GetFile onSchedule() throws if the required Directory property is not set", "[GetFile]") {
GetFileTestController test_controller;
test_controller.setProperty(minifi::processors::GetFile::Directory, "");
- REQUIRE_THROWS_AS(test_controller.test_plan_->runNextProcessor(), minifi::Exception);
+ REQUIRE_THROWS_AS(test_controller.runSession(), minifi::Exception);
}
TEST_CASE("GetFile removes the source file if KeepSourceFile is false") {
@@ -254,7 +260,7 @@ TEST_CASE("Test if GetFile honors PollInterval property when triggered multiple
auto start_time = std::chrono::steady_clock::now();
test_controller.runSession();
while (LogTestController::getInstance().countOccurrences("Logged 2 flow files") < 2) {
- test_controller.test_plan_->reset();
+ test_controller.resetTestPlan();
test_controller.runSession();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
diff --git a/extensions/standard-processors/tests/unit/ProcessorTests.cpp b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
index 0c4001f38..fe00f439c 100644
--- a/extensions/standard-processors/tests/unit/ProcessorTests.cpp
+++ b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
@@ -231,7 +231,7 @@ TEST_CASE("Test GetFile Ignore", "[getfileCreate3]") {
session->commit();
std::shared_ptr<core::FlowFile> ffr = session->get();
- REQUIRE(repo->getRepoMap().size() == 0);
+ REQUIRE(repo->getRepoMap().empty());
prev++;
}
@@ -304,7 +304,7 @@ TEST_CASE("LogAttributeTest", "[getfileCreate3]") {
auto records = plan->getProvenanceRecords();
std::shared_ptr<core::FlowFile> record = plan->getCurrentFlowFile();
REQUIRE(record == nullptr);
- REQUIRE(records.size() == 0);
+ REQUIRE(records.empty());
std::fstream file;
std::stringstream ss;
@@ -370,7 +370,7 @@ void testMultiplesLogAttribute(int fileCount, int flowsToLog, std::string verify
auto records = plan->getProvenanceRecords();
std::shared_ptr<core::FlowFile> record = plan->getCurrentFlowFile();
REQUIRE(record == nullptr);
- REQUIRE(records.size() == 0);
+ REQUIRE(records.empty());
std::vector<std::string> files;
@@ -432,7 +432,7 @@ TEST_CASE("Test Find file", "[getfileCreate3]") {
auto records = plan->getProvenanceRecords();
std::shared_ptr<core::FlowFile> record = plan->getCurrentFlowFile();
REQUIRE(record == nullptr);
- REQUIRE(records.size() == 0);
+ REQUIRE(records.empty());
std::fstream file;
std::stringstream ss;
diff --git a/extensions/standard-processors/tests/unit/RetryFlowFileTests.cpp b/extensions/standard-processors/tests/unit/RetryFlowFileTests.cpp
index 1729b665e..552c414b7 100644
--- a/extensions/standard-processors/tests/unit/RetryFlowFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/RetryFlowFileTests.cpp
@@ -162,17 +162,17 @@ class RetryFlowFileTest {
REQUIRE(expect_warning_on_reuse == retryFlowfileWarnedForReuse());
}
- bool logContainsText(const std::string pattern) {
+ static bool logContainsText(const std::string pattern) {
const std::string logs = LogTestController::getInstance().log_output.str();
return logs.find(pattern) != std::string::npos;
}
- bool flowfileWasPenalizedARetryflowfile() {
+ static bool flowfileWasPenalizedARetryflowfile() {
std::regex re(R"(\[org::apache::nifi::minifi::core::ProcessSession\] \[info\] Penalizing [0-9a-z\-]+ for [0-9]*ms at retryflowfile)");
return std::regex_search(LogTestController::getInstance().log_output.str(), re);
}
- bool retryFlowfileWarnedForReuse() {
+ static bool retryFlowfileWarnedForReuse() {
const std::string pattern = "[org::apache::nifi::minifi::processors::RetryFlowFile] [warning] Reusing retry attribute that belongs to different processor. Resetting value to 0.";
return logContainsText(pattern);
}
diff --git a/extensions/standard-processors/tests/unit/RouteTextTests.cpp b/extensions/standard-processors/tests/unit/RouteTextTests.cpp
index b59159cad..914925539 100644
--- a/extensions/standard-processors/tests/unit/RouteTextTests.cpp
+++ b/extensions/standard-processors/tests/unit/RouteTextTests.cpp
@@ -99,13 +99,13 @@ struct RouteTextController : public TestController {
}
}
- void run() {
+ void run() const {
while (!input_->isEmpty()) {
plan_->runProcessor(proc_);
}
}
- void putFlowFile(const std::map<std::string, std::string>& attributes, const std::string& content) {
+ void putFlowFile(const std::map<std::string, std::string>& attributes, const std::string& content) const {
auto flow_file = std::make_shared<minifi::FlowFileRecord>();
for (const auto& attr : attributes) {
flow_file->setAttribute(attr.first, attr.second);
diff --git a/extensions/standard-processors/tests/unit/TailFileTests.cpp b/extensions/standard-processors/tests/unit/TailFileTests.cpp
index 1ecc68785..1bd4319a5 100644
--- a/extensions/standard-processors/tests/unit/TailFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/TailFileTests.cpp
@@ -239,7 +239,8 @@ TEST_CASE("TailFile picks up the state correctly if it is rewritten between runs
testController.runSession(plan, true);
REQUIRE(LogTestController::getInstance().contains("key:filename value:minifi-tmpfile.0-13.txt"));
- std::string filePath, fileName;
+ std::string filePath;
+ std::string fileName;
REQUIRE(utils::file::getFileNameAndPath(temp_file.str(), filePath, fileName));
// should stay the same
@@ -319,7 +320,8 @@ TEST_CASE("TailFile converts the old-style state file to the new-style state", "
std::unordered_map<std::string, std::string> state;
REQUIRE(plan->getProcessContextForProcessor(tailfile)->getStateManager()->get(state));
- std::string filePath, fileName;
+ std::string filePath;
+ std::string fileName;
REQUIRE(utils::file::getFileNameAndPath(temp_file, filePath, fileName));
std::unordered_map<std::string, std::string> expected_state{{"file.0.name", fileName},
{"file.0.position", "35"},
@@ -363,7 +365,10 @@ TEST_CASE("TailFile converts the old-style state file to the new-style state", "
std::unordered_map<std::string, std::string> state;
REQUIRE(plan->getProcessContextForProcessor(tailfile)->getStateManager()->get(state));
- std::string filePath1, filePath2, fileName1, fileName2;
+ std::string filePath1;
+ std::string filePath2;
+ std::string fileName1;
+ std::string fileName2;
REQUIRE(utils::file::getFileNameAndPath(temp_file_1, filePath1, fileName1));
REQUIRE(utils::file::getFileNameAndPath(temp_file_2, filePath2, fileName2));
std::unordered_map<std::string, std::string> expected_state{{"file.0.name", fileName1},
diff --git a/extensions/systemd/ConsumeJournald.cpp b/extensions/systemd/ConsumeJournald.cpp
index ec7a0fe55..979cadbaf 100644
--- a/extensions/systemd/ConsumeJournald.cpp
+++ b/extensions/systemd/ConsumeJournald.cpp
@@ -29,11 +29,10 @@
#include "core/PropertyBuilder.h"
#include "core/Resource.h"
-namespace org { namespace apache { namespace nifi { namespace minifi { namespace extensions { namespace systemd {
+namespace org::apache::nifi::minifi::extensions::systemd {
namespace chr = std::chrono;
-constexpr const char* ConsumeJournald::CURSOR_KEY;
const core::Relationship ConsumeJournald::Success("success", "Successfully consumed journal messages.");
const core::Property ConsumeJournald::BatchSize = core::PropertyBuilder::createProperty("Batch Size")
@@ -270,9 +269,4 @@ std::string ConsumeJournald::getCursor() const {
REGISTER_RESOURCE(ConsumeJournald, Processor);
-} // namespace systemd
-} // namespace extensions
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::extensions::systemd
diff --git a/extensions/usb-camera/GetUSBCamera.cpp b/extensions/usb-camera/GetUSBCamera.cpp
index e3a42daf9..98e4204e0 100644
--- a/extensions/usb-camera/GetUSBCamera.cpp
+++ b/extensions/usb-camera/GetUSBCamera.cpp
@@ -30,11 +30,7 @@
#include "core/ProcessSessionFactory.h"
#include "core/Resource.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace processors {
+namespace org::apache::nifi::minifi::processors {
const core::Property GetUSBCamera::FPS(
"FPS", "Frames per second to capture from USB camera", "1");
@@ -433,7 +429,7 @@ int64_t GetUSBCamera::PNGWriteCallback::operator()(const std::shared_ptr<io::Bas
row_pointers[y] = reinterpret_cast<png_byte *>(frame_->data) + width_ * y * 3;
}
- png_write_image(png, &row_pointers[0]);
+ png_write_image(png, row_pointers.data());
png_write_end(png, nullptr);
png_destroy_write_struct(&png, &info);
@@ -450,8 +446,4 @@ int64_t GetUSBCamera::PNGWriteCallback::operator()(const std::shared_ptr<io::Bas
REGISTER_RESOURCE(GetUSBCamera, Processor);
-} /* namespace processors */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::processors
diff --git a/libminifi/include/FlowControlProtocol.h b/libminifi/include/FlowControlProtocol.h
index 7c5f3b877..f0b762c68 100644
--- a/libminifi/include/FlowControlProtocol.h
+++ b/libminifi/include/FlowControlProtocol.h
@@ -210,13 +210,13 @@ class FlowControlProtocol {
private:
// Connect to the socket, return sock descriptor if success, 0 for failure
- int connectServer(const char *host, uint16_t port);
+ static int connectServer(const char *host, uint16_t port);
// Send Data via the socket, return -1 for failure
- int sendData(uint8_t *buf, int buflen);
+ static int sendData(uint8_t *buf, int buflen);
// Read length into buf, return -1 for failure and 0 for EOF
int readData(uint8_t *buf, int buflen);
// Select on the socket
- int selectClient(int msec);
+ int selectClient(int msec) const;
// Read the header
int readHdr(FlowControlProtocolHeader *hdr);
// encode uint32_t
diff --git a/libminifi/include/ResourceClaim.h b/libminifi/include/ResourceClaim.h
index 95b42fc58..ea0474306 100644
--- a/libminifi/include/ResourceClaim.h
+++ b/libminifi/include/ResourceClaim.h
@@ -57,7 +57,7 @@ class ResourceClaim {
explicit ResourceClaim(std::shared_ptr<core::StreamManager<ResourceClaim>> claim_manager);
- explicit ResourceClaim(const Path& path, std::shared_ptr<core::StreamManager<ResourceClaim>> claim_manager);
+ explicit ResourceClaim(Path path, std::shared_ptr<core::StreamManager<ResourceClaim>> claim_manager);
// Destructor
~ResourceClaim();
diff --git a/libminifi/include/c2/C2Agent.h b/libminifi/include/c2/C2Agent.h
index f44ee4d23..3a491d1cb 100644
--- a/libminifi/include/c2/C2Agent.h
+++ b/libminifi/include/c2/C2Agent.h
@@ -68,7 +68,7 @@ class C2Agent : public state::UpdateController {
C2Agent(core::controller::ControllerServiceProvider *controller,
state::Pausable *pause_handler,
state::StateMonitor* updateSink,
- std::shared_ptr<Configure> configure,
+ std::shared_ptr<Configure> configuration,
std::shared_ptr<utils::file::FileSystem> filesystem,
std::function<void()> request_restart);
@@ -103,7 +103,7 @@ class C2Agent : public state::UpdateController {
* @param name name of this metric
* @param metrics metrics to include.
*/
- void serializeMetrics(C2Payload &parent_payload, const std::string &name, const std::vector<state::response::SerializedResponseNode> &metrics, bool is_container = false, bool is_collapsible = true);
+ void serializeMetrics(C2Payload &metric_payload, const std::string &name, const std::vector<state::response::SerializedResponseNode> &metrics, bool is_container = false, bool is_collapsible = true);
/**
* Extract the payload
diff --git a/libminifi/include/core/FlowConfiguration.h b/libminifi/include/core/FlowConfiguration.h
index ec278c7a5..e8239034d 100644
--- a/libminifi/include/core/FlowConfiguration.h
+++ b/libminifi/include/core/FlowConfiguration.h
@@ -78,9 +78,9 @@ class FlowConfiguration : public CoreComponent {
std::unique_ptr<core::Processor> createProcessor(const std::string &name, const std::string &fullname, const utils::Identifier &uuid);
// Create Root Processor Group
- std::unique_ptr<core::ProcessGroup> createRootProcessGroup(const std::string &name, const utils::Identifier &uuid, int version);
- std::unique_ptr<core::ProcessGroup> createSimpleProcessGroup(const std::string &name, const utils::Identifier &uuid, int version);
- std::unique_ptr<core::ProcessGroup> createRemoteProcessGroup(const std::string &name, const utils::Identifier &uuid);
+ static std::unique_ptr<core::ProcessGroup> createRootProcessGroup(const std::string &name, const utils::Identifier &uuid, int version);
+ static std::unique_ptr<core::ProcessGroup> createSimpleProcessGroup(const std::string &name, const utils::Identifier &uuid, int version);
+ static std::unique_ptr<core::ProcessGroup> createRemoteProcessGroup(const std::string &name, const utils::Identifier &uuid);
std::shared_ptr<core::controller::ControllerServiceNode> createControllerService(const std::string &class_name, const std::string &full_class_name, const std::string &name,
const utils::Identifier &uuid);
diff --git a/libminifi/include/core/ProcessSession.h b/libminifi/include/core/ProcessSession.h
index 439b23431..9e0a48263 100644
--- a/libminifi/include/core/ProcessSession.h
+++ b/libminifi/include/core/ProcessSession.h
@@ -76,7 +76,7 @@ class ProcessSession : public ReferenceContainer {
// Create a new UUID FlowFile with no content resource claim and inherit all attributes from parent
std::shared_ptr<core::FlowFile> create(const std::shared_ptr<core::FlowFile> &parent = {});
// Add a FlowFile to the session
- virtual void add(const std::shared_ptr<core::FlowFile> &flow);
+ virtual void add(const std::shared_ptr<core::FlowFile> &record);
// Clone a new UUID FlowFile from parent both for content resource claim and attributes
std::shared_ptr<core::FlowFile> clone(const std::shared_ptr<core::FlowFile> &parent);
// Clone a new UUID FlowFile from parent for attributes and sub set of parent content resource claim
diff --git a/libminifi/include/core/logging/Logger.h b/libminifi/include/core/logging/Logger.h
index 24ef90868..29c2a64d3 100644
--- a/libminifi/include/core/logging/Logger.h
+++ b/libminifi/include/core/logging/Logger.h
@@ -136,7 +136,7 @@ class LogBuilder {
void setIgnore();
- void log_string(LOG_LEVEL level);
+ void log_string(LOG_LEVEL level) const;
template<typename T>
LogBuilder &operator<<(const T &o) {
diff --git a/libminifi/include/core/reporting/SiteToSiteProvenanceReportingTask.h b/libminifi/include/core/reporting/SiteToSiteProvenanceReportingTask.h
index f30744ccc..6ac010a2f 100644
--- a/libminifi/include/core/reporting/SiteToSiteProvenanceReportingTask.h
+++ b/libminifi/include/core/reporting/SiteToSiteProvenanceReportingTask.h
@@ -58,7 +58,7 @@ class SiteToSiteProvenanceReportingTask : public minifi::RemoteProcessorGroupPor
public:
//! Get provenance json report
- void getJsonReport(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session, std::vector<std::shared_ptr<core::SerializableComponent>> &records, std::string &report); // NOLINT
+ static void getJsonReport(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session, std::vector<std::shared_ptr<core::SerializableComponent>> &records, std::string &report); // NOLINT
void onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory);
diff --git a/libminifi/include/core/repository/VolatileContentRepository.h b/libminifi/include/core/repository/VolatileContentRepository.h
index 445f482d7..453b1d1ff 100644
--- a/libminifi/include/core/repository/VolatileContentRepository.h
+++ b/libminifi/include/core/repository/VolatileContentRepository.h
@@ -95,7 +95,7 @@ class VolatileContentRepository :
*/
virtual std::shared_ptr<io::BaseStream> read(const minifi::ResourceClaim &claim);
- virtual bool exists(const minifi::ResourceClaim &streamId);
+ virtual bool exists(const minifi::ResourceClaim &claim);
/**
* Closes the claim.
diff --git a/libminifi/include/core/yaml/YamlConfiguration.h b/libminifi/include/core/yaml/YamlConfiguration.h
index 0430092c3..bd9e01e20 100644
--- a/libminifi/include/core/yaml/YamlConfiguration.h
+++ b/libminifi/include/core/yaml/YamlConfiguration.h
@@ -160,7 +160,7 @@ class YamlConfiguration : public FlowConfiguration {
*/
std::unique_ptr<core::ProcessGroup> getYamlRoot(const YAML::Node& rootYamlNode);
- std::unique_ptr<core::ProcessGroup> createProcessGroup(const YAML::Node& headerNode, bool is_root = false);
+ std::unique_ptr<core::ProcessGroup> createProcessGroup(const YAML::Node& yamlNode, bool is_root = false);
std::unique_ptr<core::ProcessGroup> parseProcessGroupYaml(const YAML::Node& headerNode, const YAML::Node& yamlNode, bool is_root = false);
/**
@@ -170,11 +170,11 @@ class YamlConfiguration : public FlowConfiguration {
* object will be created a added to the parent ProcessGroup specified
* by the parent argument.
*
- * @param processorNode the YAML::Node containing the processor configuration
- * @param parent the parent ProcessGroup to which the the created
- * Processor should be added
+ * @param processorsNode the YAML::Node containing the processor configuration
+ * @param parent the parent ProcessGroup to which the the created
+ * Processor should be added
*/
- void parseProcessorNodeYaml(const YAML::Node& processorNode, core::ProcessGroup* parent);
+ void parseProcessorNodeYaml(const YAML::Node& processorsNode, core::ProcessGroup* parent);
/**
* Parses a port from its corressponding YAML config node and adds
@@ -194,10 +194,10 @@ class YamlConfiguration : public FlowConfiguration {
* returns a ProcessGroup containing the tree of flow configuration
* objects.
*
- * @param rootNode
+ * @param rootFlowNode
* @return
*/
- std::unique_ptr<core::ProcessGroup> parseRootProcessGroupYaml(const YAML::Node& rootNode);
+ std::unique_ptr<core::ProcessGroup> parseRootProcessGroupYaml(const YAML::Node& rootFlowNode);
// Process Property YAML
void parseProcessorPropertyYaml(const YAML::Node& doc, const YAML::Node& node, std::shared_ptr<core::Processor> processor);
@@ -248,7 +248,7 @@ class YamlConfiguration : public FlowConfiguration {
* @param propertiesNode the YAML::Node containing the properties
* @param processor the Processor to which to add the resulting properties
*/
- void parsePropertiesNodeYaml(const YAML::Node& propertiesNode, core::ConfigurableComponent& processor, const std::string& component_name, const std::string& yaml_section);
+ void parsePropertiesNodeYaml(const YAML::Node& propertiesNode, core::ConfigurableComponent& component, const std::string& component_name, const std::string& yaml_section);
/**
* Parses the Funnels section of a configuration YAML.
@@ -301,7 +301,7 @@ class YamlConfiguration : public FlowConfiguration {
private:
PropertyValue getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode);
- void parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, core::ConfigurableComponent& processor);
+ void parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, core::ConfigurableComponent& component);
void parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, core::ConfigurableComponent& processor);
void parsePropertyNodeElement(const std::string& propertyName, const YAML::Node& propertyValueNode, core::ConfigurableComponent& processor);
void addNewId(const std::string& uuid);
diff --git a/libminifi/include/io/BufferStream.h b/libminifi/include/io/BufferStream.h
index 9c6eecb65..987cdcaf9 100644
--- a/libminifi/include/io/BufferStream.h
+++ b/libminifi/include/io/BufferStream.h
@@ -54,7 +54,7 @@ class BufferStream : public BaseStream {
using BaseStream::read;
using BaseStream::write;
- size_t write(const uint8_t* data, size_t len) final;
+ size_t write(const uint8_t* value, size_t size) final;
size_t read(gsl::span<std::byte> buffer) override;
diff --git a/libminifi/include/io/ZlibStream.h b/libminifi/include/io/ZlibStream.h
index d617cedd3..3c1a2d8c9 100644
--- a/libminifi/include/io/ZlibStream.h
+++ b/libminifi/include/io/ZlibStream.h
@@ -82,7 +82,7 @@ class ZlibCompressStream : public ZlibBaseStream {
void close() override;
protected:
- ZlibCompressStream(gsl::not_null<OutputStream*> ouput, ZlibCompressionFormat format, int level, std::shared_ptr<core::logging::Logger> logger);
+ ZlibCompressStream(gsl::not_null<OutputStream*> output, ZlibCompressionFormat format, int level, std::shared_ptr<core::logging::Logger> logger);
using FlushMode = int;
size_t write(const uint8_t* value, size_t size, FlushMode mode);
diff --git a/libminifi/include/provenance/Provenance.h b/libminifi/include/provenance/Provenance.h
index 2dbe56909..7941b5465 100644
--- a/libminifi/include/provenance/Provenance.h
+++ b/libminifi/include/provenance/Provenance.h
@@ -348,14 +348,11 @@ class ProvenanceEventRecord : public core::SerializableComponent {
// Serialize and Persistent to the repository
bool Serialize(const std::shared_ptr<core::SerializableComponent> &repo) override;
- // DeSerialize
bool DeSerialize(gsl::span<const std::byte>) override;
- // DeSerialize
bool DeSerialize(org::apache::nifi::minifi::io::BufferStream &stream) {
return DeSerialize(stream.getBuffer());
}
- // DeSerialize
- bool DeSerialize(const std::shared_ptr<core::SerializableComponent> &repo) override;
+ bool DeSerialize(const std::shared_ptr<core::SerializableComponent> &store) override;
protected:
// Event type
diff --git a/libminifi/include/utils/StringUtils.h b/libminifi/include/utils/StringUtils.h
index 647bca043..b48e8eef6 100644
--- a/libminifi/include/utils/StringUtils.h
+++ b/libminifi/include/utils/StringUtils.h
@@ -431,16 +431,16 @@ class StringUtils {
* @param padded if true, padding is added to the Base64 encoded string
* @return the size of Base64 encoded bytes
*/
- static size_t to_base64(char* base64, gsl::span<const std::byte> data_to_be_transformed, bool url, bool padded);
+ static size_t to_base64(char* base64, gsl::span<const std::byte> raw_data, bool url, bool padded);
/**
* Creates a Base64 encoded string from data
- * @param data the bytes to be Base64 encoded
+ * @param raw_data the bytes to be Base64 encoded
* @param url if true, the URL-safe Base64 encoding will be used
* @param padded if true, padding is added to the Base64 encoded string
* @return the Base64 encoded string
*/
- static std::string to_base64(gsl::span<const std::byte> data_to_be_transformed, bool url = false, bool padded = true);
+ static std::string to_base64(gsl::span<const std::byte> raw_data, bool url = false, bool padded = true);
/**
* Base64 encodes a string
diff --git a/libminifi/include/utils/file/FilePattern.h b/libminifi/include/utils/file/FilePattern.h
index d673ae04a..975c4d486 100644
--- a/libminifi/include/utils/file/FilePattern.h
+++ b/libminifi/include/utils/file/FilePattern.h
@@ -83,7 +83,7 @@ class FilePattern {
};
using DirIt = std::filesystem::path::const_iterator;
- static DirMatchResult matchDirectory(DirIt pattern_begin, DirIt pattern_end, DirIt value_begin, DirIt value_end);
+ static DirMatchResult matchDirectory(DirIt pattern_it, DirIt pattern_end, DirIt value_it, DirIt value_end);
std::filesystem::path directory_pattern_;
std::string file_pattern_;
diff --git a/libminifi/src/FlowControlProtocol.cpp b/libminifi/src/FlowControlProtocol.cpp
index 84eda0288..7f6e38db1 100644
--- a/libminifi/src/FlowControlProtocol.cpp
+++ b/libminifi/src/FlowControlProtocol.cpp
@@ -32,10 +32,7 @@
#include "core/Core.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
+namespace org::apache::nifi::minifi {
int FlowControlProtocol::connectServer(const char* /*host*/, uint16_t /*port*/) {
return 0;
@@ -45,7 +42,7 @@ int FlowControlProtocol::sendData(uint8_t* /*buf*/, int /*buflen*/) {
return 0;
}
-int FlowControlProtocol::selectClient(int msec) {
+int FlowControlProtocol::selectClient(int msec) const {
fd_set fds;
struct timeval tv{};
int retval;
@@ -383,7 +380,4 @@ int FlowControlProtocol::sendReportReq() {
}
}
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi
diff --git a/libminifi/src/RemoteProcessorGroupPort.cpp b/libminifi/src/RemoteProcessorGroupPort.cpp
index 350e6b483..7160f7b21 100644
--- a/libminifi/src/RemoteProcessorGroupPort.cpp
+++ b/libminifi/src/RemoteProcessorGroupPort.cpp
@@ -38,7 +38,6 @@
#include "rapidjson/document.h"
-#include "Exception.h"
#include "core/logging/Logger.h"
#include "core/ProcessContext.h"
#include "core/ProcessorNode.h"
@@ -47,10 +46,7 @@
#include "utils/HTTPClient.h"
#undef GetObject // windows.h #defines GetObject = GetObjectA or GetObjectW, which conflicts with rapidjson
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
+namespace org::apache::nifi::minifi {
const char *RemoteProcessorGroupPort::RPG_SSL_CONTEXT_SERVICE_NAME = "RemoteProcessorGroupPortSSLContextService";
@@ -70,7 +66,7 @@ std::unique_ptr<sitetosite::SiteToSiteClient> RemoteProcessorGroupPort::getNextP
if (create) {
// create
if (bypass_rest_api_) {
- if (nifi_instances_.size() > 0) {
+ if (!nifi_instances_.empty()) {
auto rpg = nifi_instances_.front();
auto host = rpg.host_;
#ifdef WIN32
@@ -158,7 +154,7 @@ void RemoteProcessorGroupPort::onSchedule(const std::shared_ptr<core::ProcessCon
std::lock_guard<std::mutex> lock(peer_mutex_);
if (!nifi_instances_.empty()) {
refreshPeerList();
- if (peers_.size() > 0)
+ if (!peers_.empty())
peer_index_ = 0;
}
/**
@@ -166,7 +162,8 @@ void RemoteProcessorGroupPort::onSchedule(const std::shared_ptr<core::ProcessCon
* we must rely on the configured host/port
*/
if (peers_.empty() && is_http_disabled()) {
- std::string host, portStr;
+ std::string host;
+ std::string portStr;
int configured_port = -1;
// place hostname/port into the log message if we have it
context->getProperty(hostName.getName(), host);
@@ -181,7 +178,7 @@ void RemoteProcessorGroupPort::onSchedule(const std::shared_ptr<core::ProcessCon
}
}
// populate the site2site protocol for load balancing between them
- if (peers_.size() > 0) {
+ if (!peers_.empty()) {
auto count = peers_.size();
if (max_concurrent_tasks_ > count)
count = max_concurrent_tasks_;
@@ -317,7 +314,7 @@ std::pair<std::string, int> RemoteProcessorGroupPort::refreshRemoteSite2SiteInfo
}
int siteTosite_port_ = -1;
client = std::unique_ptr<utils::BaseHTTPClient>(dynamic_cast<utils::BaseHTTPClient*>(client_ptr));
- client->initialize("GET", fullUrl.str().c_str(), ssl_service);
+ client->initialize("GET", fullUrl.str(), ssl_service);
// use a connection timeout. if this times out we will simply attempt re-connection
// so no need for configuration parameter that isn't already defined in Processor
client->setConnectionTimeout(std::chrono::milliseconds(10000));
@@ -390,11 +387,8 @@ void RemoteProcessorGroupPort::refreshPeerList() {
core::logging::LOG_INFO(logger_) << "Have " << peers_.size() << " peers";
- if (peers_.size() > 0)
+ if (!peers_.empty())
peer_index_ = 0;
}
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi
diff --git a/libminifi/src/ResourceClaim.cpp b/libminifi/src/ResourceClaim.cpp
index 814d8abe9..970f5516b 100644
--- a/libminifi/src/ResourceClaim.cpp
+++ b/libminifi/src/ResourceClaim.cpp
@@ -27,14 +27,11 @@
#include "utils/Id.h"
#include "core/logging/LoggerConfiguration.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
+namespace org::apache::nifi::minifi {
utils::NonRepeatingStringGenerator ResourceClaim::non_repeating_string_generator_;
-std::string default_directory_path = "";
+std::string default_directory_path;
void setDefaultDirectory(std::string path) {
default_directory_path = path;
@@ -55,8 +52,8 @@ ResourceClaim::ResourceClaim(std::shared_ptr<core::StreamManager<ResourceClaim>>
logger_->log_debug("Resource Claim created %s", _contentFullPath);
}
-ResourceClaim::ResourceClaim(const Path& path, std::shared_ptr<core::StreamManager<ResourceClaim>> claim_manager)
- : _contentFullPath(path),
+ResourceClaim::ResourceClaim(Path path, std::shared_ptr<core::StreamManager<ResourceClaim>> claim_manager)
+ : _contentFullPath(std::move(path)),
claim_manager_(std::move(claim_manager)),
logger_(core::logging::LoggerFactory<ResourceClaim>::getLogger()) {
if (claim_manager_) increaseFlowFileRecordOwnedCount();
@@ -66,7 +63,4 @@ ResourceClaim::~ResourceClaim() {
if (claim_manager_) decreaseFlowFileRecordOwnedCount();
}
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi
diff --git a/libminifi/src/c2/C2Agent.cpp b/libminifi/src/c2/C2Agent.cpp
index a0065daff..38663576b 100644
--- a/libminifi/src/c2/C2Agent.cpp
+++ b/libminifi/src/c2/C2Agent.cpp
@@ -131,7 +131,9 @@ void C2Agent::checkTriggers() {
}
}
void C2Agent::configure(const std::shared_ptr<Configure> &configure, bool reconfigure) {
- std::string clazz, heartbeat_period, device;
+ std::string clazz;
+ std::string heartbeat_period;
+ std::string device;
if (!reconfigure) {
if (!configure->get(Configuration::nifi_c2_agent_protocol_class, "c2.agent.protocol.class", clazz)) {
@@ -254,7 +256,7 @@ void C2Agent::serializeMetrics(C2Payload &metric_payload, const std::string &nam
const auto payloads = std::count_if(begin(metrics), end(metrics), [](const state::response::SerializedResponseNode& metric) { return !metric.children.empty() || metric.keep_empty; });
metric_payload.reservePayloads(metric_payload.getNestedPayloads().size() + payloads);
for (const auto &metric : metrics) {
- if (metric.children.size() > 0 || (metric.children.size() == 0 && metric.keep_empty)) {
+ if (metric.keep_empty || !metric.children.empty()) {
C2Payload child_metric_payload(metric_payload.getOperation());
if (metric.array) {
child_metric_payload.setContainer(true);
diff --git a/libminifi/src/c2/ControllerSocketProtocol.cpp b/libminifi/src/c2/ControllerSocketProtocol.cpp
index ded4a1488..9c382d957 100644
--- a/libminifi/src/c2/ControllerSocketProtocol.cpp
+++ b/libminifi/src/c2/ControllerSocketProtocol.cpp
@@ -34,7 +34,10 @@ void ControllerSocketProtocol::initialize(core::controller::ControllerServicePro
HeartbeatReporter::initialize(controller, updateSink, configuration);
stream_factory_ = minifi::io::StreamFactory::getInstance(configuration);
- std::string host = "localhost", port, limitStr, context_name;
+ std::string host = "localhost";
+ std::string port;
+ std::string limitStr;
+ std::string context_name;
std::shared_ptr<minifi::controllers::SSLContextService> secure_context = nullptr;
if (configuration_->get("controller.ssl.context.service", context_name)) {
diff --git a/libminifi/src/controllers/NetworkPrioritizerService.cpp b/libminifi/src/controllers/NetworkPrioritizerService.cpp
index 202b51a0f..8770b4fa8 100644
--- a/libminifi/src/controllers/NetworkPrioritizerService.cpp
+++ b/libminifi/src/controllers/NetworkPrioritizerService.cpp
@@ -72,7 +72,7 @@ void NetworkPrioritizerService::yield() {
*/
io::NetworkInterface NetworkPrioritizerService::getInterface(uint32_t size = 0) {
std::vector<std::string> controllers;
- std::string ifc = "";
+ std::string ifc;
if (!network_controllers_.empty()) {
if (sufficient_tokens(size) && size <= max_payload_) {
controllers.insert(std::end(controllers), std::begin(network_controllers_), std::end(network_controllers_));
@@ -153,11 +153,7 @@ bool NetworkPrioritizerService::sufficient_tokens(uint32_t size) {
tokens_ += gsl::narrow<uint32_t>(diff * tokens_per_ms);
}
if (bytes_per_token_ > 0 && size > 0) {
- if (tokens_ * bytes_per_token_ >= size) {
- return true;
- } else {
- return false;
- }
+ return tokens_ * bytes_per_token_ >= size;
}
return true;
}
diff --git a/libminifi/src/controllers/SSLContextService.cpp b/libminifi/src/controllers/SSLContextService.cpp
index 76c178aa7..4df21c450 100644
--- a/libminifi/src/controllers/SSLContextService.cpp
+++ b/libminifi/src/controllers/SSLContextService.cpp
@@ -311,7 +311,7 @@ bool SSLContextService::useClientCertificate(PCCERT_CONTEXT certificate, ClientC
}
#endif // WIN32
-bool SSLContextService::addServerCertificatesFromSystemStoreToSSLContext(SSL_CTX* ctx) const {
+bool SSLContextService::addServerCertificatesFromSystemStoreToSSLContext(SSL_CTX* ctx) const { // NOLINT(readability-convert-member-functions-to-static)
#ifdef WIN32
X509_STORE* ssl_store = SSL_CTX_get_cert_store(ctx);
if (!ssl_store) {
diff --git a/libminifi/src/controllers/UpdatePolicyControllerService.cpp b/libminifi/src/controllers/UpdatePolicyControllerService.cpp
index b057cf38a..7a36adde6 100644
--- a/libminifi/src/controllers/UpdatePolicyControllerService.cpp
+++ b/libminifi/src/controllers/UpdatePolicyControllerService.cpp
@@ -67,7 +67,8 @@ bool UpdatePolicyControllerService::isWorkAvailable() {
}
void UpdatePolicyControllerService::onEnable() {
- std::string enableStr, persistStr;
+ std::string enableStr;
+ std::string persistStr;
bool enable_all = false;
if (getProperty(AllowAllProperties.getName(), enableStr)) {
diff --git a/libminifi/src/core/Connectable.cpp b/libminifi/src/core/Connectable.cpp
index ca727a6b9..4a3b73e00 100644
--- a/libminifi/src/core/Connectable.cpp
+++ b/libminifi/src/core/Connectable.cpp
@@ -23,11 +23,7 @@
#include "core/logging/LoggerConfiguration.h"
#include "core/Relationship.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
Connectable::Connectable(const std::string &name, const utils::Identifier &uuid)
: CoreComponent(name, uuid),
@@ -75,12 +71,7 @@ bool Connectable::isSupportedRelationship(const core::Relationship &relationship
const auto conditionalLock = isConnectableRunning ? std::unique_lock<std::mutex>() : std::unique_lock<std::mutex>(relationship_mutex_);
- const auto &it = relationships_.find(relationship.getName());
- if (it != relationships_.end()) {
- return true;
- } else {
- return false;
- }
+ return relationships_.contains(relationship.getName());
}
void Connectable::setAutoTerminatedRelationships(gsl::span<const core::Relationship> relationships) {
@@ -105,12 +96,7 @@ bool Connectable::isAutoTerminated(const core::Relationship &relationship) {
const auto conditionalLock = isConnectableRunning ? std::unique_lock<std::mutex>() : std::unique_lock<std::mutex>(relationship_mutex_);
- const auto &it = auto_terminated_relationships_.find(relationship.getName());
- if (it != auto_terminated_relationships_.end()) {
- return true;
- } else {
- return false;
- }
+ return auto_terminated_relationships_.contains(relationship.getName());
}
void Connectable::waitForWork(uint64_t timeoutMs) {
@@ -171,8 +157,4 @@ Connectable* Connectable::pickIncomingConnection() {
return getNextIncomingConnection();
}
-} /* namespace core */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::core
diff --git a/libminifi/src/core/FlowConfiguration.cpp b/libminifi/src/core/FlowConfiguration.cpp
index f7108d433..6df2ed7f4 100644
--- a/libminifi/src/core/FlowConfiguration.cpp
+++ b/libminifi/src/core/FlowConfiguration.cpp
@@ -26,11 +26,7 @@
#include "utils/StringUtils.h"
#include "processors/ProcessorUtils.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
FlowConfiguration::FlowConfiguration(
std::shared_ptr<core::Repository> /*repo*/, std::shared_ptr<core::Repository> flow_file_repo,
@@ -46,7 +42,9 @@ FlowConfiguration::FlowConfiguration(
logger_(logging::LoggerFactory<FlowConfiguration>::getLogger()) {
controller_services_ = std::make_shared<core::controller::ControllerServiceMap>();
service_provider_ = std::make_shared<core::controller::StandardControllerServiceProvider>(controller_services_, nullptr, configuration);
- std::string flowUrl = "", bucket_id = "default", flowId = "";
+ std::string flowUrl;
+ std::string bucket_id = "default";
+ std::string flowId;
configuration->get(Configure::nifi_c2_flow_id, flowId);
configuration->get(Configure::nifi_c2_flow_url, flowUrl);
flow_version_ = std::make_shared<state::response::FlowVersion>(flowUrl, bucket_id, flowId);
@@ -106,7 +104,8 @@ std::unique_ptr<core::ProcessGroup> FlowConfiguration::updateFromPayload(const s
service_provider_ = std::make_shared<core::controller::StandardControllerServiceProvider>(controller_services_, nullptr, configuration_);
auto payload = getRootFromPayload(yamlConfigPayload);
if (!url.empty() && payload != nullptr) {
- std::string flow_id, bucket_id;
+ std::string flow_id;
+ std::string bucket_id;
auto path_split = utils::StringUtils::split(url, "/");
for (auto it = path_split.cbegin(); it != path_split.cend(); ++it) {
if (*it == "flows" && std::next(it) != path_split.cend()) {
@@ -170,8 +169,4 @@ std::shared_ptr<core::controller::ControllerServiceNode> FlowConfiguration::crea
return controllerServicesNode;
}
-} /* 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 1ca41a715..2630e760e 100644
--- a/libminifi/src/core/Processor.cpp
+++ b/libminifi/src/core/Processor.cpp
@@ -34,6 +34,7 @@
#include "core/ProcessSessionFactory.h"
#include "io/StreamFactory.h"
#include "utils/gsl.h"
+#include "range/v3/algorithm/any_of.hpp"
using namespace std::literals::chrono_literals;
@@ -41,7 +42,6 @@ namespace org::apache::nifi::minifi::core {
Processor::Processor(const std::string& name)
: Connectable(name),
- ConfigurableComponent(),
logger_(logging::LoggerFactory<Processor>::getLogger()) {
has_work_.store(false);
// Setup the default values
@@ -60,7 +60,6 @@ Processor::Processor(const std::string& name)
Processor::Processor(const std::string& name, const utils::Identifier& uuid)
: Connectable(name, uuid),
- ConfigurableComponent(),
logger_(logging::LoggerFactory<Processor>::getLogger()) {
has_work_.store(false);
// Setup the default values
@@ -290,32 +289,16 @@ bool Processor::partOfCycle(Connection* conn) {
}
bool Processor::isThrottledByBackpressure() const {
- bool isThrottledByOutgoing = ([&] {
- for (auto &outIt : outgoing_connections_) {
- for (auto &out : outIt.second) {
- auto connection = dynamic_cast<Connection*>(out);
- if (!connection) {
- continue;
- }
- if (connection->isFull()) {
- return true;
- }
- }
- }
- return false;
- })();
- bool isForcedByIncomingCycle = ([&] {
- for (auto &inConn : incoming_connections_) {
- auto connection = dynamic_cast<Connection*>(inConn);
- if (!connection) {
- continue;
- }
- if (partOfCycle(connection) && connection->isFull()) {
- return true;
- }
- }
- return false;
- })();
+ bool isThrottledByOutgoing = ranges::any_of(outgoing_connections_, [](auto& name_connection_set_pair) {
+ return ranges::any_of(name_connection_set_pair.second, [](auto& connectable) {
+ auto connection = dynamic_cast<Connection*>(connectable);
+ return connection && connection->isFull();
+ });
+ });
+ bool isForcedByIncomingCycle = ranges::any_of(incoming_connections_, [](auto& connectable) {
+ auto connection = dynamic_cast<Connection*>(connectable);
+ return connection && partOfCycle(connection) && connection->isFull();
+ });
return isThrottledByOutgoing && !isForcedByIncomingCycle;
}
diff --git a/libminifi/src/core/ProcessorNode.cpp b/libminifi/src/core/ProcessorNode.cpp
index 64ece9833..ee4162bf8 100644
--- a/libminifi/src/core/ProcessorNode.cpp
+++ b/libminifi/src/core/ProcessorNode.cpp
@@ -18,15 +18,10 @@
#include "core/ProcessorNode.h"
#include <memory>
#include <utility>
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
ProcessorNode::ProcessorNode(Connectable* processor)
- : ConfigurableComponent(),
- Connectable(processor->getName()),
+ : Connectable(processor->getName()),
processor_(processor) {
setUUID(processor->getUUID());
}
@@ -41,8 +36,4 @@ bool ProcessorNode::isRunning() {
return processor_->isRunning();
}
-} /* namespace core */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::core
diff --git a/libminifi/src/core/logging/Logger.cpp b/libminifi/src/core/logging/Logger.cpp
index d27377469..02425b2ec 100644
--- a/libminifi/src/core/logging/Logger.cpp
+++ b/libminifi/src/core/logging/Logger.cpp
@@ -23,13 +23,7 @@
#include <sstream>
#include <iostream>
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace logging {
-
+namespace org::apache::nifi::minifi::core::logging {
LoggerControl::LoggerControl()
: is_enabled_(true) {
@@ -68,7 +62,7 @@ void LogBuilder::setIgnore() {
ignore = true;
}
-void LogBuilder::log_string(LOG_LEVEL level) {
+void LogBuilder::log_string(LOG_LEVEL level) const {
ptr->log_string(level, str.str());
}
@@ -130,16 +124,11 @@ void Logger::log_string(LOG_LEVEL level, std::string str) {
}
Logger::Logger(std::shared_ptr<spdlog::logger> delegate, std::shared_ptr<LoggerControl> controller)
- : delegate_(delegate), controller_(controller) {
+ : delegate_(std::move(delegate)), controller_(std::move(controller)) {
}
Logger::Logger(std::shared_ptr<spdlog::logger> delegate)
- : delegate_(delegate), controller_(nullptr) {
+ : delegate_(std::move(delegate)), controller_(nullptr) {
}
-} /* 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/logging/LoggerConfiguration.cpp b/libminifi/src/core/logging/LoggerConfiguration.cpp
index 2af1c1b7a..10a53a036 100644
--- a/libminifi/src/core/logging/LoggerConfiguration.cpp
+++ b/libminifi/src/core/logging/LoggerConfiguration.cpp
@@ -94,7 +94,6 @@ std::vector<std::string> LoggerProperties::get_keys_of_type(const std::string &t
LoggerConfiguration::LoggerConfiguration()
: root_namespace_(create_default_root()),
- loggers(std::vector<std::shared_ptr<LoggerImpl>>()),
formatter_(std::make_shared<spdlog::pattern_formatter>(spdlog_default_pattern)),
shorten_names_(false) {
controller_ = std::make_shared<LoggerControl>();
@@ -248,7 +247,7 @@ std::shared_ptr<spdlog::logger> LoggerConfiguration::get_logger(std::shared_ptr<
std::vector<std::shared_ptr<spdlog::sinks::sink>> sinks = root_namespace->sinks;
std::vector<std::shared_ptr<spdlog::sinks::sink>> inherited_sinks;
spdlog::level::level_enum level = root_namespace->level;
- std::string current_namespace_str = "";
+ std::string current_namespace_str;
std::string sink_namespace_str = "root";
std::string level_namespace_str = "root";
for (auto const & name_segment : utils::StringUtils::split(name, "::")) {
@@ -259,7 +258,7 @@ std::shared_ptr<spdlog::logger> LoggerConfiguration::get_logger(std::shared_ptr<
}
std::copy(current_namespace->exported_sinks.begin(), current_namespace->exported_sinks.end(), std::back_inserter(inherited_sinks));
current_namespace = child_pair->second;
- if (current_namespace->sinks.size() > 0) {
+ if (!current_namespace->sinks.empty()) {
sinks = current_namespace->sinks;
sink_namespace_str = current_namespace_str;
}
@@ -341,7 +340,7 @@ std::shared_ptr<spdlog::sinks::rotating_file_sink_mt> LoggerConfiguration::getRo
}
int max_files = 3;
- std::string max_files_str = "";
+ std::string max_files_str;
if (properties->getString(appender_key + ".max_files", max_files_str)) {
try {
max_files = std::stoi(max_files_str);
@@ -351,7 +350,7 @@ std::shared_ptr<spdlog::sinks::rotating_file_sink_mt> LoggerConfiguration::getRo
}
int max_file_size = 5_MiB;
- std::string max_file_size_str = "";
+ std::string max_file_size_str;
if (properties->getString(appender_key + ".max_file_size", max_file_size_str)) {
try {
max_file_size = std::stoi(max_file_size_str);
diff --git a/libminifi/src/core/repository/VolatileContentRepository.cpp b/libminifi/src/core/repository/VolatileContentRepository.cpp
index e44dfed73..a6fd0bb39 100644
--- a/libminifi/src/core/repository/VolatileContentRepository.cpp
+++ b/libminifi/src/core/repository/VolatileContentRepository.cpp
@@ -29,12 +29,7 @@
using namespace std::literals::chrono_literals;
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace repository {
+namespace org::apache::nifi::minifi::core::repository {
const char *VolatileContentRepository::minimal_locking = "minimal.locking";
@@ -126,10 +121,7 @@ bool VolatileContentRepository::exists(const minifi::ResourceClaim &claim) {
auto claim_check = master_list_.find(claim.getContentFullPath());
if (claim_check != master_list_.end()) {
auto ent = claim_check->second->takeOwnership();
- if (ent == nullptr) {
- return false;
- }
- return true;
+ return ent != nullptr;
}
return false;
@@ -185,9 +177,4 @@ bool VolatileContentRepository::remove(const minifi::ResourceClaim &claim) {
return false;
}
-} // namespace repository
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::core::repository
diff --git a/libminifi/src/core/yaml/YamlConfiguration.cpp b/libminifi/src/core/yaml/YamlConfiguration.cpp
index 4ae905dd0..5cd7ed91c 100644
--- a/libminifi/src/core/yaml/YamlConfiguration.cpp
+++ b/libminifi/src/core/yaml/YamlConfiguration.cpp
@@ -32,11 +32,7 @@
#include "utils/RegexUtils.h"
#endif // YAML_CONFIGURATION_USE_REGEX
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
std::shared_ptr<utils::IdGenerator> YamlConfiguration::id_generator_ = utils::IdGenerator::getIdGenerator();
@@ -60,7 +56,7 @@ std::unique_ptr<core::ProcessGroup> YamlConfiguration::createProcessGroup(const
int version = 0;
yaml::checkRequiredField(yamlNode, "name", CONFIG_YAML_REMOTE_PROCESS_GROUP_KEY);
- std::string flowName = yamlNode["name"].as<std::string>();
+ auto flowName = yamlNode["name"].as<std::string>();
utils::Identifier uuid;
// assignment throws on invalid uuid
@@ -79,7 +75,7 @@ std::unique_ptr<core::ProcessGroup> YamlConfiguration::createProcessGroup(const
}
if (yamlNode["onschedule retry interval"]) {
- std::string onScheduleRetryPeriod = yamlNode["onschedule retry interval"].as<std::string>();
+ auto onScheduleRetryPeriod = yamlNode["onschedule retry interval"].as<std::string>();
logger_->log_debug("parseRootProcessGroup: onschedule retry period => [%s]", onScheduleRetryPeriod);
auto on_schedule_retry_period_value = utils::timeutils::StringToDuration<std::chrono::milliseconds>(onScheduleRetryPeriod);
@@ -116,7 +112,7 @@ std::unique_ptr<core::ProcessGroup> YamlConfiguration::parseProcessGroupYaml(con
if (childProcessGroupNodeSeq && childProcessGroupNodeSeq.IsSequence()) {
for (YAML::const_iterator it = childProcessGroupNodeSeq.begin(); it != childProcessGroupNodeSeq.end(); ++it) {
- YAML::Node childProcessGroupNode = it->as<YAML::Node>();
+ auto childProcessGroupNode = it->as<YAML::Node>();
group->addProcessGroup(parseProcessGroupYaml(childProcessGroupNode, childProcessGroupNode));
}
}
@@ -168,7 +164,7 @@ void YamlConfiguration::parseProcessorNodeYaml(const YAML::Node& processorsNode,
procCfg.name = procNode["name"].as<std::string>();
procCfg.id = getOrGenerateId(procNode);
- uuid = procCfg.id.c_str();
+ uuid = procCfg.id;
logger_->log_debug("parseProcessorNode: name => [%s] id => [%s]", procCfg.name, procCfg.id);
yaml::checkRequiredField(procNode, "class", CONFIG_YAML_PROCESSORS_KEY);
procCfg.javaClass = procNode["class"].as<std::string>();
@@ -231,7 +227,7 @@ void YamlConfiguration::parseProcessorNodeYaml(const YAML::Node& processorsNode,
std::vector<std::string> rawAutoTerminatedRelationshipValues;
if (autoTerminatedSequence.IsSequence() && !autoTerminatedSequence.IsNull() && autoTerminatedSequence.size() > 0) {
for (YAML::const_iterator relIter = autoTerminatedSequence.begin(); relIter != autoTerminatedSequence.end(); ++relIter) {
- std::string autoTerminatedRel = relIter->as<std::string>();
+ auto autoTerminatedRel = relIter->as<std::string>();
rawAutoTerminatedRelationshipValues.push_back(autoTerminatedRel);
}
}
@@ -316,7 +312,7 @@ void YamlConfiguration::parseRemoteProcessGroupYaml(const YAML::Node& rpgNode, c
return;
}
for (YAML::const_iterator iter = rpgNode.begin(); iter != rpgNode.end(); ++iter) {
- YAML::Node currRpgNode = iter->as<YAML::Node>();
+ auto currRpgNode = iter->as<YAML::Node>();
yaml::checkRequiredField(currRpgNode, "name", CONFIG_YAML_REMOTE_PROCESS_GROUP_KEY);
auto name = currRpgNode["name"].as<std::string>();
@@ -327,7 +323,7 @@ void YamlConfiguration::parseRemoteProcessGroupYaml(const YAML::Node& rpgNode, c
auto urlNode = getOptionalField(currRpgNode, "url", YAML::Node(""),
CONFIG_YAML_REMOTE_PROCESS_GROUP_KEY);
- std::string url = urlNode.as<std::string>();
+ auto url = urlNode.as<std::string>();
logger_->log_debug("parseRemoteProcessGroupYaml: url => [%s]", url);
uuid = id;
@@ -335,7 +331,7 @@ void YamlConfiguration::parseRemoteProcessGroupYaml(const YAML::Node& rpgNode, c
group->setParent(parentGroup);
if (currRpgNode["yield period"]) {
- std::string yieldPeriod = currRpgNode["yield period"].as<std::string>();
+ auto yieldPeriod = currRpgNode["yield period"].as<std::string>();
logger_->log_debug("parseRemoteProcessGroupYaml: yield period => [%s]", yieldPeriod);
auto yield_period_value = utils::timeutils::StringToDuration<std::chrono::milliseconds>(yieldPeriod);
@@ -346,7 +342,7 @@ void YamlConfiguration::parseRemoteProcessGroupYaml(const YAML::Node& rpgNode, c
}
if (currRpgNode["timeout"]) {
- std::string timeout = currRpgNode["timeout"].as<std::string>();
+ auto timeout = currRpgNode["timeout"].as<std::string>();
logger_->log_debug("parseRemoteProcessGroupYaml: timeout => [%s]", timeout);
auto timeout_value = utils::timeutils::StringToDuration<std::chrono::milliseconds>(timeout);
@@ -357,32 +353,32 @@ void YamlConfiguration::parseRemoteProcessGroupYaml(const YAML::Node& rpgNode, c
}
if (currRpgNode["local network interface"]) {
- std::string interface = currRpgNode["local network interface"].as<std::string>();
+ auto interface = currRpgNode["local network interface"].as<std::string>();
logger_->log_debug("parseRemoteProcessGroupYaml: local network interface => [%s]", interface);
group->setInterface(interface);
}
if (currRpgNode["transport protocol"]) {
- std::string transport_protocol = currRpgNode["transport protocol"].as<std::string>();
+ auto transport_protocol = currRpgNode["transport protocol"].as<std::string>();
logger_->log_debug("parseRemoteProcessGroupYaml: transport protocol => [%s]", transport_protocol);
if (transport_protocol == "HTTP") {
group->setTransportProtocol(transport_protocol);
if (currRpgNode["proxy host"]) {
- std::string http_proxy_host = currRpgNode["proxy host"].as<std::string>();
+ auto http_proxy_host = currRpgNode["proxy host"].as<std::string>();
logger_->log_debug("parseRemoteProcessGroupYaml: proxy host => [%s]", http_proxy_host);
group->setHttpProxyHost(http_proxy_host);
if (currRpgNode["proxy user"]) {
- std::string http_proxy_username = currRpgNode["proxy user"].as<std::string>();
+ auto http_proxy_username = currRpgNode["proxy user"].as<std::string>();
logger_->log_debug("parseRemoteProcessGroupYaml: proxy user => [%s]", http_proxy_username);
group->setHttpProxyUserName(http_proxy_username);
}
if (currRpgNode["proxy password"]) {
- std::string http_proxy_password = currRpgNode["proxy password"].as<std::string>();
+ auto http_proxy_password = currRpgNode["proxy password"].as<std::string>();
logger_->log_debug("parseRemoteProcessGroupYaml: proxy password => [%s]", http_proxy_password);
group->setHttpProxyPassWord(http_proxy_password);
}
if (currRpgNode["proxy port"]) {
- std::string http_proxy_port = currRpgNode["proxy port"].as<std::string>();
+ auto http_proxy_port = currRpgNode["proxy port"].as<std::string>();
int32_t port;
if (core::Property::StringToInt(http_proxy_port, port)) {
logger_->log_debug("parseRemoteProcessGroupYaml: proxy port => [%d]", port);
@@ -403,20 +399,20 @@ void YamlConfiguration::parseRemoteProcessGroupYaml(const YAML::Node& rpgNode, c
group->setURL(url);
yaml::checkRequiredField(currRpgNode, "Input Ports", CONFIG_YAML_REMOTE_PROCESS_GROUP_KEY);
- YAML::Node inputPorts = currRpgNode["Input Ports"].as<YAML::Node>();
+ auto inputPorts = currRpgNode["Input Ports"].as<YAML::Node>();
if (inputPorts && inputPorts.IsSequence()) {
for (YAML::const_iterator portIter = inputPorts.begin(); portIter != inputPorts.end(); ++portIter) {
- YAML::Node currPort = portIter->as<YAML::Node>();
+ auto currPort = portIter->as<YAML::Node>();
this->parsePortYaml(currPort, group.get(), sitetosite::SEND);
} // for node
}
- YAML::Node outputPorts = currRpgNode["Output Ports"].as<YAML::Node>();
+ auto outputPorts = currRpgNode["Output Ports"].as<YAML::Node>();
if (outputPorts && outputPorts.IsSequence()) {
for (YAML::const_iterator portIter = outputPorts.begin(); portIter != outputPorts.end(); ++portIter) {
logger_->log_debug("Got a current port, iterating...");
- YAML::Node currPort = portIter->as<YAML::Node>();
+ auto currPort = portIter->as<YAML::Node>();
this->parsePortYaml(currPort, group.get(), sitetosite::RECEIVE);
} // for node
@@ -867,7 +863,7 @@ void YamlConfiguration::raiseComponentError(const std::string &component_name, c
std::string YamlConfiguration::getOrGenerateId(const YAML::Node& yamlNode, const std::string& idField) {
std::string id;
- YAML::Node node = yamlNode.as<YAML::Node>();
+ auto node = yamlNode.as<YAML::Node>();
if (node[idField]) {
if (YAML::NodeType::Scalar == node[idField].Type()) {
@@ -921,8 +917,4 @@ void YamlConfiguration::addNewId(const std::string& uuid) {
}
}
-} /* namespace core */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::core
diff --git a/libminifi/src/core/yaml/YamlConnectionParser.cpp b/libminifi/src/core/yaml/YamlConnectionParser.cpp
index 3ffbaf719..b29487275 100644
--- a/libminifi/src/core/yaml/YamlConnectionParser.cpp
+++ b/libminifi/src/core/yaml/YamlConnectionParser.cpp
@@ -19,15 +19,7 @@
#include "core/yaml/YamlConnectionParser.h"
#include "core/yaml/CheckRequiredField.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
-namespace yaml {
-
-// This is no longer needed in c++17
-constexpr const char* YamlConnectionParser::CONFIG_YAML_CONNECTIONS_KEY;
+namespace org::apache::nifi::minifi::core::yaml {
void YamlConnectionParser::addNewRelationshipToConnection(const std::string& relationship_name, minifi::Connection& connection) const {
core::Relationship relationship(relationship_name, "");
@@ -148,7 +140,7 @@ utils::Identifier YamlConnectionParser::getDestinationUUIDFromYaml() const {
// we use the same logic as above for resolving the source processor
// for looking up the destination processor in absence of a processor id
checkRequiredField(connectionNode_, "destination name", CONFIG_YAML_CONNECTIONS_KEY);
- std::string connectionDestProcName = connectionNode_["destination name"].as<std::string>();
+ auto connectionDestProcName = connectionNode_["destination name"].as<std::string>();
const auto destUUID = utils::Identifier::parse(connectionDestProcName);
if (destUUID && parent_->findProcessorById(destUUID.value(), ProcessGroup::Traverse::ExcludeChildren)) {
// the destination name is a remote port id, so use that as the dest id
@@ -197,9 +189,4 @@ bool YamlConnectionParser::getDropEmptyFromYaml() const {
return false;
}
-} // namespace yaml
-} // namespace core
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::core::yaml
diff --git a/libminifi/src/io/ClientSocket.cpp b/libminifi/src/io/ClientSocket.cpp
index fc321c233..0fe3fa411 100644
--- a/libminifi/src/io/ClientSocket.cpp
+++ b/libminifi/src/io/ClientSocket.cpp
@@ -41,7 +41,6 @@
#include "Exception.h"
#include <system_error>
#include <cinttypes>
-#include <Exception.h>
#include <utils/Deleters.h>
#include "io/validation.h"
#include "core/logging/LoggerConfiguration.h"
diff --git a/libminifi/src/provenance/Provenance.cpp b/libminifi/src/provenance/Provenance.cpp
index ad7bc59ae..dc705dfc4 100644
--- a/libminifi/src/provenance/Provenance.cpp
+++ b/libminifi/src/provenance/Provenance.cpp
@@ -31,11 +31,7 @@
#include "FlowController.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace provenance {
+namespace org::apache::nifi::minifi::provenance {
std::shared_ptr<utils::IdGenerator> ProvenanceEventRecord::id_generator_ = utils::IdGenerator::getIdGenerator();
std::shared_ptr<core::logging::Logger> ProvenanceEventRecord::logger_ = core::logging::LoggerFactory<ProvenanceEventRecord>::getLogger();
@@ -473,7 +469,7 @@ void ProvenanceReporter::commit() {
for (auto& event : _events) {
std::unique_ptr<io::BufferStream> stramptr(new io::BufferStream());
- event->Serialize(*stramptr.get());
+ event->Serialize(*stramptr);
flowData.emplace_back(event->getUUIDStr(), std::move(stramptr));
}
@@ -623,8 +619,4 @@ void ProvenanceReporter::fetch(std::shared_ptr<core::FlowFile> flow, std::string
}
}
-} /* namespace provenance */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::provenance
diff --git a/libminifi/src/serialization/FlowFileV3Serializer.cpp b/libminifi/src/serialization/FlowFileV3Serializer.cpp
index 5bd69c40e..3ecc4a5c3 100644
--- a/libminifi/src/serialization/FlowFileV3Serializer.cpp
+++ b/libminifi/src/serialization/FlowFileV3Serializer.cpp
@@ -20,12 +20,7 @@
#include "core/ProcessSession.h"
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-
-constexpr uint8_t FlowFileV3Serializer::MAGIC_HEADER[];
+namespace org::apache::nifi::minifi {
size_t FlowFileV3Serializer::writeLength(std::size_t length, const std::shared_ptr<io::OutputStream>& out) {
if (length < MAX_2_BYTE_VALUE) {
@@ -100,7 +95,4 @@ int64_t FlowFileV3Serializer::serialize(const std::shared_ptr<core::FlowFile>& f
return gsl::narrow<int64_t>(sum);
}
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi
diff --git a/libminifi/src/sitetosite/Peer.cpp b/libminifi/src/sitetosite/Peer.cpp
index 4906294e7..a48ae3507 100644
--- a/libminifi/src/sitetosite/Peer.cpp
+++ b/libminifi/src/sitetosite/Peer.cpp
@@ -51,11 +51,7 @@ bool SiteToSitePeer::Open() {
return false;
const auto data_size = sizeof MAGIC_BYTES;
- if (stream_->write(reinterpret_cast<const uint8_t *>(MAGIC_BYTES), data_size) != data_size) {
- return false;
- }
-
- return true;
+ return stream_->write(reinterpret_cast<const uint8_t *>(MAGIC_BYTES), data_size) == data_size;
}
void SiteToSitePeer::Close() {
diff --git a/libminifi/src/sitetosite/SiteToSiteClient.cpp b/libminifi/src/sitetosite/SiteToSiteClient.cpp
index 5b169247d..e0cfe3670 100644
--- a/libminifi/src/sitetosite/SiteToSiteClient.cpp
+++ b/libminifi/src/sitetosite/SiteToSiteClient.cpp
@@ -23,11 +23,7 @@
#include "utils/gsl.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace sitetosite {
+namespace org::apache::nifi::minifi::sitetosite {
int SiteToSiteClient::readResponse(const std::shared_ptr<Transaction>& /*transaction*/, RespondCode &code, std::string &message) {
uint8_t firstByte;
@@ -299,7 +295,7 @@ bool SiteToSiteClient::confirm(const utils::Identifier& transactionID) {
}
void SiteToSiteClient::cancel(const utils::Identifier& transactionID) {
- std::shared_ptr<Transaction> transaction = NULL;
+ std::shared_ptr<Transaction> transaction = nullptr;
if (peer_state_ != READY) {
return;
@@ -321,11 +317,10 @@ void SiteToSiteClient::cancel(const utils::Identifier& transactionID) {
transaction->_state = TRANSACTION_CANCELED;
tearDown();
- return;
}
void SiteToSiteClient::error(const utils::Identifier& transactionID) {
- std::shared_ptr<Transaction> transaction = NULL;
+ std::shared_ptr<Transaction> transaction = nullptr;
auto it = this->known_transactions_.find(transactionID);
@@ -337,13 +332,12 @@ void SiteToSiteClient::error(const utils::Identifier& transactionID) {
transaction->_state = TRANSACTION_ERROR;
tearDown();
- return;
}
// Complete the transaction
bool SiteToSiteClient::complete(const utils::Identifier& transactionID) {
int ret;
- std::shared_ptr<Transaction> transaction = NULL;
+ std::shared_ptr<Transaction> transaction = nullptr;
if (peer_state_ != READY) {
bootstrap();
@@ -644,7 +638,7 @@ bool SiteToSiteClient::receive(const utils::Identifier& transactionID, DataPacke
bool SiteToSiteClient::receiveFlowFiles(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) {
uint64_t bytes = 0;
int transfers = 0;
- std::shared_ptr<Transaction> transaction = NULL;
+ std::shared_ptr<Transaction> transaction = nullptr;
if (peer_state_ != READY) {
if (!bootstrap()) {
@@ -661,7 +655,7 @@ bool SiteToSiteClient::receiveFlowFiles(const std::shared_ptr<core::ProcessConte
// Create the transaction
transaction = createTransaction(RECEIVE);
- if (transaction == NULL) {
+ if (transaction == nullptr) {
context->yield();
tearDown();
throw Exception(SITE2SITE_EXCEPTION, "Can not create transaction");
@@ -752,8 +746,4 @@ bool SiteToSiteClient::receiveFlowFiles(const std::shared_ptr<core::ProcessConte
deleteTransaction(transactionID);
return true;
}
-} /* namespace sitetosite */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+} // namespace org::apache::nifi::minifi::sitetosite
diff --git a/libminifi/src/utils/Id.cpp b/libminifi/src/utils/Id.cpp
index 83106f936..a62c98a9f 100644
--- a/libminifi/src/utils/Id.cpp
+++ b/libminifi/src/utils/Id.cpp
@@ -168,7 +168,8 @@ std::optional<Identifier> Identifier::parse(const std::string &str) {
}
bool Identifier::parseByte(Data &data, const uint8_t *input, int &charIdx, int &byteIdx) {
- uint8_t upper, lower;
+ uint8_t upper;
+ uint8_t lower;
if (!StringUtils::from_hex(input[charIdx++], upper)
|| !StringUtils::from_hex(input[charIdx++], lower)) {
return false;
diff --git a/libminifi/src/utils/StringUtils.cpp b/libminifi/src/utils/StringUtils.cpp
index 7c5dae6bd..c7d55b11b 100644
--- a/libminifi/src/utils/StringUtils.cpp
+++ b/libminifi/src/utils/StringUtils.cpp
@@ -28,8 +28,8 @@ namespace org::apache::nifi::minifi::utils {
namespace views = ranges::views;
-std::optional<bool> StringUtils::toBool(const std::string& str) {
- std::string trimmed = trim(str);
+std::optional<bool> StringUtils::toBool(const std::string& input) {
+ std::string trimmed = trim(input);
if (equalsIgnoreCase(trimmed, "true")) {
return true;
}
@@ -315,10 +315,7 @@ bool StringUtils::from_hex(std::byte* data, size_t* data_length, std::string_vie
}
}
}
- if (found_first_nibble) {
- return false;
- }
- return true;
+ return !found_first_nibble;
}
std::vector<std::byte> StringUtils::from_hex(std::string_view hex) {
diff --git a/libminifi/src/utils/file/FileUtils.cpp b/libminifi/src/utils/file/FileUtils.cpp
index 7313843a3..ce6e03631 100644
--- a/libminifi/src/utils/file/FileUtils.cpp
+++ b/libminifi/src/utils/file/FileUtils.cpp
@@ -25,15 +25,10 @@
#include "utils/Literals.h"
#include "utils/Searcher.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace utils {
-namespace file {
+namespace org::apache::nifi::minifi::utils::file {
uint64_t computeChecksum(const std::string &file_name, uint64_t up_to_position) {
- constexpr uint64_t BUFFER_SIZE = 4096u;
+ constexpr uint64_t BUFFER_SIZE = 4096U;
std::array<char, std::size_t{BUFFER_SIZE}> buffer;
std::ifstream stream{file_name, std::ios::in | std::ios::binary};
@@ -96,9 +91,4 @@ void put_content(const std::filesystem::path& filename, std::string_view new_con
ofs.write(new_contents.data(), gsl::narrow<std::streamsize>(new_contents.size()));
}
-} // namespace file
-} // namespace utils
-} // namespace minifi
-} // namespace nifi
-} // namespace apache
-} // namespace org
+} // namespace org::apache::nifi::minifi::utils::file
diff --git a/libminifi/src/utils/net/Socket.cpp b/libminifi/src/utils/net/Socket.cpp
index 533dd9407..f87483d2e 100644
--- a/libminifi/src/utils/net/Socket.cpp
+++ b/libminifi/src/utils/net/Socket.cpp
@@ -52,14 +52,14 @@ std::string sockaddr_ntop(const sockaddr* const sa) {
sockaddr_in sa_in{};
std::memcpy(&sa_in, sa, sizeof(sockaddr_in));
result.resize(INET_ADDRSTRLEN);
- if (inet_ntop(AF_INET, &sa_in.sin_addr, &result[0], INET_ADDRSTRLEN) == nullptr) {
+ if (inet_ntop(AF_INET, &sa_in.sin_addr, result.data(), INET_ADDRSTRLEN) == nullptr) {
throw minifi::Exception{ minifi::ExceptionType::GENERAL_EXCEPTION, get_last_socket_error().message() };
}
} else if (sa->sa_family == AF_INET6) {
sockaddr_in6 sa_in6{};
std::memcpy(&sa_in6, sa, sizeof(sockaddr_in6));
result.resize(INET6_ADDRSTRLEN);
- if (inet_ntop(AF_INET6, &sa_in6.sin6_addr, &result[0], INET6_ADDRSTRLEN) == nullptr) {
+ if (inet_ntop(AF_INET6, &sa_in6.sin6_addr, result.data(), INET6_ADDRSTRLEN) == nullptr) {
throw minifi::Exception{ minifi::ExceptionType::GENERAL_EXCEPTION, get_last_socket_error().message() };
}
} else {
diff --git a/libminifi/test/TestBase.cpp b/libminifi/test/TestBase.cpp
index 6e94d80e9..4255f13c6 100644
--- a/libminifi/test/TestBase.cpp
+++ b/libminifi/test/TestBase.cpp
@@ -92,7 +92,7 @@ void LogTestController::setLevelByClassName(spdlog::level::level_enum level, con
}
}
-bool LogTestController::contains(const std::ostringstream& stream, const std::string& ending, std::chrono::seconds timeout, std::chrono::milliseconds sleep_interval) {
+bool LogTestController::contains(const std::ostringstream& stream, const std::string& ending, std::chrono::seconds timeout, std::chrono::milliseconds sleep_interval) const {
if (ending.length() == 0) {
return false;
}
@@ -113,7 +113,7 @@ bool LogTestController::contains(const std::ostringstream& stream, const std::st
return found;
}
-std::optional<std::smatch> LogTestController::matchesRegex(const std::string& regex_str, std::chrono::seconds timeout, std::chrono::milliseconds sleep_interval) {
+std::optional<std::smatch> LogTestController::matchesRegex(const std::string& regex_str, std::chrono::seconds timeout, std::chrono::milliseconds sleep_interval) const {
if (regex_str.length() == 0) {
return std::nullopt;
}
diff --git a/libminifi/test/TestBase.h b/libminifi/test/TestBase.h
index 117fb7ecb..1653817db 100644
--- a/libminifi/test/TestBase.h
+++ b/libminifi/test/TestBase.h
@@ -129,23 +129,23 @@ class LogTestController {
void setLevelByClassName(spdlog::level::level_enum level, const std::string& class_name);
- bool contains(const std::string &ending, std::chrono::seconds timeout = std::chrono::seconds(3), std::chrono::milliseconds sleep_interval = std::chrono::milliseconds(200)) {
+ bool contains(const std::string &ending, std::chrono::seconds timeout = std::chrono::seconds(3), std::chrono::milliseconds sleep_interval = std::chrono::milliseconds(200)) const {
return contains(log_output, ending, timeout, sleep_interval);
}
bool contains(const std::ostringstream &stream, const std::string &ending,
std::chrono::seconds timeout = std::chrono::seconds(3),
- std::chrono::milliseconds sleep_interval = std::chrono::milliseconds(200));
+ std::chrono::milliseconds sleep_interval = std::chrono::milliseconds(200)) const;
std::optional<std::smatch> matchesRegex(const std::string ®ex_str,
std::chrono::seconds timeout = std::chrono::seconds(3),
- std::chrono::milliseconds sleep_interval = std::chrono::milliseconds(200));
+ std::chrono::milliseconds sleep_interval = std::chrono::milliseconds(200)) const;
int countOccurrences(const std::string& pattern) const;
void reset();
- void resetStream(std::ostringstream &stream);
+ static void resetStream(std::ostringstream &stream);
std::shared_ptr<std::ostringstream> log_output_ptr = std::make_shared<std::ostringstream>();
std::ostringstream& log_output = *log_output_ptr;
diff --git a/libminifi/test/archive-tests/CompressContentTests.cpp b/libminifi/test/archive-tests/CompressContentTests.cpp
index ba10a2cff..df2bcf208 100644
--- a/libminifi/test/archive-tests/CompressContentTests.cpp
+++ b/libminifi/test/archive-tests/CompressContentTests.cpp
@@ -94,7 +94,7 @@ class ReadCallback {
* decompression test. Each such test controller should either be
* CompressTestController or a DecompressTestController.
*/
-class CompressDecompressionTestController : public TestController{
+class CompressDecompressionTestController : public TestController {
protected:
static std::string tempDir_;
static std::string raw_content_path_;
@@ -149,7 +149,7 @@ class CompressDecompressionTestController : public TestController{
helper_session = std::make_shared<core::ProcessSession>(context);
}
- std::shared_ptr<core::FlowFile> importFlowFile(const std::string& content_path) {
+ [[nodiscard]] std::shared_ptr<core::FlowFile> importFlowFile(const std::string& content_path) const {
std::shared_ptr<core::FlowFile> flow = std::static_pointer_cast<core::FlowFile>(helper_session->create());
helper_session->import(content_path, flow, true, 0);
helper_session->flushContent();
@@ -174,7 +174,7 @@ class CompressDecompressionTestController : public TestController{
session->commit();
}
- void read(const std::shared_ptr<core::FlowFile>& file, ReadCallback& reader) {
+ void read(const std::shared_ptr<core::FlowFile>& file, ReadCallback& reader) const {
helper_session->read(file, std::ref(reader));
}
@@ -192,15 +192,15 @@ class CompressDecompressionTestController : public TestController{
}
};
- [[nodiscard]] std::string rawContentPath() const {
+ [[nodiscard]] static std::string rawContentPath() {
return raw_content_path_;
}
- [[nodiscard]] std::string compressedPath() const {
+ [[nodiscard]] static std::string compressedPath() {
return compressed_content_path_;
}
- [[nodiscard]] RawContent getRawContent() const {
+ [[nodiscard]] static RawContent getRawContent() {
std::ifstream file;
file.open(raw_content_path_, std::ios::binary);
std::string contents{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
diff --git a/libminifi/test/archive-tests/ManipulateArchiveTests.cpp b/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
index 63ea5f1bf..65965d16d 100644
--- a/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
+++ b/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
@@ -97,7 +97,8 @@ bool run_archive_test(OrderedTestArchive input_archive, OrderedTestArchive outpu
}
bool run_archive_test(TAE_MAP_T input_map, TAE_MAP_T output_map, PROP_MAP_T properties, bool check_attributes = true) {
- OrderedTestArchive input_archive, output_archive;
+ OrderedTestArchive input_archive;
+ OrderedTestArchive output_archive;
// An empty vector is treated as "ignore order"
input_archive.order = output_archive.order = FN_VEC_T();
diff --git a/libminifi/test/aws-tests/PutS3ObjectTests.cpp b/libminifi/test/aws-tests/PutS3ObjectTests.cpp
index 81849d1c5..854e5e87e 100644
--- a/libminifi/test/aws-tests/PutS3ObjectTests.cpp
+++ b/libminifi/test/aws-tests/PutS3ObjectTests.cpp
@@ -26,14 +26,14 @@ using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime;
class PutS3ObjectTestsFixture : public FlowProcessorS3TestsFixture<minifi::aws::processors::PutS3Object> {
public:
- void checkPutObjectResults() {
+ static void checkPutObjectResults() {
REQUIRE(verifyLogLinePresenceInPollTime(std::chrono::seconds(3), "key:s3.version value:" + S3_VERSION_1));
REQUIRE(verifyLogLinePresenceInPollTime(std::chrono::seconds(3), "key:s3.etag value:" + S3_ETAG_UNQUOTED));
REQUIRE(verifyLogLinePresenceInPollTime(std::chrono::seconds(3), "key:s3.expiration value:" + S3_EXPIRATION_DATE));
REQUIRE(verifyLogLinePresenceInPollTime(std::chrono::seconds(3), "key:s3.sseAlgorithm value:" + S3_SSEALGORITHM_STR));
}
- void checkEmptyPutObjectResults() {
+ static void checkEmptyPutObjectResults() {
REQUIRE_FALSE(LogTestController::getInstance().contains("key:s3.version value:", std::chrono::seconds(0), std::chrono::milliseconds(0)));
REQUIRE_FALSE(LogTestController::getInstance().contains("key:s3.etag value:", std::chrono::seconds(0), std::chrono::milliseconds(0)));
REQUIRE_FALSE(LogTestController::getInstance().contains("key:s3.expiration value:", std::chrono::seconds(0), std::chrono::milliseconds(0)));
diff --git a/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp b/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp
index 3b79fce41..010ffcb68 100644
--- a/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp
+++ b/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp
@@ -114,7 +114,8 @@ class EventDriverScheduleErrorHandlingTests: public IntegrationBase {
};
int main(int argc, char **argv) {
- std::string test_file_location, url;
+ std::string test_file_location;
+ std::string url;
if (argc > 1) {
test_file_location = argv[1];
}
diff --git a/libminifi/test/pcap-tests/PcapTest.cpp b/libminifi/test/pcap-tests/PcapTest.cpp
index 4e408f4a1..23df72a8d 100644
--- a/libminifi/test/pcap-tests/PcapTest.cpp
+++ b/libminifi/test/pcap-tests/PcapTest.cpp
@@ -94,7 +94,9 @@ class PcapTestHarness : public IntegrationBase {
};
int main(int argc, char **argv) {
- std::string key_dir, test_file_location, url;
+ std::string key_dir;
+ std::string test_file_location;
+ std::string url;
if (argc > 1) {
test_file_location = argv[1];
diff --git a/libminifi/test/sensors-tests/SensorTests.cpp b/libminifi/test/sensors-tests/SensorTests.cpp
index a91e76010..d4432b26e 100644
--- a/libminifi/test/sensors-tests/SensorTests.cpp
+++ b/libminifi/test/sensors-tests/SensorTests.cpp
@@ -85,7 +85,9 @@ class PcapTestHarness : public IntegrationBase {
};
int main(int argc, char **argv) {
- std::string key_dir, test_file_location, url;
+ std::string key_dir;
+ std::string test_file_location;
+ std::string url;
if (argc > 1) {
test_file_location = argv[1];
diff --git a/libminifi/test/sql-tests/SQLColumnIdentifierTests.cpp b/libminifi/test/sql-tests/SQLColumnIdentifierTests.cpp
index 293b5efaa..d42960ff0 100644
--- a/libminifi/test/sql-tests/SQLColumnIdentifierTests.cpp
+++ b/libminifi/test/sql-tests/SQLColumnIdentifierTests.cpp
@@ -53,5 +53,5 @@ TEST_CASE("Hashing is escape-agnostic") {
REQUIRE(ids.count(SQLColumnIdentifier("[Abc]")) == 1);
REQUIRE(ids.count(SQLColumnIdentifier("`Abc`")) == 1);
REQUIRE(ids.count(SQLColumnIdentifier("Abc")) == 1);
- REQUIRE(ids.count(SQLColumnIdentifier("abc")) == 0);
+ REQUIRE(!ids.contains(SQLColumnIdentifier("abc")));
}
diff --git a/libminifi/test/sql-tests/mocks/MockConnectors.h b/libminifi/test/sql-tests/mocks/MockConnectors.h
index 5d1e8d590..f559f1250 100644
--- a/libminifi/test/sql-tests/mocks/MockConnectors.h
+++ b/libminifi/test/sql-tests/mocks/MockConnectors.h
@@ -114,7 +114,7 @@ class MockDB {
* @param condition_str SQL WHERE condition string with only AND logical operators
* @return Function object evaluating MockRow according to the condition parameter
*/
- std::function<bool(const MockRow&)> parseWhereCondition(const std::string& condition_str);
+ static std::function<bool(const MockRow&)> parseWhereCondition(const std::string& condition_str);
static DataType stringToDataType(const std::string& type_str);
static std::string dataTypeToString(DataType data_type);
diff --git a/libminifi/test/unit/BackTraceTests.cpp b/libminifi/test/unit/BackTraceTests.cpp
index 9a14ffe69..27fbc5401 100644
--- a/libminifi/test/unit/BackTraceTests.cpp
+++ b/libminifi/test/unit/BackTraceTests.cpp
@@ -41,17 +41,13 @@ class WorkerNumberExecutions : public utils::AfterExecute<int> {
}
bool isFinished(const int &result) override {
- if (result > 0 && ++runs < tasks) {
- return false;
- } else {
- return true;
- }
+ return result <= 0 || ++runs >= tasks;
}
bool isCancelled(const int& /*result*/) override {
return false;
}
- int getRuns() {
+ [[nodiscard]] int getRuns() const {
return runs;
}
diff --git a/libminifi/test/unit/ClassUtilsTests.cpp b/libminifi/test/unit/ClassUtilsTests.cpp
index 2382bdda6..95a9a79cf 100644
--- a/libminifi/test/unit/ClassUtilsTests.cpp
+++ b/libminifi/test/unit/ClassUtilsTests.cpp
@@ -23,7 +23,8 @@
#include "../Catch.h"
TEST_CASE("Test ShortNames", "[testcrc1]") {
- std::string className, adjusted;
+ std::string className;
+ std::string adjusted;
SECTION("EMPTY") {
className = "";
adjusted = "";
diff --git a/libminifi/test/unit/FileUtilsTests.cpp b/libminifi/test/unit/FileUtilsTests.cpp
index eabb29ee0..9cd01f59a 100644
--- a/libminifi/test/unit/FileUtilsTests.cpp
+++ b/libminifi/test/unit/FileUtilsTests.cpp
@@ -58,8 +58,8 @@ TEST_CASE("TestFileUtils::get_parent_path", "[TestGetParentPath]") {
REQUIRE("C:\\foo\\" == FileUtils::get_parent_path("C:\\foo\\bar\\"));
REQUIRE("C:\\" == FileUtils::get_parent_path("C:\\foo"));
REQUIRE("C:\\" == FileUtils::get_parent_path("C:\\foo\\"));
- REQUIRE("" == FileUtils::get_parent_path("C:\\"));
- REQUIRE("" == FileUtils::get_parent_path("C:\\\\"));
+ REQUIRE("" == FileUtils::get_parent_path("C:\\")); // NOLINT(readability-container-size-empty)
+ REQUIRE("" == FileUtils::get_parent_path("C:\\\\")); // NOLINT(readability-container-size-empty)
#else
REQUIRE("foo/" == FileUtils::get_parent_path("foo/bar"));
REQUIRE("foo/" == FileUtils::get_parent_path("foo/bar/"));
@@ -67,8 +67,8 @@ TEST_CASE("TestFileUtils::get_parent_path", "[TestGetParentPath]") {
REQUIRE("/foo/" == FileUtils::get_parent_path("/foo/bar/"));
REQUIRE("/" == FileUtils::get_parent_path("/foo"));
REQUIRE("/" == FileUtils::get_parent_path("/foo/"));
- REQUIRE("" == FileUtils::get_parent_path("/"));
- REQUIRE("" == FileUtils::get_parent_path("//"));
+ REQUIRE("" == FileUtils::get_parent_path("/")); // NOLINT(readability-container-size-empty)
+ REQUIRE("" == FileUtils::get_parent_path("//")); // NOLINT(readability-container-size-empty)
#endif
}
@@ -80,8 +80,8 @@ TEST_CASE("TestFileUtils::get_child_path", "[TestGetChildPath]") {
REQUIRE("bar\\" == FileUtils::get_child_path("C:\\foo\\bar\\"));
REQUIRE("foo" == FileUtils::get_child_path("C:\\foo"));
REQUIRE("foo\\" == FileUtils::get_child_path("C:\\foo\\"));
- REQUIRE("" == FileUtils::get_child_path("C:\\"));
- REQUIRE("" == FileUtils::get_child_path("C:\\\\"));
+ REQUIRE("" == FileUtils::get_child_path("C:\\")); // NOLINT(readability-container-size-empty)
+ REQUIRE("" == FileUtils::get_child_path("C:\\\\")); // NOLINT(readability-container-size-empty)
#else
REQUIRE("bar" == FileUtils::get_child_path("foo/bar"));
REQUIRE("bar/" == FileUtils::get_child_path("foo/bar/"));
@@ -89,8 +89,8 @@ TEST_CASE("TestFileUtils::get_child_path", "[TestGetChildPath]") {
REQUIRE("bar/" == FileUtils::get_child_path("/foo/bar/"));
REQUIRE("foo" == FileUtils::get_child_path("/foo"));
REQUIRE("foo/" == FileUtils::get_child_path("/foo/"));
- REQUIRE("" == FileUtils::get_child_path("/"));
- REQUIRE("" == FileUtils::get_child_path("//"));
+ REQUIRE("" == FileUtils::get_child_path("/")); // NOLINT(readability-container-size-empty)
+ REQUIRE("" == FileUtils::get_child_path("//")); // NOLINT(readability-container-size-empty)
#endif
}
@@ -100,7 +100,8 @@ TEST_CASE("TestFilePath", "[TestGetFileNameAndPath]") {
path << "a" << FileUtils::get_separator() << "b" << FileUtils::get_separator() << "c";
std::stringstream file;
file << path.str() << FileUtils::get_separator() << "file";
- std::string filename, filepath;
+ std::string filename;
+ std::string filepath;
REQUIRE(true == utils::file::getFileNameAndPath(file.str(), filepath, filename) );
REQUIRE(path.str() == filepath);
REQUIRE("file" == filename);
@@ -108,7 +109,8 @@ TEST_CASE("TestFilePath", "[TestGetFileNameAndPath]") {
SECTION("NO FILE VALID PATH") {
std::stringstream path;
path << "a" << FileUtils::get_separator() << "b" << FileUtils::get_separator() << "c" << FileUtils::get_separator();
- std::string filename, filepath;
+ std::string filename;
+ std::string filepath;
REQUIRE(false == utils::file::getFileNameAndPath(path.str(), filepath, filename) );
REQUIRE(filepath.empty());
REQUIRE(filename.empty());
@@ -116,7 +118,8 @@ SECTION("NO FILE VALID PATH") {
SECTION("FILE NO PATH") {
std::stringstream path;
path << FileUtils::get_separator() << "file";
- std::string filename, filepath;
+ std::string filename;
+ std::string filepath;
std::string expectedPath;
expectedPath += FileUtils::get_separator();
REQUIRE(true == utils::file::getFileNameAndPath(path.str(), filepath, filename) );
@@ -125,7 +128,8 @@ SECTION("FILE NO PATH") {
}
SECTION("NO FILE NO PATH") {
std::string path = "file";
- std::string filename, filepath;
+ std::string filename;
+ std::string filepath;
REQUIRE(false == utils::file::getFileNameAndPath(path, filepath, filename) );
REQUIRE(filepath.empty());
REQUIRE(filename.empty());
@@ -135,13 +139,13 @@ SECTION("NO FILE NO PATH") {
TEST_CASE("TestFileUtils::get_executable_path", "[TestGetExecutablePath]") {
std::string executable_path = FileUtils::get_executable_path();
std::cerr << "Executable path: " << executable_path << std::endl;
- REQUIRE(0U < executable_path.size());
+ REQUIRE(!executable_path.empty());
}
TEST_CASE("TestFileUtils::get_executable_dir", "[TestGetExecutableDir]") {
std::string executable_path = FileUtils::get_executable_path();
std::string executable_dir = FileUtils::get_executable_dir();
- REQUIRE(0U < executable_dir.size());
+ REQUIRE(!executable_dir.empty());
std::cerr << "Executable dir: " << executable_dir << std::endl;
REQUIRE(FileUtils::get_parent_path(executable_path) == executable_dir);
}
@@ -397,9 +401,9 @@ TEST_CASE("FileUtils::file_size works", "[file_size]") {
}
TEST_CASE("FileUtils::computeChecksum works", "[computeChecksum]") {
- constexpr uint64_t CHECKSUM_OF_0_BYTES = 0u;
- constexpr uint64_t CHECKSUM_OF_4_BYTES = 2117232040u;
- constexpr uint64_t CHECKSUM_OF_11_BYTES = 3461392622u;
+ constexpr uint64_t CHECKSUM_OF_0_BYTES = 0U;
+ constexpr uint64_t CHECKSUM_OF_4_BYTES = 2117232040U;
+ constexpr uint64_t CHECKSUM_OF_11_BYTES = 3461392622U;
TestController testController;
@@ -439,11 +443,11 @@ TEST_CASE("FileUtils::computeChecksum works", "[computeChecksum]") {
}
TEST_CASE("FileUtils::computeChecksum with large files", "[computeChecksum]") {
- constexpr uint64_t CHECKSUM_OF_0_BYTES = 0u;
- constexpr uint64_t CHECKSUM_OF_4095_BYTES = 1902799545u;
- constexpr uint64_t CHECKSUM_OF_4096_BYTES = 1041266625u;
- constexpr uint64_t CHECKSUM_OF_4097_BYTES = 1619129554u;
- constexpr uint64_t CHECKSUM_OF_8192_BYTES = 305726917u;
+ constexpr uint64_t CHECKSUM_OF_0_BYTES = 0U;
+ constexpr uint64_t CHECKSUM_OF_4095_BYTES = 1902799545U;
+ constexpr uint64_t CHECKSUM_OF_4096_BYTES = 1041266625U;
+ constexpr uint64_t CHECKSUM_OF_4097_BYTES = 1619129554U;
+ constexpr uint64_t CHECKSUM_OF_8192_BYTES = 305726917U;
TestController testController;
diff --git a/libminifi/test/unit/RegexUtilsTests.cpp b/libminifi/test/unit/RegexUtilsTests.cpp
index 2a01ce565..40a50509b 100644
--- a/libminifi/test/unit/RegexUtilsTests.cpp
+++ b/libminifi/test/unit/RegexUtilsTests.cpp
@@ -44,9 +44,9 @@ TEST_CASE("TestRegexUtils::invalid_construction", "[regex2]") {
}
TEST_CASE("TestRegexUtils::empty_input", "[regex3]") {
- std::string pat = "";
+ std::string pat;
std::string rgx1 = "Speed limit ([0-9]+)";
- std::string rgx2 = "";
+ std::string rgx2;
std::string rgx3 = "(.*)";
std::vector<Regex::Mode> mode = {Regex::Mode::ICASE};
Regex r1(rgx1, mode);
@@ -100,7 +100,7 @@ TEST_CASE("TestRegexUtils::regexMatch works with groups", "[matchesFullInput]")
REQUIRE(matches[0].str() == "Speed limit 130 all the way");
REQUIRE(matches[1].str() == "130");
REQUIRE(matches[2].str() == "all the way");
- REQUIRE("" == matches.suffix().str());
+ REQUIRE(matches.suffix().str().empty());
}
TEST_CASE("TestRegexUtils::getLastRegexMatch works correctly", "[getLastRegexMatch]") {
diff --git a/libminifi/test/unit/ThreadPoolTests.cpp b/libminifi/test/unit/ThreadPoolTests.cpp
index 88069326a..eec7c9ced 100644
--- a/libminifi/test/unit/ThreadPoolTests.cpp
+++ b/libminifi/test/unit/ThreadPoolTests.cpp
@@ -39,17 +39,13 @@ class WorkerNumberExecutions : public utils::AfterExecute<int> {
}
bool isFinished(const int &result) override {
- if (result > 0 && ++runs < tasks) {
- return false;
- } else {
- return true;
- }
+ return result <= 0 || ++runs >= tasks;
}
bool isCancelled(const int& /*result*/) override {
return false;
}
- int getRuns() {
+ [[nodiscard]] int getRuns() const {
return runs;
}
diff --git a/main/AgentDocs.cpp b/main/AgentDocs.cpp
index 4c40dbda2..5d4f00086 100644
--- a/main/AgentDocs.cpp
+++ b/main/AgentDocs.cpp
@@ -28,7 +28,7 @@
namespace org::apache::nifi::minifi::docs {
-std::string AgentDocs::extractClassName(const std::string &processor) const {
+std::string AgentDocs::extractClassName(const std::string &processor) {
auto positionOfLastDot = processor.find_last_of('.');
if (positionOfLastDot != std::string::npos) {
return processor.substr(positionOfLastDot + 1);
diff --git a/main/AgentDocs.h b/main/AgentDocs.h
index 1b880b3eb..5ed7e55c2 100644
--- a/main/AgentDocs.h
+++ b/main/AgentDocs.h
@@ -26,7 +26,7 @@ class AgentDocs {
public:
void generate(const std::string &docsdir, std::ostream &genStream);
private:
- [[nodiscard]] inline std::string extractClassName(const std::string &processor) const;
+ [[nodiscard]] static std::string extractClassName(const std::string &processor);
BuildDescription build_description_;
};
diff --git a/main/MainHelper.cpp b/main/MainHelper.cpp
index c7e148fde..77883a172 100644
--- a/main/MainHelper.cpp
+++ b/main/MainHelper.cpp
@@ -112,7 +112,8 @@ std::string determineMinifiHome(const std::shared_ptr<logging::Logger>& logger)
if (executablePath.empty()) {
logger->log_error("Failed to determine location of the minifi executable");
} else {
- std::string minifiPath, minifiFileName;
+ std::string minifiPath;
+ std::string minifiFileName;
std::tie(minifiPath, minifiFileName) = minifi::utils::file::split_path(executablePath);
logger->log_info("Inferred " MINIFI_HOME_ENV_KEY "=%s based on the minifi executable location %s", minifiPath, executablePath);
return minifiPath;
@@ -145,9 +146,10 @@ std::string determineMinifiHome(const std::shared_ptr<logging::Logger>& logger)
} else {
logger->log_info("%s is not a valid " MINIFI_HOME_ENV_KEY ", because there is no " DEFAULT_NIFI_PROPERTIES_FILE " file in it.", minifiHome);
- std::string minifiHomeWithoutBin, binDir;
+ std::string minifiHomeWithoutBin;
+ std::string binDir;
std::tie(minifiHomeWithoutBin, binDir) = minifi::utils::file::split_path(minifiHome);
- if (minifiHomeWithoutBin != "" && (binDir == "bin" || binDir == std::string("bin") + minifi::utils::file::get_separator())) {
+ if (!minifiHomeWithoutBin.empty() && (binDir == "bin" || binDir == std::string("bin") + minifi::utils::file::get_separator())) {
if (validHome(minifiHomeWithoutBin)) {
logger->log_info("%s is a valid " MINIFI_HOME_ENV_KEY ", falling back to it.", minifiHomeWithoutBin);
minifiHomeValid = true;
diff --git a/main/MiNiFiMain.cpp b/main/MiNiFiMain.cpp
index b901f623e..3a8aad0c2 100644
--- a/main/MiNiFiMain.cpp
+++ b/main/MiNiFiMain.cpp
@@ -254,7 +254,8 @@ int main(int argc, char **argv) {
std::cerr << "Dumping docs to " << argv[2] << std::endl;
if (argc == 4) {
- std::string filepath, filename;
+ std::string filepath;
+ std::string filename;
utils::file::PathUtils::getFileNameAndPath(argv[3], filepath, filename);
if (filepath == argv[2]) {
std::cerr << "Target file should be out of the working directory: " << filepath << std::endl;