github-actions[bot] commented on code in PR #30825:
URL: https://github.com/apache/doris/pull/30825#discussion_r1477312232
##########
be/src/util/string_parser.hpp:
##########
@@ -521,8 +530,8 @@
}
template <PrimitiveType P, typename T, typename DecimalType>
-T StringParser::string_to_decimal(const char* s, int len, int type_precision,
int type_scale,
- ParseResult* result) {
+T StringParser::string_to_decimal(const char* __restrict s, int 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, int len, int
type_precision,
^
```
<details>
<summary>Additional context</summary>
**be/src/util/string_parser.hpp:532:** 237 lines including whitespace and
comments (threshold 80)
```cpp
T StringParser::string_to_decimal(const char* __restrict s, int len, int
type_precision,
^
```
</details>
##########
be/src/util/string_parser.hpp:
##########
@@ -521,8 +530,8 @@ inline bool StringParser::string_to_bool_internal(const
char* s, int len, ParseR
}
template <PrimitiveType P, typename T, typename DecimalType>
-T StringParser::string_to_decimal(const char* s, int len, int type_precision,
int type_scale,
- ParseResult* result) {
+T StringParser::string_to_decimal(const char* __restrict s, int len, int
type_precision,
Review Comment:
warning: function 'string_to_decimal' has cognitive complexity of 157
(threshold 50) [readability-function-cognitive-complexity]
```cpp
T StringParser::string_to_decimal(const char* __restrict s, int len, int
type_precision,
^
```
<details>
<summary>Additional context</summary>
**be/src/util/string_parser.hpp:545:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
while (len > 0 && is_whitespace(*s)) {
^
```
**be/src/util/string_parser.hpp:545:** +1
```cpp
while (len > 0 && is_whitespace(*s)) {
^
```
**be/src/util/string_parser.hpp:549:** +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:549:** +1
```cpp
while (len > 0 && is_whitespace(s[len - 1])) {
^
```
**be/src/util/string_parser.hpp:554:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if (len > 0) {
^
```
**be/src/util/string_parser.hpp:555:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
switch (*s) {
^
```
**be/src/util/string_parser.hpp:567:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
while (len > 0 && UNLIKELY(*s == '0')) {
^
```
**be/src/util/string_parser.hpp:567:** +1
```cpp
while (len > 0 && UNLIKELY(*s == '0')) {
^
```
**be/src/util/string_parser.hpp:578:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if (len > 0 && *s == '.') {
^
```
**be/src/util/string_parser.hpp:578:** +1
```cpp
if (len > 0 && *s == '.') {
^
```
**be/src/util/string_parser.hpp:582:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
while (len > 0 && UNLIKELY(*s == '0')) {
^
```
**be/src/util/string_parser.hpp:582:** +1
```cpp
while (len > 0 && UNLIKELY(*s == '0')) {
^
```
**be/src/util/string_parser.hpp:596:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if constexpr (TYPE_DECIMALV2 == P) {
^
```
**be/src/util/string_parser.hpp:598:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
for (int i = 0; i < len; ++i) {
^
```
**be/src/util/string_parser.hpp:600:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
if (LIKELY('0' <= c && c <= '9')) {
^
```
**be/src/util/string_parser.hpp:600:** +1
```cpp
if (LIKELY('0' <= c && c <= '9')) {
^
```
**be/src/util/string_parser.hpp:606:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (LIKELY(type_precision > precision)) {
^
```
**be/src/util/string_parser.hpp:608:** +1, nesting level increased to 4
```cpp
} else {
^
```
**be/src/util/string_parser.hpp:611:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
?
vectorized::min_decimal_value<DecimalType>(type_precision)
^
```
**be/src/util/string_parser.hpp:618:** +1, nesting level increased to 3
```cpp
} else if (c == '.' && LIKELY(!found_dot)) {
^
```
**be/src/util/string_parser.hpp:618:** +1
```cpp
} else if (c == '.' && LIKELY(!found_dot)) {
^
```
**be/src/util/string_parser.hpp:620:** +1, nesting level increased to 3
```cpp
} else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
^
```
**be/src/util/string_parser.hpp:620:** +1
```cpp
} else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
^
```
**be/src/util/string_parser.hpp:620:** +1
```cpp
} else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
^
```
**be/src/util/string_parser.hpp:623:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (UNLIKELY(*result != StringParser::PARSE_SUCCESS)) {
^
```
**be/src/util/string_parser.hpp:624:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
if (*result == StringParser::PARSE_OVERFLOW && exponent
< 0) {
^
```
**be/src/util/string_parser.hpp:624:** +1
```cpp
if (*result == StringParser::PARSE_OVERFLOW && exponent
< 0) {
^
```
**be/src/util/string_parser.hpp:630:** +1, nesting level increased to 3
```cpp
} else {
^
```
**be/src/util/string_parser.hpp:631:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (value == 0) {
^
```
**be/src/util/string_parser.hpp:638:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
return is_negative ? T(-value) : T(value);
^
```
**be/src/util/string_parser.hpp:641:** +1, nesting level increased to 1
```cpp
} else {
^
```
**be/src/util/string_parser.hpp:644:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
for (int i = 0; i < len; ++i) {
^
```
**be/src/util/string_parser.hpp:646:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
if (LIKELY('0' <= c && c <= '9')) {
^
```
**be/src/util/string_parser.hpp:646:** +1
```cpp
if (LIKELY('0' <= c && c <= '9')) {
^
```
**be/src/util/string_parser.hpp:652:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (LIKELY(type_precision > precision) && !has_round) {
^
```
**be/src/util/string_parser.hpp:652:** +1
```cpp
if (LIKELY(type_precision > precision) && !has_round) {
^
```
**be/src/util/string_parser.hpp:657:** +1, nesting level increased to 4
```cpp
} else if (!found_dot && max_digit < (precision - scale)) {
^
```
**be/src/util/string_parser.hpp:657:** +1
```cpp
} else if (!found_dot && max_digit < (precision - scale)) {
^
```
**be/src/util/string_parser.hpp:660:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
?
vectorized::min_decimal_value<DecimalType>(type_precision)
^
```
**be/src/util/string_parser.hpp:663:** +1, nesting level increased to 4
```cpp
} else if (found_dot && scale >= type_scale && !has_round) {
^
```
**be/src/util/string_parser.hpp:663:** +1
```cpp
} else if (found_dot && scale >= type_scale && !has_round) {
^
```
**be/src/util/string_parser.hpp:665:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
if (c > '4') {
^
```
**be/src/util/string_parser.hpp:670:** +1, nesting level increased to 4
```cpp
} else if (!found_dot) {
^
```
**be/src/util/string_parser.hpp:674:** +1, nesting level increased to 3
```cpp
} else if (c == '.' && LIKELY(!found_dot)) {
^
```
**be/src/util/string_parser.hpp:674:** +1
```cpp
} else if (c == '.' && LIKELY(!found_dot)) {
^
```
**be/src/util/string_parser.hpp:676:** +1, nesting level increased to 3
```cpp
} else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
^
```
**be/src/util/string_parser.hpp:676:** +1
```cpp
} else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
^
```
**be/src/util/string_parser.hpp:676:** +1
```cpp
} else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
^
```
**be/src/util/string_parser.hpp:679:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (UNLIKELY(*result != StringParser::PARSE_SUCCESS)) {
^
```
**be/src/util/string_parser.hpp:680:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
if (*result == StringParser::PARSE_OVERFLOW && exponent
< 0) {
^
```
**be/src/util/string_parser.hpp:680:** +1
```cpp
if (*result == StringParser::PARSE_OVERFLOW && exponent
< 0) {
^
```
**be/src/util/string_parser.hpp:686:** +1, nesting level increased to 3
```cpp
} else {
^
```
**be/src/util/string_parser.hpp:687:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (value == 0) {
^
```
**be/src/util/string_parser.hpp:693:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (type_scale >= scale) {
^
```
**be/src/util/string_parser.hpp:698:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
if (!is_numeric_ascii(c)) {
^
```
**be/src/util/string_parser.hpp:699:** +6, including nesting penalty of 5,
nesting level increased to 6
```cpp
if (cur_digit > type_precision) {
^
```
**be/src/util/string_parser.hpp:701:** +7, including nesting penalty of 6,
nesting level increased to 7
```cpp
value = is_negative ?
vectorized::min_decimal_value<DecimalType>(
^
```
**be/src/util/string_parser.hpp:707:** +6, including nesting penalty of 5,
nesting level increased to 6
```cpp
return is_negative ? T(-value) : T(value);
^
```
**be/src/util/string_parser.hpp:711:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
return is_negative ? T(-value) : T(value);
^
```
**be/src/util/string_parser.hpp:717:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if (exponent > scale) {
^
```
**be/src/util/string_parser.hpp:724:** +1, nesting level increased to 1
```cpp
} else {
^
```
**be/src/util/string_parser.hpp:732:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if (scale > precision) {
^
```
**be/src/util/string_parser.hpp:739:** +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:741:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
if constexpr (TYPE_DECIMALV2 != P) {
^
```
**be/src/util/string_parser.hpp:743:** +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:747:** +1, nesting level increased to 1
```cpp
} else if (UNLIKELY(scale > type_scale)) {
^
```
**be/src/util/string_parser.hpp:751:** +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:753:** +1, nesting level increased to 2
```cpp
} else {
^
```
**be/src/util/string_parser.hpp:756:** +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:756:** +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:761:** +1, nesting level increased to 1
```cpp
} else if (UNLIKELY(!found_value && !found_dot)) {
^
```
**be/src/util/string_parser.hpp:761:** +1
```cpp
} else if (UNLIKELY(!found_value && !found_dot)) {
^
```
**be/src/util/string_parser.hpp:765:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if (type_scale > scale) {
^
```
**be/src/util/string_parser.hpp:769:** +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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]