Skip to content

Commit

Permalink
MINIFICPP-1203 - Remove build/include suppression from linter, reorde…
Browse files Browse the repository at this point in the history
…r corresponding .cpp files

MINIFICPP-1203 - Enable linting for headers

MINIFICPP-1203 - Rename header guards according to linter recommendations

MINIFICPP-1203 - Remove linter errors due to visibility modifiers following each other

MINIFICPP-1203 - Add NOLINT rule to lines longer than 200 characters

MINIFICPP-1203 - Fix missing includes according to linter recommendations

MINIFICPP-1203 - Resolve include order linter recommendations

Tool used:
https://github.com/TheOstrichIO/cpplint/tree/nitpick-sort-includes/cpplint

Signed-off-by: Arpad Boda <aboda@apache.org>

This closes #789
  • Loading branch information
hunyadi-dev authored and arpadboda committed Jun 15, 2020
1 parent 60c463e commit 2362fff
Show file tree
Hide file tree
Showing 217 changed files with 2,806 additions and 2,801 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

3 changes: 0 additions & 3 deletions extensions/expression-language/ExpressionLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

bool ExpressionObjectFactory::added = core::FlowConfiguration::add_static_func("createExpressionFactory");
extern "C" {



void *createExpressionFactory(void) {
return new ExpressionObjectFactory();
}
Expand Down
4 changes: 0 additions & 4 deletions extensions/http-curl/HTTPCurlLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@

bool HttpCurlObjectFactory::added = core::FlowConfiguration::add_static_func("createHttpCurlFactory");
extern "C" {



void *createHttpCurlFactory(void) {
return new HttpCurlObjectFactory();
}

}
16 changes: 7 additions & 9 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 Expand Up @@ -419,8 +417,8 @@ void HTTPClient::setInterface(const std::string &ifc) {
curl_easy_setopt(http_session_, CURLOPT_INTERFACE, ifc.c_str());
}

} /* namespace utils */
} /* namespace minifi */
} /* namespace nifi */
} /* namespace apache */
} /* namespace org */
} // namespace utils
} // namespace minifi
} // namespace nifi
} // namespace apache
} // namespace org
57 changes: 28 additions & 29 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 @@ -287,10 +286,10 @@ class HTTPClient : public BaseHTTPClient, public core::Connectable {
std::shared_ptr<logging::Logger> logger_{logging::LoggerFactory<HTTPClient>::getLogger()};
};

} /* namespace utils */
} /* namespace minifi */
} /* namespace nifi */
} /* namespace apache */
} /* namespace org */
} // namespace utils
} // namespace minifi
} // namespace nifi
} // namespace apache
} // namespace org

#endif
#endif // EXTENSIONS_HTTP_CURL_CLIENT_HTTPCLIENT_H_
10 changes: 5 additions & 5 deletions extensions/librdkafka/KafkaConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ void KafkaConnection::logCallback(const rd_kafka_t* rk, int level, const char* /
}
}

} /* namespace processors */
} /* namespace minifi */
} /* namespace nifi */
} /* namespace apache */
} /* namespace org */
} // namespace processors
} // namespace minifi
} // namespace nifi
} // namespace apache
} // namespace org
24 changes: 12 additions & 12 deletions extensions/librdkafka/KafkaConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
* limitations under the License.
*/

#ifndef NIFI_MINIFI_CPP_KAFKACONNECTION_H
#define NIFI_MINIFI_CPP_KAFKACONNECTION_H
#ifndef EXTENSIONS_LIBRDKAFKA_KAFKACONNECTION_H_
#define EXTENSIONS_LIBRDKAFKA_KAFKACONNECTION_H_

#include <atomic>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>

#include "core/logging/LoggerConfiguration.h"
#include "core/logging/Logger.h"
#include "rdkafka.h"
#include "rdkafka.h" // NOLINT
#include "KafkaTopic.h"
#include "utils/gsl.h"

Expand All @@ -36,7 +38,7 @@ namespace minifi {
namespace processors {

class KafkaConnectionKey {
public:
public:
std::string client_id_;
std::string brokers_;

Expand All @@ -47,7 +49,6 @@ class KafkaConnectionKey {

class KafkaConnection {
public:

explicit KafkaConnection(const KafkaConnectionKey &key);

KafkaConnection(const KafkaConnection&) = delete;
Expand Down Expand Up @@ -76,7 +77,6 @@ class KafkaConnection {
static void logCallback(const rd_kafka_t* rk, int level, const char* /*fac*/, const char* buf);

private:

std::shared_ptr<logging::Logger> logger_;

bool initialized_;
Expand Down Expand Up @@ -117,10 +117,10 @@ class KafkaConnection {
}
};

} /* namespace processors */
} /* namespace minifi */
} /* namespace nifi */
} /* namespace apache */
} /* namespace org */
} // namespace processors
} // namespace minifi
} // namespace nifi
} // namespace apache
} // namespace org

#endif //NIFI_MINIFI_CPP_KAFKACONNECTION_H
#endif // EXTENSIONS_LIBRDKAFKA_KAFKACONNECTION_H_
18 changes: 9 additions & 9 deletions extensions/librdkafka/KafkaTopic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

#ifndef NIFI_MINIFI_CPP_KAFKATOPIC_H
#define NIFI_MINIFI_CPP_KAFKATOPIC_H
#ifndef EXTENSIONS_LIBRDKAFKA_KAFKATOPIC_H_
#define EXTENSIONS_LIBRDKAFKA_KAFKATOPIC_H_

#include "rdkafka.h"
#include "rdkafka.h" // NOLINT

#include "utils/gsl.h"

Expand Down Expand Up @@ -48,10 +48,10 @@ class KafkaTopic {
gsl::owner<rd_kafka_topic_t*> topic_reference_;
};

} /* namespace processors */
} /* namespace minifi */
} /* namespace nifi */
} /* namespace apache */
} /* namespace org */
} // namespace processors
} // namespace minifi
} // namespace nifi
} // namespace apache
} // namespace org

#endif //NIFI_MINIFI_CPP_KAFKATOPIC_H
#endif // EXTENSIONS_LIBRDKAFKA_KAFKATOPIC_H_
10 changes: 5 additions & 5 deletions extensions/librdkafka/PublishKafka.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,8 @@ void PublishKafka::onTrigger(const std::shared_ptr<core::ProcessContext> &contex
});
}

} /* namespace processors */
} /* namespace minifi */
} /* namespace nifi */
} /* namespace apache */
} /* namespace org */
} // namespace processors
} // namespace minifi
} // namespace nifi
} // namespace apache
} // namespace org

0 comments on commit 2362fff

Please sign in to comment.