Copilot commented on code in PR #2213:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2213#discussion_r3549834378


##########
extension-framework/include/utils/ProcessorConfigUtils.h:
##########
@@ -55,6 +55,18 @@ inline int64_t parseI64Property(const core::ProcessContext& 
ctx, const core::Pro
       | orThrow(fmt::format("Expected parsable int64_t from \"{}\"", 
property.name));
 }
 
+inline double parsef64Property(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file = nullptr) {

Review Comment:
   Function naming is inconsistent with the existing `parseU64Property` / 
`parseI64Property` helpers: `parsef64Property` starts with a lowercase type 
letter. For consistency and discoverability, use `parseF64Property`.



##########
extension-framework/include/utils/ProcessorConfigUtils.h:
##########
@@ -55,6 +55,18 @@ inline int64_t parseI64Property(const core::ProcessContext& 
ctx, const core::Pro
       | orThrow(fmt::format("Expected parsable int64_t from \"{}\"", 
property.name));
 }
 
+inline double parsef64Property(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file = nullptr) {
+  return ctx.getProperty(property.name, flow_file)
+  | andThen(parsing::parseFloatingPoint<double>)
+  | orThrow(fmt::format("Expected parsable double from \"{}\"", 
property.name));
+}
+
+inline double parsef32Property(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file = nullptr) {

Review Comment:
   This helper parses a `float` but is declared to return `double`, and its 
name (`parsef32Property`) is inconsistent with the existing `parseU64Property` 
/ `parseI64Property` naming style. Returning `float` and using 
`parseF32Property` keeps the API contract and naming consistent.



##########
minifi-api/common/include/minifi-cpp/core/PropertyValidator.h:
##########
@@ -113,16 +112,26 @@ class DataSizeValidator final : public PropertyValidator {
 
 class PortValidator final : public core::PropertyValidator {
  public:
-  PortValidator() = default;
-  constexpr ~PortValidator() override {}  // NOLINT see comment at parent
-
-  [[nodiscard]] std::optional<std::string_view> 
getEquivalentNifiStandardValidatorName() const override { return 
"PORT_VALIDATOR"; }
+  [[nodiscard]] std::optional<std::string_view> 
getEquivalentNifiStandardValidatorName() const override {
+    return "PORT_VALIDATOR";
+  }
   [[nodiscard]] bool validate(const std::string_view input) const override {
     const auto parsed_integer = parsing::parseIntegralMinMax<uint64_t>(input, 
0, 65535);
     return parsed_integer.has_value();
   }
 };
 
+class NumberValidator final : public core::PropertyValidator {
+ public:
+  [[nodiscard]] std::optional<std::string_view> 
getEquivalentNifiStandardValidatorName() const override {
+    return "NUMBER_VALIDATOR";
+  }
+  [[nodiscard]] bool validate(const std::string_view input) const override {
+    const auto parsed_integer = parsing::parseFloatingPoint<double>(input);
+    return parsed_integer.has_value();
+  }

Review Comment:
   Local variable name `parsed_integer` is misleading here because the 
validator parses a floating-point value. Renaming improves readability and 
avoids confusion during maintenance.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to