This is an automated email from the ASF dual-hosted git repository. adebreceni pushed a commit to branch minifi-api-reduced in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 59b524ba28df749b57c2670911ffe6b7cf09250e Author: Adam Debreceni <[email protected]> AuthorDate: Mon May 12 17:08:04 2025 +0200 Linter fixes --- extensions/python/PythonCreator.h | 2 +- extensions/sftp/processors/SFTPProcessorBase.h | 2 +- .../tests/unit/DefragmentTextTests.cpp | 2 +- libminifi/src/core/ClassLoader.cpp | 31 +++++++++++----------- minifi-api/include/minifi-cpp/core/ClassLoader.h | 14 +++++----- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/extensions/python/PythonCreator.h b/extensions/python/PythonCreator.h index 3cc2c1284..362f737db 100644 --- a/extensions/python/PythonCreator.h +++ b/extensions/python/PythonCreator.h @@ -60,7 +60,7 @@ class DummyLogger : public core::logging::Logger { bool should_log(core::logging::LOG_LEVEL /*level*/) override { return false; } - [[nodiscard]] virtual core::logging::LOG_LEVEL level() const override { + [[nodiscard]] core::logging::LOG_LEVEL level() const override { return core::logging::LOG_LEVEL::off; } diff --git a/extensions/sftp/processors/SFTPProcessorBase.h b/extensions/sftp/processors/SFTPProcessorBase.h index 628fd652e..a63c57d71 100644 --- a/extensions/sftp/processors/SFTPProcessorBase.h +++ b/extensions/sftp/processors/SFTPProcessorBase.h @@ -40,7 +40,7 @@ namespace org::apache::nifi::minifi::processors { class SFTPProcessorBase : public core::ProcessorImpl { public: - SFTPProcessorBase(core::ProcessorMetadata info); + explicit SFTPProcessorBase(core::ProcessorMetadata info); ~SFTPProcessorBase() override; static constexpr std::string_view PROXY_TYPE_DIRECT = "DIRECT"; diff --git a/extensions/standard-processors/tests/unit/DefragmentTextTests.cpp b/extensions/standard-processors/tests/unit/DefragmentTextTests.cpp index 49a22a8cc..1fb68b0c4 100644 --- a/extensions/standard-processors/tests/unit/DefragmentTextTests.cpp +++ b/extensions/standard-processors/tests/unit/DefragmentTextTests.cpp @@ -39,7 +39,7 @@ TEST_CASE("DefragmentText Single source tests", "[defragmenttextsinglesource]") auto plan = testController.createPlan(); auto write_to_flow_file = plan->addProcessor<WriteToFlowFileTestProcessor>("write_to_flow_file"); auto defrag_text_flow_files = plan->addProcessor<DefragmentText>("defrag_text_flow_files"); - auto read_from_success_relationship = plan->addProcessor<ReadFromFlowFileTestProcessor>( "read_from_success_relationship"); + auto read_from_success_relationship = plan->addProcessor<ReadFromFlowFileTestProcessor>("read_from_success_relationship"); auto read_from_failure_relationship = plan->addProcessor<ReadFromFlowFileTestProcessor>("read_from_failure_relationship"); plan->addConnection(write_to_flow_file, WriteToFlowFileTestProcessor::Success, defrag_text_flow_files); diff --git a/libminifi/src/core/ClassLoader.cpp b/libminifi/src/core/ClassLoader.cpp index a316887e6..b7076b369 100644 --- a/libminifi/src/core/ClassLoader.cpp +++ b/libminifi/src/core/ClassLoader.cpp @@ -31,7 +31,12 @@ class ClassLoaderImpl : public ClassLoader { public: explicit ClassLoaderImpl(std::string name = "/"); - ClassLoader& getClassLoader(const std::string& child_name) override; + ClassLoaderImpl(const ClassLoaderImpl&) = delete; + ClassLoaderImpl(ClassLoaderImpl&&) = delete; + ClassLoaderImpl& operator=(const ClassLoaderImpl&) = delete; + ClassLoaderImpl& operator=(ClassLoaderImpl&&) = delete; + + [[nodiscard]] ClassLoader& getClassLoader(const std::string& child_name) override; void registerClass(const std::string &clazz, std::unique_ptr<ObjectFactory> factory) override; @@ -39,25 +44,21 @@ class ClassLoaderImpl : public ClassLoader { void unregisterClass(const std::string& clazz) override; - std::optional<std::string> getGroupForClass(const std::string &class_name) const override; + [[nodiscard]] std::optional<std::string> getGroupForClass(const std::string &class_name) const override; - std::unique_ptr<CoreComponent> instantiate(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) override; + [[nodiscard]] std::unique_ptr<CoreComponent> instantiate(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) override; - std::unique_ptr<CoreComponent> instantiate(const std::string &class_name, const utils::Identifier &uuid, std::function<bool(CoreComponent*)> filter) override; + [[nodiscard]] std::unique_ptr<CoreComponent> instantiate(const std::string &class_name, const utils::Identifier &uuid, std::function<bool(CoreComponent*)> filter) override; - CoreComponent* instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) override; + [[nodiscard]] CoreComponent* instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) override; ~ClassLoaderImpl() override = default; private: std::map<std::string, std::unique_ptr<ObjectFactory>> loaded_factories_; - std::map<std::string, ClassLoaderImpl> class_loaders_; - mutable std::mutex internal_mutex_; - std::shared_ptr<logging::Logger> logger_; - std::string name_; }; @@ -104,28 +105,28 @@ class ProcessorFactoryWrapper : public ObjectFactoryImpl { : ObjectFactoryImpl(factory->getGroupName()), factory_(std::move(factory)) {} - std::unique_ptr<CoreComponent> create(const std::string &name) override { + [[nodiscard]] std::unique_ptr<CoreComponent> create(const std::string &name) override { return std::unique_ptr<CoreComponent>{createRaw(name)}; } - std::unique_ptr<CoreComponent> create(const std::string &name, const utils::Identifier &uuid) override { + [[nodiscard]] std::unique_ptr<CoreComponent> create(const std::string &name, const utils::Identifier &uuid) override { return std::unique_ptr<CoreComponent>{createRaw(name, uuid)}; } - CoreComponent* createRaw(const std::string &name) override { + [[nodiscard]] CoreComponent* createRaw(const std::string &name) override { return createRaw(name, utils::IdGenerator::getIdGenerator()->generate()); } - CoreComponent* createRaw(const std::string &name, const utils::Identifier &uuid) override { + [[nodiscard]] CoreComponent* createRaw(const std::string &name, const utils::Identifier &uuid) override { auto logger = logging::LoggerFactoryBase::getAliasedLogger(getClassName(), uuid); return new Processor(name, uuid, factory_->create({.uuid = uuid, .name = name, .logger = logger})); } - std::string getGroupName() const override { + [[nodiscard]] std::string getGroupName() const override { return factory_->getGroupName(); } - std::string getClassName() override { + [[nodiscard]] std::string getClassName() override { return factory_->getClassName(); } diff --git a/minifi-api/include/minifi-cpp/core/ClassLoader.h b/minifi-api/include/minifi-cpp/core/ClassLoader.h index ec377de61..72fa03319 100644 --- a/minifi-api/include/minifi-cpp/core/ClassLoader.h +++ b/minifi-api/include/minifi-cpp/core/ClassLoader.h @@ -69,13 +69,13 @@ class ClassLoader { virtual void unregisterClass(const std::string& clazz) = 0; - virtual std::optional<std::string> getGroupForClass(const std::string &class_name) const = 0; + [[nodiscard]] virtual std::optional<std::string> getGroupForClass(const std::string &class_name) const = 0; - virtual std::unique_ptr<CoreComponent> instantiate(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) = 0; + [[nodiscard]] virtual std::unique_ptr<CoreComponent> instantiate(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) = 0; - virtual std::unique_ptr<CoreComponent> instantiate(const std::string &class_name, const utils::Identifier &uuid, std::function<bool(CoreComponent*)> filter) = 0; + [[nodiscard]] virtual std::unique_ptr<CoreComponent> instantiate(const std::string &class_name, const utils::Identifier &uuid, std::function<bool(CoreComponent*)> filter) = 0; - virtual CoreComponent* instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) = 0; + [[nodiscard]] virtual CoreComponent* instantiateRaw(const std::string &class_name, const std::string &name, std::function<bool(CoreComponent*)> filter) = 0; /** * Instantiate object based on class_name @@ -84,7 +84,7 @@ class ClassLoader { * @return nullptr or object created from class_name definition. */ template<class T = CoreComponent> - std::unique_ptr<T> instantiate(const std::string &class_name, const std::string &name); + [[nodiscard]] std::unique_ptr<T> instantiate(const std::string &class_name, const std::string &name); /** * Instantiate object based on class_name @@ -93,7 +93,7 @@ class ClassLoader { * @return nullptr or object created from class_name definition. */ template<class T = CoreComponent> - std::unique_ptr<T> instantiate(const std::string &class_name, const utils::Identifier &uuid); + [[nodiscard]] std::unique_ptr<T> instantiate(const std::string &class_name, const utils::Identifier &uuid); /** * Instantiate object based on class_name @@ -102,7 +102,7 @@ class ClassLoader { * @return nullptr or object created from class_name definition. */ template<class T = CoreComponent> - T *instantiateRaw(const std::string &class_name, const std::string &name); + [[nodiscard]] T *instantiateRaw(const std::string &class_name, const std::string &name); }; } // namespace org::apache::nifi::minifi::core
