Skip to content

Commit 8b005ef

Browse files
committed
linter fixes
1 parent 36fd2be commit 8b005ef

File tree

9 files changed

+42
-40
lines changed

9 files changed

+42
-40
lines changed

extensions/standard-processors/controllers/JsonRecordSetReader.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ nonstd::expected<core::RecordField, std::error_code> parse(const rapidjson::Valu
4141
}
4242
if (json_value.IsString()) {
4343
auto json_str = json_value.GetString();
44-
if (schema && schema->IsString() && std::string_view{schema->GetString()} == "std::chrono::system_clock::time_point") {
44+
if (schema && schema->IsString() && std::string_view {schema->GetString()} == "std::chrono::system_clock::time_point") {
4545
if (auto parsed_time = utils::timeutils::parseRfc3339(json_str)) {
4646
return core::RecordField{.value_ = *parsed_time};
4747
}
@@ -95,7 +95,9 @@ nonstd::expected<core::Record, std::error_code> parseDocument(rapidjson::Documen
9595
}
9696
} // namespace
9797

98-
nonstd::expected<core::RecordSet, std::error_code> JsonRecordSetReader::read(const std::shared_ptr<core::FlowFile>& flow_file, core::ProcessSession& session, const core::RecordSchema* const record_schema) {
98+
nonstd::expected<core::RecordSet, std::error_code> JsonRecordSetReader::read(const std::shared_ptr<core::FlowFile>& flow_file,
99+
core::ProcessSession& session,
100+
const core::RecordSchema* const record_schema) {
99101
core::RecordSet record_set{};
100102
auto read_result = session.read(flow_file, [&record_set, &record_schema](const std::shared_ptr<io::InputStream>& input_stream) -> int64_t {
101103
std::string content;
@@ -106,10 +108,9 @@ nonstd::expected<core::RecordSet, std::error_code> JsonRecordSetReader::read(con
106108
}
107109
std::stringstream ss(content);
108110
std::string line;
109-
while(std::getline(ss, line,'\n')){
111+
while (std::getline(ss, line, '\n')) {
110112
rapidjson::Document document;
111-
rapidjson::ParseResult parse_result = document.Parse<rapidjson::kParseStopWhenDoneFlag>(line);
112-
if (parse_result.IsError())
113+
if (rapidjson::ParseResult parse_result = document.Parse<rapidjson::kParseStopWhenDoneFlag>(line); parse_result.IsError())
113114
return -1;
114115
auto record = parseDocument(document, record_schema);
115116
if (!record)
@@ -123,4 +124,4 @@ nonstd::expected<core::RecordSet, std::error_code> JsonRecordSetReader::read(con
123124
return record_set;
124125
}
125126

126-
} // namespace org::apache::nifi::minifi::standard
127+
} // namespace org::apache::nifi::minifi::standard

extensions/standard-processors/controllers/JsonRecordSetReader.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ class JsonRecordSetReader final : public core::RecordSetReader {
3232
~JsonRecordSetReader() override = default;
3333

3434
EXTENSIONAPI static constexpr const char* Description = "Parses JSON into individual Record objects. "
35-
"While the reader expects each record to be well-formed JSON, the content of a FlowFile may consist of many records, each as a well-formed JSON array or JSON object with optional whitespace between them, such as the common 'JSON-per-line' format. "
35+
"While the reader expects each record to be well-formed JSON, the content of a FlowFile may consist of many records, "
36+
"each as a well-formed JSON array or JSON object with optional whitespace between them, such as the common 'JSON-per-line' format. "
3637
"If an array is encountered, each element in that array will be treated as a separate record. "
37-
"If the schema that is configured contains a field that is not present in the JSON, a null value will be used. If the JSON contains a field that is not present in the schema, that field will be skipped.";
38+
"If the schema that is configured contains a field that is not present in the JSON, a null value will be used. "
39+
"If the JSON contains a field that is not present in the schema, that field will be skipped.";
3840

3941
EXTENSIONAPI static constexpr auto SchemaAccessStrategy = core::PropertyDefinitionBuilder<>::createProperty("Schema Access Strategy")
4042
.withDescription("Specifies how to obtain the schema that is to be used for interpreting the data.")
@@ -56,4 +58,4 @@ class JsonRecordSetReader final : public core::RecordSetReader {
5658
bool isWorkAvailable() override { return false; }
5759
};
5860

59-
} // namespace org::apache::nifi::minifi::standard
61+
} // namespace org::apache::nifi::minifi::standard

extensions/standard-processors/controllers/JsonRecordSetWriter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ rapidjson::Value toJson(const core::RecordObject& record_object, rapidjson::Docu
6363
}
6464
return object_json;
6565
}
66-
}
66+
} // namespace
6767

6868
void JsonRecordSetWriter::write(const core::RecordSet& record_set, const std::shared_ptr<core::FlowFile>& flow_file, core::ProcessSession& session) {
6969
session.write(flow_file, [this, &record_set](const std::shared_ptr<io::OutputStream>& stream) -> int64_t {
@@ -90,4 +90,4 @@ void JsonRecordSetWriter::convertRecord(const core::Record& record, rapidjson::V
9090
}
9191

9292

93-
} // namespace org::apache::nifi::minifi::standard
93+
} // namespace org::apache::nifi::minifi::standard

extensions/standard-processors/controllers/JsonRecordSetWriter.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,22 @@ class JsonRecordSetWriter final : public core::RecordSetWriter {
3131

3232
~JsonRecordSetWriter() override = default;
3333

34-
EXTENSIONAPI static constexpr const char* Description = "Writes the results of a RecordSet as either a JSON Array or one JSON object per line. "
35-
"If using Array output, then even if the RecordSet consists of a single row, it will be written as an array with a single element. "
36-
"If using One Line Per Object output, the JSON objects cannot be pretty-printed.";
34+
EXTENSIONAPI static constexpr const char* Description =
35+
"Writes the results of a RecordSet as either a JSON Array or one JSON object per line. "
36+
"If using Array output, then even if the RecordSet consists of a single row, it will be written as an array with a single element. "
37+
"If using One Line Per Object output, the JSON objects cannot be pretty-printed.";
3738

3839
EXTENSIONAPI static constexpr auto SchemaWriteStrategy = core::PropertyDefinitionBuilder<>::createProperty("Schema Write Strategy")
3940
.withDescription("Specifies how the schema for a Record should be added to the data.")
4041
.supportsExpressionLanguage(true)
4142
.build();
4243
EXTENSIONAPI static constexpr auto OutputGrouping = core::PropertyDefinitionBuilder<>::createProperty("Output Grouping")
43-
.withDescription("Specifies how the writer should output the JSON records (as an array or one object per line, e.g.) Note that if 'One Line Per Object' is selected, then Pretty Print JSON must be false.")
44+
.withDescription("Specifies how the writer should output the JSON records (as an array or one object per line, e.g.) "
45+
"Note that if 'One Line Per Object' is selected, then Pretty Print JSON must be false.")
4446
.supportsExpressionLanguage(true)
4547
.build();
4648
EXTENSIONAPI static constexpr auto Properties = std::array<core::PropertyReference, 1>{
47-
SchemaWriteStrategy,
49+
SchemaWriteStrategy,
4850
};
4951

5052
EXTENSIONAPI static constexpr bool SupportsDynamicProperties = false;
@@ -59,8 +61,8 @@ class JsonRecordSetWriter final : public core::RecordSetWriter {
5961

6062
public:
6163
void yield() override {}
62-
bool isRunning() const override { return getState() == core::controller::ControllerServiceState::ENABLED; }
64+
bool isRunning() const override { return getState() == core::controller::ControllerServiceState::ENABLED; }
6365
bool isWorkAvailable() override { return false; }
6466
};
6567

66-
} // namespace org::apache::nifi::minifi::standard
68+
} // namespace org::apache::nifi::minifi::standard

extensions/standard-processors/tests/unit/JsonRecordTests.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
#include <variant>
2020

2121
#include "Catch.h"
22+
#include "RecordSetTesters.h"
2223
#include "TestBase.h"
2324
#include "TestRecord.h"
24-
#include "RecordSetTesters.h"
25-
#include "controllers/JsonRecordSetWriter.h"
2625
#include "controllers/JsonRecordSetReader.h"
26+
#include "controllers/JsonRecordSetWriter.h"
2727
#include "core/Record.h"
2828

2929
namespace org::apache::nifi::minifi::standard::test {
@@ -34,7 +34,7 @@ TEST_CASE("JsonRecordSetWriter test") {
3434
record_set.push_back(core::test::createSampleRecord2());
3535

3636
constexpr std::string_view expected =
37-
R"({"baz":3.14,"qux":[true,false,true],"is_test":true,"bar":123,"quux":{"Apfel":"apple","Birne":"pear","Aprikose":"apricot"},"foo":"asd","when":"2012-07-01T09:53:00Z"}
37+
R"({"baz":3.14,"qux":[true,false,true],"is_test":true,"bar":123,"quux":{"Apfel":"apple","Birne":"pear","Aprikose":"apricot"},"foo":"asd","when":"2012-07-01T09:53:00Z"}
3838
{"baz":3.141592653589793,"qux":[false,false,true],"is_test":true,"bar":98402134,"quux":{"Apfel":"pomme","Birne":"poire","Aprikose":"abricot"},"foo":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.","when":"2022-11-01T19:52:11Z"}
3939
)";
4040

libminifi/include/controllers/RecordSetReader.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
namespace org::apache::nifi::minifi::core {
2626

2727
class RecordSetReader : public controller::ControllerService {
28-
public:
28+
public:
2929
using ControllerService::ControllerService;
3030

3131
virtual nonstd::expected<RecordSet, std::error_code> read(const std::shared_ptr<FlowFile>& flow_file, ProcessSession& session, const RecordSchema* record_schema) = 0;
3232
};
3333

34-
} // namespace org::apache::nifi::minifi::core
34+
} // namespace org::apache::nifi::minifi::core

libminifi/include/controllers/RecordSetWriter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ class RecordSetWriter : public controller::ControllerService {
3737
virtual void write(const RecordSet& record_set, const std::shared_ptr<FlowFile>& flow_file, ProcessSession& session) = 0;
3838
};
3939

40-
} // namespace org::apache::nifi::minifi::core
40+
} // namespace org::apache::nifi::minifi::core

libminifi/test/RecordSetTesters.h

+8-9
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,22 @@
1717
*/
1818

1919
#pragma once
20-
#include <controllers/RecordSetReader.h>
21-
#include <controllers/RecordSetWriter.h>
22-
23-
#include <numbers>
2420

21+
#include "controllers/RecordSetReader.h"
22+
#include "controllers/RecordSetWriter.h"
2523
#include "core/Record.h"
24+
#include "TestBase.h"
2625

2726
namespace org::apache::nifi::minifi::core::test {
2827

2928
class RecordSetFixture {
30-
public:
29+
public:
3130
explicit RecordSetFixture(TestController::PlanConfig config = {}): plan_config_(std::move(config)) {}
3231

3332
[[nodiscard]] ProcessSession& processSession() const { return *process_session_; }
3433

3534
[[nodiscard]] const Relationship& getRelationship() const { return relationship_; }
36-
private:
35+
private:
3736
TestController test_controller_{};
3837
TestController::PlanConfig plan_config_{};
3938
std::shared_ptr<TestPlan> test_plan_ = test_controller_.createPlan(plan_config_);
@@ -45,7 +44,7 @@ class RecordSetFixture {
4544
};
4645

4746
inline bool testRecordWriter(RecordSetWriter& record_set_writer, const RecordSet& record_set, const std::string_view expected) {
48-
RecordSetFixture fixture;
47+
const RecordSetFixture fixture;
4948
ProcessSession& process_session = fixture.processSession();
5049

5150
const auto flow_file = process_session.create();
@@ -62,7 +61,7 @@ inline bool testRecordWriter(RecordSetWriter& record_set_writer, const RecordSet
6261
}
6362

6463
inline bool testRecordReader(RecordSetReader& record_set_reader, const std::string_view serialized_record_set, const RecordSet& expected_record_set, const RecordSchema* record_schema) {
65-
RecordSetFixture fixture;
64+
const RecordSetFixture fixture;
6665
ProcessSession& process_session = fixture.processSession();
6766

6867
const auto flow_file = process_session.create();
@@ -76,4 +75,4 @@ inline bool testRecordReader(RecordSetReader& record_set_reader, const std::stri
7675
return *record_set == expected_record_set;
7776
}
7877

79-
} // namespace org::apache::nifi::minifi::standard::test
78+
} // namespace org::apache::nifi::minifi::core::test

libminifi/test/TestRecord.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818

1919
#pragma once
20-
#include <controllers/RecordSetWriter.h>
21-
2220
#include <numbers>
2321

2422
#include "core/Record.h"
@@ -44,8 +42,8 @@ inline Record createSampleRecord2() {
4442
quux["Birne"] = RecordField{.value_ = "poire"};
4543
quux["Aprikose"] = RecordField{.value_ = "abricot"};
4644

47-
record["qux"] = RecordField{.value_=qux};
48-
record["quux"] = RecordField{.value_=quux};
45+
record["qux"] = RecordField{.value_ = qux};
46+
record["quux"] = RecordField{.value_ = quux};
4947
return record;
5048
}
5149

@@ -68,9 +66,9 @@ inline Record createSampleRecord() {
6866
quux["Birne"] = RecordField{.value_ = "pear"};
6967
quux["Aprikose"] = RecordField{.value_ = "apricot"};
7068

71-
record["qux"] = RecordField{.value_=qux};
72-
record["quux"] = RecordField{.value_=quux};
69+
record["qux"] = RecordField{.value_ = qux};
70+
record["quux"] = RecordField{.value_ = quux};
7371
return record;
7472
}
7573

76-
} // namespace org::apache::nifi::minifi::standard::test
74+
} // namespace org::apache::nifi::minifi::core::test

0 commit comments

Comments
 (0)