github-actions[bot] commented on code in PR #39197:
URL: https://github.com/apache/doris/pull/39197#discussion_r1712876126
##########
be/src/gutil/strings/numbers.cc:
##########
@@ -1042,7 +1046,7 @@
// strict mode, but "01" == "1" otherwise.
// ----------------------------------------------------------------------
-int AutoDigitStrCmp(const char* a, int alen, const char* b, int blen, bool
strict) {
+int AutoDigitStrCmp(const char* a, size_t alen, const char* b, size_t blen,
bool strict) {
Review Comment:
warning: function 'AutoDigitStrCmp' has cognitive complexity of 53
(threshold 50) [readability-function-cognitive-complexity]
```cpp
int AutoDigitStrCmp(const char* a, size_t alen, const char* b, size_t blen,
bool strict) {
^
```
<details>
<summary>Additional context</summary>
**be/src/gutil/strings/numbers.cc:1051:** +1, including nesting penalty of
0, nesting level increased to 1
```cpp
while ((aindex < alen) && (bindex < blen)) {
^
```
**be/src/gutil/strings/numbers.cc:1051:** +1
```cpp
while ((aindex < alen) && (bindex < blen)) {
^
```
**be/src/gutil/strings/numbers.cc:1052:** +2, including nesting penalty of
1, nesting level increased to 2
```cpp
if (isdigit(a[aindex]) && isdigit(b[bindex])) {
^
```
**be/src/gutil/strings/numbers.cc:1052:** +1
```cpp
if (isdigit(a[aindex]) && isdigit(b[bindex])) {
^
```
**be/src/gutil/strings/numbers.cc:1062:** +3, including nesting penalty of
2, nesting level increased to 3
```cpp
while ((aindex < alen) && (a[aindex] == '0')) aindex++;
^
```
**be/src/gutil/strings/numbers.cc:1062:** +1
```cpp
while ((aindex < alen) && (a[aindex] == '0')) aindex++;
^
```
**be/src/gutil/strings/numbers.cc:1063:** +3, including nesting penalty of
2, nesting level increased to 3
```cpp
while ((bindex < blen) && (b[bindex] == '0')) bindex++;
^
```
**be/src/gutil/strings/numbers.cc:1063:** +1
```cpp
while ((bindex < blen) && (b[bindex] == '0')) bindex++;
^
```
**be/src/gutil/strings/numbers.cc:1070:** +3, including nesting penalty of
2, nesting level increased to 3
```cpp
while ((aindex < alen) && isdigit(a[aindex])) aindex++;
^
```
**be/src/gutil/strings/numbers.cc:1070:** +1
```cpp
while ((aindex < alen) && isdigit(a[aindex])) aindex++;
^
```
**be/src/gutil/strings/numbers.cc:1071:** +3, including nesting penalty of
2, nesting level increased to 3
```cpp
while ((bindex < blen) && isdigit(b[bindex])) bindex++;
^
```
**be/src/gutil/strings/numbers.cc:1071:** +1
```cpp
while ((bindex < blen) && isdigit(b[bindex])) bindex++;
^
```
**be/src/gutil/strings/numbers.cc:1072:** +3, including nesting penalty of
2, nesting level increased to 3
```cpp
if (aindex - astart < bindex - bstart) {
^
```
**be/src/gutil/strings/numbers.cc:1075:** +1, nesting level increased to 3
```cpp
} else if (aindex - astart > bindex - bstart) {
^
```
**be/src/gutil/strings/numbers.cc:1078:** +1, nesting level increased to 3
```cpp
} else {
^
```
**be/src/gutil/strings/numbers.cc:1080:** +4, including nesting penalty of
3, nesting level increased to 4
```cpp
for (int i = 0; i < aindex - astart; i++) {
^
```
**be/src/gutil/strings/numbers.cc:1081:** +5, including nesting penalty of
4, nesting level increased to 5
```cpp
if (a[astart + i] < b[bstart + i]) {
^
```
**be/src/gutil/strings/numbers.cc:1083:** +1, nesting level increased to 5
```cpp
} else if (a[astart + i] > b[bstart + i]) {
^
```
**be/src/gutil/strings/numbers.cc:1088:** +4, including nesting penalty of
3, nesting level increased to 4
```cpp
if (strict && azeroes != bzeroes) {
^
```
**be/src/gutil/strings/numbers.cc:1088:** +1
```cpp
if (strict && azeroes != bzeroes) {
^
```
**be/src/gutil/strings/numbers.cc:1089:** +5, including nesting penalty of
4, nesting level increased to 5
```cpp
if (azeroes > bzeroes) {
^
```
**be/src/gutil/strings/numbers.cc:1092:** +1, nesting level increased to 5
```cpp
} else {
^
```
**be/src/gutil/strings/numbers.cc:1099:** +1, nesting level increased to 2
```cpp
} else if (a[aindex] < b[bindex]) {
^
```
**be/src/gutil/strings/numbers.cc:1101:** +1, nesting level increased to 2
```cpp
} else if (a[aindex] > b[bindex]) {
^
```
**be/src/gutil/strings/numbers.cc:1103:** +1, nesting level increased to 2
```cpp
} else {
^
```
**be/src/gutil/strings/numbers.cc:1109:** +1, including nesting penalty of
0, nesting level increased to 1
```cpp
if (aindex < alen) {
^
```
**be/src/gutil/strings/numbers.cc:1112:** +1, nesting level increased to 1
```cpp
} else if (bindex < blen) {
^
```
**be/src/gutil/strings/numbers.cc:1115:** +1, nesting level increased to 1
```cpp
} else {
^
```
</details>
##########
be/src/gutil/strings/numbers.cc:
##########
@@ -10,12 +10,13 @@
#include <ctype.h>
#include <errno.h>
#include <float.h> // for DBL_DIG and FLT_DIG
-#include <math.h> // for HUGE_VAL
+#include <inttypes.h>
Review Comment:
warning: inclusion of deprecated C++ header 'inttypes.h'; consider using
'cinttypes' instead [modernize-deprecated-headers]
```suggestion
#include <cinttypes>
```
##########
be/src/gutil/bits.cc:
##########
@@ -20,10 +20,10 @@ const char Bits::num_bits[] = {
5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4,
4, 5, 4, 5, 5, 6,
4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7,
8};
-int Bits::Count(const void* m, int num_bytes) {
+int Bits::Count(const void* m, int64_t num_bytes) {
int nbits = 0;
const uint8* s = (const uint8*)m;
- for (int i = 0; i < num_bytes; i++) nbits += num_bits[*s++];
+ for (int64_t i = 0; i < num_bytes; i++) nbits += num_bits[*s++];
Review Comment:
warning: statement should be inside braces
[readability-braces-around-statements]
```suggestion
for (int64_t i = 0; i < num_bytes; i++) { nbits += num_bits[*s++];
}
```
##########
be/src/gutil/strings/numbers.cc:
##########
@@ -10,12 +10,13 @@
#include <ctype.h>
#include <errno.h>
#include <float.h> // for DBL_DIG and FLT_DIG
-#include <math.h> // for HUGE_VAL
+#include <inttypes.h>
+#include <math.h> // for HUGE_VAL
Review Comment:
warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath'
instead [modernize-deprecated-headers]
```suggestion
#include <cmath> // for HUGE_VAL
```
##########
be/src/gutil/strings/numbers.h:
##########
@@ -6,8 +6,9 @@
#pragma once
#include <stddef.h>
-#include <time.h>
#include <stdint.h>
+#include <time.h>
Review Comment:
warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime'
instead [modernize-deprecated-headers]
```suggestion
#include <ctime>
```
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -92,16 +92,16 @@ bool VecDateTimeValue::check_date(uint32_t year, uint32_t
month, uint32_t day) {
// The interval format is that with no delimiters
// YYYY-MM-DD HH-MM-DD.FFFFFF AM in default format
// 0 1 2 3 4 5 6 7
-bool VecDateTimeValue::from_date_str(const char* date_str, int len) {
+bool VecDateTimeValue::from_date_str(const char* date_str, int64_t len) {
return from_date_str_base(date_str, len, nullptr);
}
//parse timezone to get offset
-bool VecDateTimeValue::from_date_str(const char* date_str, int len,
+bool VecDateTimeValue::from_date_str(const char* date_str, int64_t len,
const cctz::time_zone& local_time_zone) {
return from_date_str_base(date_str, len, &local_time_zone);
}
-bool VecDateTimeValue::from_date_str_base(const char* date_str, int len,
+bool VecDateTimeValue::from_date_str_base(const char* date_str, size_t len,
Review Comment:
warning: function 'from_date_str_base' has cognitive complexity of 72
(threshold 50) [readability-function-cognitive-complexity]
```cpp
bool VecDateTimeValue::from_date_str_base(const char* date_str, size_t len,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/runtime/vdatetime_value.cpp:115:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
while (ptr < end && check_space(*ptr)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:115:** +1
```cpp
while (ptr < end && check_space(*ptr)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:118:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (ptr == end || !isdigit(*ptr)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:118:** +1
```cpp
if (ptr == end || !isdigit(*ptr)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:123:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
while (pos < end && (isdigit(*pos) || *pos == 'T')) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:123:** +1
```cpp
while (pos < end && (isdigit(*pos) || *pos == 'T')) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:123:** +1
```cpp
while (pos < end && (isdigit(*pos) || *pos == 'T')) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:133:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (pos == end || *pos == '.') {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:133:** +1
```cpp
if (pos == end || *pos == '.') {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:134:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (digits == 4 || digits == 8 || digits >= 14) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:134:** +1
```cpp
if (digits == 4 || digits == 8 || digits >= 14) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:136:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:145:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
while (ptr < end && isdigit(*ptr) && field_idx < MAX_DATE_PARTS - 1) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:145:** +1
```cpp
while (ptr < end && isdigit(*ptr) && field_idx < MAX_DATE_PARTS - 1) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:148:** +1
```cpp
bool scan_to_delim = (!is_interval_format) && (field_idx != 6);
^
```
**be/src/vec/runtime/vdatetime_value.cpp:149:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
while (ptr < end && isdigit(*ptr) && (scan_to_delim || field_len--))
{
^
```
**be/src/vec/runtime/vdatetime_value.cpp:149:** +1
```cpp
while (ptr < end && isdigit(*ptr) && (scan_to_delim || field_len--))
{
^
```
**be/src/vec/runtime/vdatetime_value.cpp:149:** +1
```cpp
while (ptr < end && isdigit(*ptr) && (scan_to_delim || field_len--))
{
^
```
**be/src/vec/runtime/vdatetime_value.cpp:153:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (temp_val > 999999L) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:160:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (ptr == end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:166:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (UNLIKELY((field_idx > 2 ||
^
```
**be/src/vec/runtime/vdatetime_value.cpp:168:** +1
```cpp
&& time_zone_begins(ptr, end))) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:166:** +1
```cpp
if (UNLIKELY((field_idx > 2 ||
^
```
**be/src/vec/runtime/vdatetime_value.cpp:169:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (local_time_zone == nullptr) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:172:** nesting level increased to 3
```cpp
auto get_tz_offset = [&](const std::string& str_tz,
^
```
**be/src/vec/runtime/vdatetime_value.cpp:175:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!TimezoneUtils::find_cctz_time_zone(str_tz, given_tz)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:186:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
} catch ([[maybe_unused]] Exception& e) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:193:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (field_idx == 2 && *ptr == 'T') {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:193:** +1
```cpp
if (field_idx == 2 && *ptr == 'T') {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:201:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (field_idx == 5) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:202:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (*ptr == '.') {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:205:** +1, nesting level increased
to 3
```cpp
} else if (isdigit(*ptr)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:213:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
while (ptr < end && (check_date_punct(*ptr) || check_space(*ptr))) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:213:** +1
```cpp
while (ptr < end && (check_date_punct(*ptr) || check_space(*ptr))) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:213:** +1
```cpp
while (ptr < end && (check_date_punct(*ptr) || check_space(*ptr))) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:214:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (check_space(*ptr)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:215:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (((1 << field_idx) & allow_space_mask) == 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:219:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (*ptr == '-') {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:227:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (num_field <= 3) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:229:** +1, nesting level increased
to 1
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:232:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (!is_interval_format) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:235:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
for (; field_idx < MAX_DATE_PARTS; ++field_idx) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:240:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (year_len == 2) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:241:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (date_val[0] < YY_PART_YEAR) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:243:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:248:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (num_field < 3) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:251:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (!check_range_and_set_time(date_val[0], date_val[1], date_val[2],
date_val[3], date_val[4],
^
```
**be/src/vec/runtime/vdatetime_value.cpp:255:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
return sec_offset ? date_add_interval<TimeUnit::SECOND>(
^
```
</details>
##########
be/src/util/hash_util.hpp:
##########
@@ -19,6 +19,8 @@
// and modified by Doris
#pragma once
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
#include <gen_cpp/Types_types.h>
Review Comment:
warning: 'gen_cpp/Types_types.h' file not found [clang-diagnostic-error]
```cpp
#include <gen_cpp/Types_types.h>
^
```
##########
be/src/vec/common/string_ref.h:
##########
@@ -336,7 +336,7 @@ inline size_t hash_less_than8(const char* data, size_t
size) {
uint8_t b = data[size >> 1];
uint8_t c = data[size - 1];
uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) <<
8);
- uint32_t z = size + (static_cast<uint32_t>(c) << 2);
+ uint32_t z = static_cast<uint32_t>(size + (static_cast<uint32_t>(c) <<
2));
Review Comment:
warning: use auto when initializing with a cast to avoid duplicating the
type name [modernize-use-auto]
```suggestion
auto z = static_cast<uint32_t>(size + (static_cast<uint32_t>(c) <<
2));
```
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -683,7 +683,7 @@
return dst + 4;
}
-bool VecDateTimeValue::to_format_string_conservative(const char* format, int
len, char* to,
+bool VecDateTimeValue::to_format_string_conservative(const char* format,
size_t len, char* to,
Review Comment:
warning: function 'to_format_string_conservative' exceeds recommended
size/complexity thresholds [readability-function-size]
```cpp
bool VecDateTimeValue::to_format_string_conservative(const char* format,
size_t len, char* to,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/runtime/vdatetime_value.cpp:685:** 270 lines including
whitespace and comments (threshold 80)
```cpp
bool VecDateTimeValue::to_format_string_conservative(const char* format,
size_t len, char* to,
^
```
</details>
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -3449,7 +3450,7 @@
}
template <typename T>
-bool DateV2Value<T>::to_format_string_conservative(const char* format, int
len, char* to,
+bool DateV2Value<T>::to_format_string_conservative(const char* format, size_t
len, char* to,
Review Comment:
warning: function 'to_format_string_conservative' exceeds recommended
size/complexity thresholds [readability-function-size]
```cpp
bool DateV2Value<T>::to_format_string_conservative(const char* format,
size_t len, char* to,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/runtime/vdatetime_value.cpp:3452:** 256 lines including
whitespace and comments (threshold 80)
```cpp
bool DateV2Value<T>::to_format_string_conservative(const char* format,
size_t len, char* to,
^
```
</details>
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -2253,8 +2254,8 @@
// this method is exactly same as fromDateFormatStr() in DateLiteral.java in FE
// change this method should also change that.
template <typename T>
-bool DateV2Value<T>::from_date_format_str(const char* format, int format_len,
const char* value,
- int value_len, const char**
sub_val_end) {
+bool DateV2Value<T>::from_date_format_str(const char* format, size_t
format_len, const char* value,
Review Comment:
warning: function 'from_date_format_str' exceeds recommended size/complexity
thresholds [readability-function-size]
```cpp
bool DateV2Value<T>::from_date_format_str(const char* format, size_t
format_len, const char* value,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/runtime/vdatetime_value.cpp:2256:** 464 lines including
whitespace and comments (threshold 80)
```cpp
bool DateV2Value<T>::from_date_format_str(const char* format, size_t
format_len, const char* value,
^
```
</details>
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -683,7 +683,7 @@
return dst + 4;
}
-bool VecDateTimeValue::to_format_string_conservative(const char* format, int
len, char* to,
+bool VecDateTimeValue::to_format_string_conservative(const char* format,
size_t len, char* to,
Review Comment:
warning: function 'to_format_string_conservative' has cognitive complexity
of 60 (threshold 50) [readability-function-cognitive-complexity]
```cpp
bool VecDateTimeValue::to_format_string_conservative(const char* format,
size_t len, char* to,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/runtime/vdatetime_value.cpp:687:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (check_range(_year, _month, _day, _hour, _minute, _second, _type)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:698:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
while (ptr < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:699:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (to - begin + SAFE_FORMAT_STRING_MARGIN > max_valid_length)
[[unlikely]] {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:702:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (*ptr != '%' || (ptr + 1) == end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:702:** +1
```cpp
if (*ptr != '%' || (ptr + 1) == end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:708:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
switch (ch = *ptr++) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:759:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_type == TIME_TIME || (_year == 0 && _month == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:759:** +1
```cpp
if (_type == TIME_TIME || (_year == 0 && _month == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:759:** +1
```cpp
if (_type == TIME_TIME || (_year == 0 && _month == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:766:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_month == 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:780:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_day >= 10 && _day <= 19) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:780:** +1
```cpp
if (_day >= 10 && _day <= 19) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:782:** +1, nesting level increased
to 3
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:783:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
switch (_day % 10) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:826:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_month == 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:833:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if ((_hour % 24) >= 12) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:835:** +1, nesting level increased
to 3
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:851:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if ((_hour % 24) >= 12) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:853:** +1, nesting level increased
to 3
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:873:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_type == TIME_TIME) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:883:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_type == TIME_TIME) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:893:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_type == TIME_TIME) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:903:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_type == TIME_TIME) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:912:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_type == TIME_TIME || (_month == 0 && _year == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:912:** +1
```cpp
if (_type == TIME_TIME || (_month == 0 && _year == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:912:** +1
```cpp
if (_type == TIME_TIME || (_month == 0 && _year == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:925:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_type == TIME_TIME) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:938:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (_type == TIME_TIME) {
^
```
</details>
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -92,16 +92,16 @@
// The interval format is that with no delimiters
// YYYY-MM-DD HH-MM-DD.FFFFFF AM in default format
// 0 1 2 3 4 5 6 7
-bool VecDateTimeValue::from_date_str(const char* date_str, int len) {
+bool VecDateTimeValue::from_date_str(const char* date_str, int64_t len) {
return from_date_str_base(date_str, len, nullptr);
}
//parse timezone to get offset
-bool VecDateTimeValue::from_date_str(const char* date_str, int len,
+bool VecDateTimeValue::from_date_str(const char* date_str, int64_t len,
const cctz::time_zone& local_time_zone) {
return from_date_str_base(date_str, len, &local_time_zone);
}
-bool VecDateTimeValue::from_date_str_base(const char* date_str, int len,
+bool VecDateTimeValue::from_date_str_base(const char* date_str, size_t len,
Review Comment:
warning: function 'from_date_str_base' exceeds recommended size/complexity
thresholds [readability-function-size]
```cpp
bool VecDateTimeValue::from_date_str_base(const char* date_str, size_t len,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/runtime/vdatetime_value.cpp:103:** 154 lines including
whitespace and comments (threshold 80)
```cpp
bool VecDateTimeValue::from_date_str_base(const char* date_str, size_t len,
^
```
</details>
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -1203,8 +1203,9 @@
// this method is exactly same as fromDateFormatStr() in DateLiteral.java in FE
// change this method should also change that.
-bool VecDateTimeValue::from_date_format_str(const char* format, int
format_len, const char* value,
- int value_len, const char**
sub_val_end) {
+bool VecDateTimeValue::from_date_format_str(const char* format, size_t
format_len,
Review Comment:
warning: function 'from_date_format_str' exceeds recommended size/complexity
thresholds [readability-function-size]
```cpp
bool VecDateTimeValue::from_date_format_str(const char* format, size_t
format_len,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/runtime/vdatetime_value.cpp:1205:** 425 lines including
whitespace and comments (threshold 80)
```cpp
bool VecDateTimeValue::from_date_format_str(const char* format, size_t
format_len,
^
```
</details>
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -2253,8 +2254,8 @@
// this method is exactly same as fromDateFormatStr() in DateLiteral.java in FE
// change this method should also change that.
template <typename T>
-bool DateV2Value<T>::from_date_format_str(const char* format, int format_len,
const char* value,
- int value_len, const char**
sub_val_end) {
+bool DateV2Value<T>::from_date_format_str(const char* format, size_t
format_len, const char* value,
Review Comment:
warning: function 'from_date_format_str' has cognitive complexity of 248
(threshold 50) [readability-function-cognitive-complexity]
```cpp
bool DateV2Value<T>::from_date_format_str(const char* format, size_t
format_len, const char* value,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/runtime/vdatetime_value.cpp:2258:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (value_len <= 0) [[unlikely]] {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2296:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
while (ptr < end && val < val_end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2296:** +1
```cpp
while (ptr < end && val < val_end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2298:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
while (val < val_end && check_space(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2298:** +1
```cpp
while (val < val_end && check_space(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2301:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (val >= val_end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2305:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (*ptr == '%' && ptr + 1 < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2305:** +1
```cpp
if (*ptr == '%' && ptr + 1 < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2309:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
switch (*ptr++) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2314:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2317:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
int_value += int_value >= 70 ? 1900 : 2000;
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2325:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2328:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (tmp - val <= 2) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2329:** +5, including nesting
penalty of 4, nesting level increased to 5
```cpp
int_value += int_value >= 70 ? 1900 : 2000;
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2339:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2348:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value < 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2356:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value < 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2366:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2375:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2392:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2402:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2413:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2424:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
while (tmp < val_end && isdigit(*tmp)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2424:** +1
```cpp
while (tmp < val_end && isdigit(*tmp)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2428:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (tmp - val > 6) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2430:** +5, including nesting
penalty of 4, nesting level increased to 5
```cpp
if (!str_to_int64(val, &tmp2, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2433:** +1, nesting level increased
to 4
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2434:** +5, including nesting
penalty of 4, nesting level increased to 5
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2438:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if constexpr (is_datetime) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2446:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if ((val_end - val) < 2 || toupper(*(val + 1)) != 'M' ||
!hour_system_12) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2446:** +1
```cpp
if ((val_end - val) < 2 || toupper(*(val + 1)) != 'M' ||
!hour_system_12) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2449:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (toupper(*val) == 'P') {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2458:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value < 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2467:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value < 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2476:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2479:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value >= 7) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2482:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value == 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2491:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2502:** +1
```cpp
sunday_first = (*(ptr - 1) == 'U' || *(ptr - 1) == 'V');
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2504:** +1
```cpp
strict_week_number = (*(ptr - 1) == 'V' || *(ptr - 1) ==
'v');
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2506:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2510:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (week_num > 53 || (strict_week_number && week_num == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2510:** +1
```cpp
if (week_num > 53 || (strict_week_number && week_num == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2510:** +1
```cpp
if (week_num > 53 || (strict_week_number && week_num == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2521:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2529:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if constexpr (is_datetime) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2531:** +5, including nesting
penalty of 4, nesting level increased to 5
```cpp
if (!tmp_val.from_date_format_str("%I:%i:%S %p", 11,
val, val_end - val,
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2542:** +1, nesting level increased
to 4
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2547:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if constexpr (is_datetime) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2549:** +5, including nesting
penalty of 4, nesting level increased to 5
```cpp
if (!tmp_val.from_date_format_str("%H:%i:%S", 8, val,
val_end - val, &tmp)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2559:** +1, nesting level increased
to 4
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2564:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
while (val < val_end && ispunct(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2564:** +1
```cpp
while (val < val_end && ispunct(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2569:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
while (val < val_end && isalpha(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2569:** +1
```cpp
while (val < val_end && isalpha(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2574:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
while (val < val_end && isdigit(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2574:** +1
```cpp
while (val < val_end && isdigit(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2579:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if ('%' != *val) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2587:** +1, nesting level increased
to 2
```cpp
} else if (!isspace(*ptr)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2588:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (*ptr != *val) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2593:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2599:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
while (ptr < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2600:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (*ptr == '%' && ptr + 1 < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2600:** +1
```cpp
if (*ptr == '%' && ptr + 1 < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2602:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
switch (*ptr++) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2620:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2625:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (!part_used) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2629:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (hour_system_12) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2630:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (hour > 12 || hour < 1) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2630:** +1
```cpp
if (hour > 12 || hour < 1) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2635:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (sub_val_end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2640:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (part_used & FRAC_PART) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2641:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if constexpr (!is_datetime) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2644:** +1, nesting level increased
to 1
```cpp
} else if (part_used & TIME_PART) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2645:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if constexpr (!is_datetime) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2651:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (yearday > 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2653:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (!get_date_from_daynr(days)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2658:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (week_num >= 0 && weekday > 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2658:** +1
```cpp
if (week_num >= 0 && weekday > 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2660:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if ((strict_week_number &&
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2661:** +1
```cpp
(strict_week_number_year < 0 || strict_week_number_year_type !=
sunday_first)) ||
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2660:** +1
```cpp
if ((strict_week_number &&
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2661:** +1
```cpp
(strict_week_number_year < 0 || strict_week_number_year_type !=
sunday_first)) ||
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2662:** +1
```cpp
(!strict_week_number && strict_week_number_year >= 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2666:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
doris::calc_daynr(strict_week_number ?
strict_week_number_year : year, 1, 1);
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2670:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (sunday_first) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2671:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
days += ((weekday_b == 0) ? 0 : 7) - weekday_b + (week_num - 1)
* 7 + weekday % 7;
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2672:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2673:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
days += ((weekday_b <= 3) ? 0 : 7) - weekday_b + (week_num - 1)
* 7 + weekday - 1;
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2675:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (!get_date_from_daynr(days)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2683:** +1
```cpp
bool already_set_date_part = yearday > 0 || (week_num >= 0 && weekday >
0);
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2683:** +1
```cpp
bool already_set_date_part = yearday > 0 || (week_num >= 0 && weekday >
0);
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2684:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (already_set_date_part && already_set_time_part) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2684:** +1
```cpp
if (already_set_date_part && already_set_time_part) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2687:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (already_set_date_part) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2688:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if constexpr (is_datetime) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2691:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2697:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (!(part_used & ~NORMAL_DATE_PART)) { // Ymd part only
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2698:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (!(part_used & DAY_PART)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2700:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (!(part_used & MONTH_PART)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2706:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (already_set_time_part) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2707:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if constexpr (is_datetime) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2711:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2715:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if constexpr (is_datetime) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:2718:** +1, nesting level increased
to 1
```cpp
} else {
^
```
</details>
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -1203,8 +1203,9 @@
// this method is exactly same as fromDateFormatStr() in DateLiteral.java in FE
// change this method should also change that.
-bool VecDateTimeValue::from_date_format_str(const char* format, int
format_len, const char* value,
- int value_len, const char**
sub_val_end) {
+bool VecDateTimeValue::from_date_format_str(const char* format, size_t
format_len,
Review Comment:
warning: function 'from_date_format_str' has cognitive complexity of 207
(threshold 50) [readability-function-cognitive-complexity]
```cpp
bool VecDateTimeValue::from_date_format_str(const char* format, size_t
format_len,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/runtime/vdatetime_value.cpp:1208:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (value_len <= 0) [[unlikely]] {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1245:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
while (ptr < end && val < val_end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1245:** +1
```cpp
while (ptr < end && val < val_end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1247:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
while (val < val_end && check_space(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1247:** +1
```cpp
while (val < val_end && check_space(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1250:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (val >= val_end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1254:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (*ptr == '%' && ptr + 1 < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1254:** +1
```cpp
if (*ptr == '%' && ptr + 1 < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1258:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
switch (*ptr++) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1263:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1266:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
int_value += int_value >= 70 ? 1900 : 2000;
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1274:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1277:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (tmp - val <= 2) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1278:** +5, including nesting
penalty of 4, nesting level increased to 5
```cpp
int_value += int_value >= 70 ? 1900 : 2000;
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1288:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1297:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value < 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1305:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value < 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1315:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1324:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1341:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1351:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1362:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1373:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1380:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if ((val_end - val) < 2 || toupper(*(val + 1)) != 'M' ||
!hour_system_12) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1380:** +1
```cpp
if ((val_end - val) < 2 || toupper(*(val + 1)) != 'M' ||
!hour_system_12) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1383:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (toupper(*val) == 'P') {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1392:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value < 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1401:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value < 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1410:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1413:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value >= 7) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1416:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (int_value == 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1425:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1436:** +1
```cpp
sunday_first = (*(ptr - 1) == 'U' || *(ptr - 1) == 'V');
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1438:** +1
```cpp
strict_week_number = (*(ptr - 1) == 'V' || *(ptr - 1) ==
'v');
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1440:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1444:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (week_num > 53 || (strict_week_number && week_num == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1444:** +1
```cpp
if (week_num > 53 || (strict_week_number && week_num == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1444:** +1
```cpp
if (week_num > 53 || (strict_week_number && week_num == 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1455:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!str_to_int64(val, &tmp, &int_value)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1464:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!tmp_val.from_date_format_str("%I:%i:%S %p", 11, val,
val_end - val, &tmp)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1477:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (!tmp_val.from_date_format_str("%H:%i:%S", 8, val,
val_end - val, &tmp)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1489:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
while (val < val_end && ispunct(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1489:** +1
```cpp
while (val < val_end && ispunct(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1494:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
while (val < val_end && isalpha(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1494:** +1
```cpp
while (val < val_end && isalpha(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1499:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
while (val < val_end && isdigit(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1499:** +1
```cpp
while (val < val_end && isdigit(*val)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1504:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if ('%' != *val) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1512:** +1, nesting level increased
to 2
```cpp
} else if (!check_space(*ptr)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1513:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (*ptr != *val) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1518:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1524:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
while (ptr < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1525:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (*ptr == '%' && ptr + 1 < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1525:** +1
```cpp
if (*ptr == '%' && ptr + 1 < end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1527:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
switch (*ptr++) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1545:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1550:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (!part_used) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1554:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (hour_system_12) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1555:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (hour > 12 || hour < 1) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1555:** +1
```cpp
if (hour > 12 || hour < 1) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1560:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (sub_val_end) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1565:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (part_used & DATE_PART) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1566:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (part_used & TIME_PART) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1568:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1571:** +1, nesting level increased
to 1
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1578:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (yearday > 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1580:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (!get_date_from_daynr(days)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1585:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (week_num >= 0 && weekday > 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1585:** +1
```cpp
if (week_num >= 0 && weekday > 0) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1587:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if ((strict_week_number &&
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1588:** +1
```cpp
(strict_week_number_year < 0 || strict_week_number_year_type !=
sunday_first)) ||
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1587:** +1
```cpp
if ((strict_week_number &&
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1588:** +1
```cpp
(strict_week_number_year < 0 || strict_week_number_year_type !=
sunday_first)) ||
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1589:** +1
```cpp
(!strict_week_number && strict_week_number_year >= 0)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1593:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
doris::calc_daynr(strict_week_number ?
strict_week_number_year : year, 1, 1);
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1597:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (sunday_first) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1598:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
days += ((weekday_b == 0) ? 0 : 7) - weekday_b + (week_num - 1)
* 7 + weekday % 7;
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1599:** +1, nesting level increased
to 2
```cpp
} else {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1600:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
days += ((weekday_b <= 3) ? 0 : 7) - weekday_b + (week_num - 1)
* 7 + weekday - 1;
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1602:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (!get_date_from_daynr(days)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1610:** +1
```cpp
bool already_set_date_part = yearday > 0 || (week_num >= 0 && weekday >
0);
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1610:** +1
```cpp
bool already_set_date_part = yearday > 0 || (week_num >= 0 && weekday >
0);
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1611:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (already_set_date_part && already_set_time_part) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1611:** +1
```cpp
if (already_set_date_part && already_set_time_part) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1615:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (!(part_used & ~NORMAL_DATE_PART)) { // Ymd part only
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1616:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (!(part_used & DAY_PART)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1618:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (!(part_used & MONTH_PART)) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1624:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (already_set_date_part) {
^
```
**be/src/vec/runtime/vdatetime_value.cpp:1627:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (already_set_time_part) {
^
```
</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]