Skip to content

Commit

Permalink
MINIFICPP-1203 - Fix all leftover linter recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
hunyadi-dev committed May 22, 2020
1 parent 95a394e commit a0dc345
Show file tree
Hide file tree
Showing 66 changed files with 396 additions and 504 deletions.
1 change: 0 additions & 1 deletion CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
set noparent
filter=-runtime/reference,-runtime/string,-build/c++11

6 changes: 2 additions & 4 deletions extensions/http-curl/client/HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ HTTPClient::~HTTPClient() {
}

void HTTPClient::forceClose() {

if (nullptr != callback) {
callback->stop = true;
}

if (nullptr != write_callback_) {
write_callback_->stop = true;
}

}

int HTTPClient::debug_callback(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr) {
Expand Down Expand Up @@ -142,7 +140,7 @@ bool HTTPClient::setSpecificSSLVersion(SSLVersion specific_version) {
#endif
}

/* If not set, the default will be TLS 1.0, see https://curl.haxx.se/libcurl/c/CURLOPT_SSLVERSION.html */
// If not set, the default will be TLS 1.0, see https://curl.haxx.se/libcurl/c/CURLOPT_SSLVERSION.html
bool HTTPClient::setMinimumSSLVersion(SSLVersion minimum_version) {
CURLcode ret = CURLE_UNKNOWN_OPTION;
switch (minimum_version) {
Expand Down Expand Up @@ -186,7 +184,7 @@ void HTTPClient::setUploadCallback(HTTPUploadCallback *callbackObj) {
logger_->log_debug("Setting callback for %s", url_);
write_callback_ = callbackObj;
if (method_ == "put" || method_ == "PUT") {
curl_easy_setopt(http_session_, CURLOPT_INFILESIZE_LARGE, (curl_off_t ) callbackObj->ptr->getBufferSize());
curl_easy_setopt(http_session_, CURLOPT_INFILESIZE_LARGE, (curl_off_t) callbackObj->ptr->getBufferSize());
}
curl_easy_setopt(http_session_, CURLOPT_READFUNCTION, &utils::HTTPRequestResponse::send_write);
curl_easy_setopt(http_session_, CURLOPT_READDATA, static_cast<void*>(callbackObj));
Expand Down
47 changes: 23 additions & 24 deletions extensions/http-curl/client/HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __HTTP_UTILS_H__
#define __HTTP_UTILS_H__
#ifndef EXTENSIONS_HTTP_CURL_CLIENT_HTTPCLIENT_H_
#define EXTENSIONS_HTTP_CURL_CLIENT_HTTPCLIENT_H_

#include "utils/HTTPClient.h"
#ifdef WIN32
Expand All @@ -29,16 +29,18 @@
#else
#include <curl/curl.h>
#endif
#include <curl/easy.h>
#include <vector>
#include <memory>
#include <iostream>
#include <map>
#include <chrono>
#include <string>
#include <curl/easy.h>
#ifdef WIN32
#include <regex>
#else
#include <regex.h>
#endif
#include <chrono>

#include "utils/ByteArrayCallback.h"
#include "controllers/SSLContextService.h"
Expand All @@ -63,52 +65,51 @@ namespace utils {
*/
class HTTPClient : public BaseHTTPClient, public core::Connectable {
public:

HTTPClient();

HTTPClient(std::string name, utils::Identifier uuid);

HTTPClient(const std::string &url, const std::shared_ptr<minifi::controllers::SSLContextService> ssl_context_service = nullptr);
explicit HTTPClient(const std::string &url, const std::shared_ptr<minifi::controllers::SSLContextService> ssl_context_service = nullptr);

~HTTPClient();

static int debug_callback(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr);

virtual void setVerbose(bool use_stderr = false) override;
void setVerbose(bool use_stderr = false) override;

void forceClose();

virtual void initialize(const std::string &method, const std::string url = "", const std::shared_ptr<minifi::controllers::SSLContextService> ssl_context_service = nullptr) override;
void initialize(const std::string &method, const std::string url = "", const std::shared_ptr<minifi::controllers::SSLContextService> ssl_context_service = nullptr) override;

// This is a bad API and deprecated. Use the std::chrono variant of this
// It is assumed that the value of timeout provided to this function
// is in seconds units
DEPRECATED(/*deprecated in*/ 0.8.0, /*will remove in */ 2.0) virtual void setConnectionTimeout(int64_t timeout) override;
DEPRECATED(/*deprecated in*/ 0.8.0, /*will remove in */ 2.0) void setConnectionTimeout(int64_t timeout) override;

// This is a bad API and deprecated. Use the std::chrono variant of this
// It is assumed that the value of timeout provided to this function
// is in seconds units
DEPRECATED(/*deprecated in*/ 0.8.0, /*will remove in */ 2.0) virtual void setReadTimeout(int64_t timeout) override;
DEPRECATED(/*deprecated in*/ 0.8.0, /*will remove in */ 2.0) void setReadTimeout(int64_t timeout) override;

virtual void setConnectionTimeout(std::chrono::milliseconds timeout) override;
void setConnectionTimeout(std::chrono::milliseconds timeout) override;

virtual void setReadTimeout(std::chrono::milliseconds timeout) override;
void setReadTimeout(std::chrono::milliseconds timeout) override;

virtual void setUploadCallback(HTTPUploadCallback *callbackObj) override;
void setUploadCallback(HTTPUploadCallback *callbackObj) override;

virtual void setReadCallback(HTTPReadCallback *callbackObj);

struct curl_slist *build_header_list(std::string regex, const std::map<std::string, std::string> &attributes);

virtual void setContentType(std::string content_type) override;
void setContentType(std::string content_type) override;

virtual std::string escape(std::string string_to_escape) override;
std::string escape(std::string string_to_escape) override;

virtual void setPostFields(const std::string& input) override;
void setPostFields(const std::string& input) override;

void setHeaders(struct curl_slist *list);

virtual void appendHeader(const std::string &new_header) override;
void appendHeader(const std::string &new_header) override;

void appendHeader(const std::string &key, const std::string &value);

Expand Down Expand Up @@ -161,7 +162,7 @@ class HTTPClient : public BaseHTTPClient, public core::Connectable {

void setInterface(const std::string &);

virtual const std::map<std::string, std::string> &getParsedHeaders() override {
const std::map<std::string, std::string> &getParsedHeaders() override {
return header_response_.getHeaderMap();
}

Expand All @@ -186,7 +187,7 @@ class HTTPClient : public BaseHTTPClient, public core::Connectable {
/**
* Determines if we are connected and operating
*/
virtual bool isRunning() override {
bool isRunning() override {
return true;
}

Expand All @@ -197,15 +198,14 @@ class HTTPClient : public BaseHTTPClient, public core::Connectable {
void waitForWork(uint64_t timeoutMs) {
}

virtual void yield() override {

void yield() override {
}

/**
* Determines if work is available by this connectable
* @return boolean if work is available.
*/
virtual bool isWorkAvailable() override {
bool isWorkAvailable() override {
return true;
}

Expand Down Expand Up @@ -239,7 +239,6 @@ class HTTPClient : public BaseHTTPClient, public core::Connectable {
Progress progress_;

protected:

inline bool matches(const std::string &value, const std::string &sregex) override;

static CURLcode configure_ssl_context(CURL *curl, void *ctx, void *param) {
Expand Down Expand Up @@ -293,4 +292,4 @@ class HTTPClient : public BaseHTTPClient, public core::Connectable {
} /* namespace apache */
} /* namespace org */

#endif
#endif // EXTENSIONS_HTTP_CURL_CLIENT_HTTPCLIENT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __UNORDERED_MAP_KEY_VALUE_STORE_SERVICE_H__
#define __UNORDERED_MAP_KEY_VALUE_STORE_SERVICE_H__
#ifndef EXTENSIONS_STANDARD_PROCESSORS_CONTROLLERS_UNORDEREDMAPKEYVALUESTORESERVICE_H_
#define EXTENSIONS_STANDARD_PROCESSORS_CONTROLLERS_UNORDEREDMAPKEYVALUESTORESERVICE_H_

#include <unordered_map>
#include <string>
#include <mutex>
#include <memory>
#include <utility>

#include "controllers/keyvalue/KeyValueStoreService.h"
#include "core/Core.h"
Expand All @@ -24,12 +30,6 @@
#include "core/logging/LoggerConfiguration.h"
#include "core/Resource.h"

#include <unordered_map>
#include <string>
#include <mutex>
#include <memory>
#include <utility>

namespace org {
namespace apache {
namespace nifi {
Expand All @@ -44,17 +44,17 @@ class UnorderedMapKeyValueStoreService : virtual public KeyValueStoreService {

virtual ~UnorderedMapKeyValueStoreService();

virtual bool set(const std::string& key, const std::string& value) override;
bool set(const std::string& key, const std::string& value) override;

virtual bool get(const std::string& key, std::string& value) override;
bool get(const std::string& key, std::string& value) override;

virtual bool get(std::unordered_map<std::string, std::string>& kvs) override;
bool get(std::unordered_map<std::string, std::string>& kvs) override;

virtual bool remove(const std::string& key) override;
bool remove(const std::string& key) override;

virtual bool clear() override;
bool clear() override;

virtual bool update(const std::string& key, const std::function<bool(bool /*exists*/, std::string& /*value*/)>& update_func) override;
bool update(const std::string& key, const std::function<bool(bool /*exists*/, std::string& /*value*/)>& update_func) override;

protected:
std::unordered_map<std::string, std::string> map_;
Expand All @@ -72,4 +72,4 @@ REGISTER_RESOURCE(UnorderedMapKeyValueStoreService, "A key-value service impleme
} /* namespace apache */
} /* namespace org */

#endif /* __UNORDERED_MAP_KEY_VALUE_STORE_SERVICE_H__ */
#endif // EXTENSIONS_STANDARD_PROCESSORS_CONTROLLERS_UNORDEREDMAPKEYVALUESTORESERVICE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __UNORDERED_MAP_PERSISTABLE_KEY_VALUE_STORE_SERVICE_H__
#define __UNORDERED_MAP_PERSISTABLE_KEY_VALUE_STORE_SERVICE_H__
#ifndef EXTENSIONS_STANDARD_PROCESSORS_CONTROLLERS_UNORDEREDMAPPERSISTABLEKEYVALUESTORESERVICE_H_
#define EXTENSIONS_STANDARD_PROCESSORS_CONTROLLERS_UNORDEREDMAPPERSISTABLEKEYVALUESTORESERVICE_H_

#include <unordered_map>
#include <string>
#include <mutex>
#include <memory>
#include <utility>

#include "controllers/keyvalue/AbstractAutoPersistingKeyValueStoreService.h"
#include "UnorderedMapKeyValueStoreService.h"
Expand All @@ -25,12 +31,6 @@
#include "core/logging/LoggerConfiguration.h"
#include "core/Resource.h"

#include <unordered_map>
#include <string>
#include <mutex>
#include <memory>
#include <utility>

namespace org {
namespace apache {
namespace nifi {
Expand All @@ -48,19 +48,19 @@ class UnorderedMapPersistableKeyValueStoreService : public AbstractAutoPersistin

static core::Property File;

virtual void onEnable() override;
virtual void initialize() override;
virtual void notifyStop() override;
void onEnable() override;
void initialize() override;
void notifyStop() override;

virtual bool set(const std::string& key, const std::string& value) override;
bool set(const std::string& key, const std::string& value) override;

virtual bool remove(const std::string& key) override;
bool remove(const std::string& key) override;

virtual bool clear() override;
bool clear() override;

virtual bool update(const std::string& key, const std::function<bool(bool /*exists*/, std::string& /*value*/)>& update_func) override;
bool update(const std::string& key, const std::function<bool(bool /*exists*/, std::string& /*value*/)>& update_func) override;

virtual bool persist() override;
bool persist() override;

protected:
static constexpr const char* FORMAT_VERSION_KEY = "__UnorderedMapPersistableKeyValueStoreService_FormatVersion";
Expand All @@ -85,4 +85,4 @@ REGISTER_RESOURCE(UnorderedMapPersistableKeyValueStoreService, "A persistable ke
} /* namespace apache */
} /* namespace org */

#endif /* __UNORDERED_MAP_PERSISTABLE_KEY_VALUE_STORE_SERVICE_H__ */
#endif // EXTENSIONS_STANDARD_PROCESSORS_CONTROLLERS_UNORDEREDMAPPERSISTABLEKEYVALUESTORESERVICE_H_
3 changes: 0 additions & 3 deletions extensions/standard-processors/processors/ExecuteProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include <thread>

#ifndef WIN32
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>

#endif
Expand Down Expand Up @@ -130,7 +128,6 @@ REGISTER_RESOURCE(ExecuteProcess, "Runs an operating system command specified by
"as it typically does not make sense to split binary data on arbitrary time-based intervals.");
#endif
} // namespace processors
/* namespace processors */
} /* namespace minifi */
} /* namespace nifi */
} /* namespace apache */
Expand Down
2 changes: 1 addition & 1 deletion extensions/standard-processors/processors/GetTCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "core/ProcessSession.h"
#include "core/Core.h"
#include "core/Resource.h"
#include "concurrentqueue.h"
#include "concurrentqueue.h" // NOLINT
#include "utils/ThreadPool.h"
#include "core/logging/LoggerConfiguration.h"
#include "controllers/SSLContextService.h"
Expand Down

0 comments on commit a0dc345

Please sign in to comment.