github-actions[bot] commented on code in PR #39197:
URL: https://github.com/apache/doris/pull/39197#discussion_r1712877481


##########
be/src/util/string_parser.hpp:
##########
@@ -535,7 +539,7 @@
 }
 
 template <PrimitiveType P, typename T, typename DecimalType>
-T StringParser::string_to_decimal(const char* __restrict s, int len, int 
type_precision,
+T StringParser::string_to_decimal(const char* __restrict s, int64_t len, int 
type_precision,

Review Comment:
   warning: function 'string_to_decimal' exceeds recommended size/complexity 
thresholds [readability-function-size]
   ```cpp
   T StringParser::string_to_decimal(const char* __restrict s, int64_t len, int 
type_precision,
                   ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/util/string_parser.hpp:541:** 188 lines including whitespace and 
comments (threshold 80)
   ```cpp
   T StringParser::string_to_decimal(const char* __restrict s, int64_t len, int 
type_precision,
                   ^
   ```
   
   </details>
   



##########
be/src/util/string_parser.hpp:
##########
@@ -535,7 +539,7 @@ inline bool StringParser::string_to_bool_internal(const 
char* __restrict s, int
 }
 
 template <PrimitiveType P, typename T, typename DecimalType>
-T StringParser::string_to_decimal(const char* __restrict s, int len, int 
type_precision,
+T StringParser::string_to_decimal(const char* __restrict s, int64_t len, int 
type_precision,

Review Comment:
   warning: function 'string_to_decimal' has cognitive complexity of 101 
(threshold 50) [readability-function-cognitive-complexity]
   ```cpp
   T StringParser::string_to_decimal(const char* __restrict s, int64_t len, int 
type_precision,
                   ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/util/string_parser.hpp:554:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       while (len > 0 && is_whitespace(*s)) {
       ^
   ```
   **be/src/util/string_parser.hpp:554:** +1
   ```cpp
       while (len > 0 && is_whitespace(*s)) {
                      ^
   ```
   **be/src/util/string_parser.hpp:558:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       while (len > 0 && is_whitespace(s[len - 1])) {
       ^
   ```
   **be/src/util/string_parser.hpp:558:** +1
   ```cpp
       while (len > 0 && is_whitespace(s[len - 1])) {
                      ^
   ```
   **be/src/util/string_parser.hpp:563:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       if (len > 0) {
       ^
   ```
   **be/src/util/string_parser.hpp:564:** +2, including nesting penalty of 1, 
nesting level increased to 2
   ```cpp
           switch (*s) {
           ^
   ```
   **be/src/util/string_parser.hpp:576:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       while (len > 0 && UNLIKELY(*s == '0')) {
       ^
   ```
   **be/src/util/string_parser.hpp:576:** +1
   ```cpp
       while (len > 0 && UNLIKELY(*s == '0')) {
                      ^
   ```
   **be/src/util/string_parser.hpp:587:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       if (len > 0 && *s == '.') {
       ^
   ```
   **be/src/util/string_parser.hpp:587:** +1
   ```cpp
       if (len > 0 && *s == '.') {
                   ^
   ```
   **be/src/util/string_parser.hpp:591:** +2, including nesting penalty of 1, 
nesting level increased to 2
   ```cpp
           while (len > 0 && UNLIKELY(*s == '0')) {
           ^
   ```
   **be/src/util/string_parser.hpp:591:** +1
   ```cpp
           while (len > 0 && UNLIKELY(*s == '0')) {
                          ^
   ```
   **be/src/util/string_parser.hpp:606:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       for (int i = 0; i < len; ++i) {
       ^
   ```
   **be/src/util/string_parser.hpp:608:** +2, including nesting penalty of 1, 
nesting level increased to 2
   ```cpp
           if (LIKELY('0' <= c && c <= '9')) {
           ^
   ```
   **be/src/util/string_parser.hpp:608:** +1
   ```cpp
           if (LIKELY('0' <= c && c <= '9')) {
                               ^
   ```
   **be/src/util/string_parser.hpp:614:** +3, including nesting penalty of 2, 
nesting level increased to 3
   ```cpp
               if (LIKELY(type_precision > precision) && !has_round) {
               ^
   ```
   **be/src/util/string_parser.hpp:614:** +1
   ```cpp
               if (LIKELY(type_precision > precision) && !has_round) {
                                                      ^
   ```
   **be/src/util/string_parser.hpp:619:** +1, nesting level increased to 3
   ```cpp
               } else if (!found_dot && max_digit < (precision - scale)) {
                      ^
   ```
   **be/src/util/string_parser.hpp:619:** +1
   ```cpp
               } else if (!found_dot && max_digit < (precision - scale)) {
                                     ^
   ```
   **be/src/util/string_parser.hpp:621:** +4, including nesting penalty of 3, 
nesting level increased to 4
   ```cpp
                   value = is_negative ? 
vectorized::min_decimal_value<DecimalType>(type_precision)
                                       ^
   ```
   **be/src/util/string_parser.hpp:624:** +1, nesting level increased to 3
   ```cpp
               } else if (found_dot && scale >= type_scale && !has_round) {
                      ^
   ```
   **be/src/util/string_parser.hpp:624:** +1
   ```cpp
               } else if (found_dot && scale >= type_scale && !has_round) {
                                                           ^
   ```
   **be/src/util/string_parser.hpp:626:** +4, including nesting penalty of 3, 
nesting level increased to 4
   ```cpp
                   if (c > '4') {
                   ^
   ```
   **be/src/util/string_parser.hpp:631:** +1, nesting level increased to 3
   ```cpp
               } else if (!found_dot) {
                      ^
   ```
   **be/src/util/string_parser.hpp:635:** +1, nesting level increased to 2
   ```cpp
           } else if (c == '.' && LIKELY(!found_dot)) {
                  ^
   ```
   **be/src/util/string_parser.hpp:635:** +1
   ```cpp
           } else if (c == '.' && LIKELY(!found_dot)) {
                               ^
   ```
   **be/src/util/string_parser.hpp:637:** +1, nesting level increased to 2
   ```cpp
           } else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
                  ^
   ```
   **be/src/util/string_parser.hpp:637:** +1
   ```cpp
           } else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
                                             ^
   ```
   **be/src/util/string_parser.hpp:637:** +1
   ```cpp
           } else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
                                ^
   ```
   **be/src/util/string_parser.hpp:640:** +3, including nesting penalty of 2, 
nesting level increased to 3
   ```cpp
               if (UNLIKELY(*result != StringParser::PARSE_SUCCESS)) {
               ^
   ```
   **be/src/util/string_parser.hpp:641:** +4, including nesting penalty of 3, 
nesting level increased to 4
   ```cpp
                   if (*result == StringParser::PARSE_OVERFLOW && exponent < 0) 
{
                   ^
   ```
   **be/src/util/string_parser.hpp:641:** +1
   ```cpp
                   if (*result == StringParser::PARSE_OVERFLOW && exponent < 0) 
{
                                                               ^
   ```
   **be/src/util/string_parser.hpp:647:** +1, nesting level increased to 2
   ```cpp
           } else {
             ^
   ```
   **be/src/util/string_parser.hpp:648:** +3, including nesting penalty of 2, 
nesting level increased to 3
   ```cpp
               if (value == 0) {
               ^
   ```
   **be/src/util/string_parser.hpp:654:** +3, including nesting penalty of 2, 
nesting level increased to 3
   ```cpp
               if (type_scale >= scale) {
               ^
   ```
   **be/src/util/string_parser.hpp:659:** +4, including nesting penalty of 3, 
nesting level increased to 4
   ```cpp
                   if (!is_numeric_ascii(c)) {
                   ^
   ```
   **be/src/util/string_parser.hpp:660:** +5, including nesting penalty of 4, 
nesting level increased to 5
   ```cpp
                       if (cur_digit > type_precision) {
                       ^
   ```
   **be/src/util/string_parser.hpp:663:** +6, including nesting penalty of 5, 
nesting level increased to 6
   ```cpp
                                           ? 
vectorized::min_decimal_value<DecimalType>(type_precision)
                                           ^
   ```
   **be/src/util/string_parser.hpp:668:** +5, including nesting penalty of 4, 
nesting level increased to 5
   ```cpp
                       return is_negative ? T(-value) : T(value);
                                          ^
   ```
   **be/src/util/string_parser.hpp:672:** +3, including nesting penalty of 2, 
nesting level increased to 3
   ```cpp
               return is_negative ? T(-value) : T(value);
                                  ^
   ```
   **be/src/util/string_parser.hpp:677:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       if (exponent > scale) {
       ^
   ```
   **be/src/util/string_parser.hpp:684:** +1, nesting level increased to 1
   ```cpp
       } else {
         ^
   ```
   **be/src/util/string_parser.hpp:692:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       if (scale > precision) {
       ^
   ```
   **be/src/util/string_parser.hpp:699:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       if (UNLIKELY(precision - scale > type_precision - type_scale)) {
       ^
   ```
   **be/src/util/string_parser.hpp:701:** +2, including nesting penalty of 1, 
nesting level increased to 2
   ```cpp
           if constexpr (TYPE_DECIMALV2 != P) {
           ^
   ```
   **be/src/util/string_parser.hpp:703:** +3, including nesting penalty of 2, 
nesting level increased to 3
   ```cpp
               value = is_negative ? 
vectorized::min_decimal_value<DecimalType>(type_precision)
                                   ^
   ```
   **be/src/util/string_parser.hpp:707:** +1, nesting level increased to 1
   ```cpp
       } else if (UNLIKELY(scale > type_scale)) {
              ^
   ```
   **be/src/util/string_parser.hpp:711:** +2, including nesting penalty of 1, 
nesting level increased to 2
   ```cpp
           if (UNLIKELY(divisor == std::numeric_limits<T>::max())) {
           ^
   ```
   **be/src/util/string_parser.hpp:713:** +1, nesting level increased to 2
   ```cpp
           } else {
             ^
   ```
   **be/src/util/string_parser.hpp:716:** +3, including nesting penalty of 2, 
nesting level increased to 3
   ```cpp
               if ((remainder > 0 ? T(remainder) : T(-remainder)) >= (divisor 
>> 1)) {
               ^
   ```
   **be/src/util/string_parser.hpp:716:** +3, including nesting penalty of 2, 
nesting level increased to 3
   ```cpp
               if ((remainder > 0 ? T(remainder) : T(-remainder)) >= (divisor 
>> 1)) {
                                  ^
   ```
   **be/src/util/string_parser.hpp:721:** +1, nesting level increased to 1
   ```cpp
       } else if (UNLIKELY(!found_value && !found_dot)) {
              ^
   ```
   **be/src/util/string_parser.hpp:721:** +1
   ```cpp
       } else if (UNLIKELY(!found_value && !found_dot)) {
                                        ^
   ```
   **be/src/util/string_parser.hpp:725:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       if (type_scale > scale) {
       ^
   ```
   **be/src/util/string_parser.hpp:729:** +1, including nesting penalty of 0, 
nesting level increased to 1
   ```cpp
       return is_negative ? T(-value) : T(value);
                          ^
   ```
   
   </details>
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to