github-actions[bot] commented on code in PR #35883: URL: https://github.com/apache/doris/pull/35883#discussion_r1626938867
########## be/src/vec/runtime/vdatetime_value.cpp: ########## @@ -673,10 +672,12 @@ char* write_four_digits_to_string(int number, char* dst) { return dst + 4; } -bool VecDateTimeValue::to_format_string(const char* format, int len, char* to) const { +bool VecDateTimeValue::to_format_string(const char* format, int len, char* to, Review Comment: warning: function 'to_format_string' has cognitive complexity of 152 (threshold 50) [readability-function-cognitive-complexity] ```cpp bool VecDateTimeValue::to_format_string(const char* format, int len, char* to, ^ ``` <details> <summary>Additional context</summary> **be/src/vec/runtime/vdatetime_value.cpp:676:** +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:687:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp while (ptr < end) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:688:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (*ptr != '%' || (ptr + 1) == end) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:688:** +1 ```cpp if (*ptr != '%' || (ptr + 1) == end) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:689:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 1 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:697:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp switch (ch = *ptr++) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:700:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:709:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 4 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:718:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:726:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:735:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:743:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:753:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:763:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:772:** +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:772:** +1 ```cpp if (_type == TIME_TIME || (_year == 0 && _month == 0)) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:772:** +1 ```cpp if (_type == TIME_TIME || (_year == 0 && _month == 0)) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:775:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 3 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:782:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (_month == 0) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:785:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 3 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:793:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:801:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:805:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (_day >= 10 && _day <= 19) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:805:** +1 ```cpp if (_day >= 10 && _day <= 19) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:807:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:808:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp switch (_day % 10) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:827:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:835:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(6L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:843:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(3L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:851:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:859:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:866:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (_month == 0) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:869:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 9 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:876:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:879:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if ((_hour % 24) >= 12) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:881:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:887:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 11 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:900:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if ((_hour % 24) >= 12) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:902:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:908:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 8 > max_valid_length) [[unlikely]] { ^ ``` **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:928:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:938:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (_type == TIME_TIME) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:941:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:951:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (_type == TIME_TIME) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:954:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:964:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (_type == TIME_TIME) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:967:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:976:** +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:976:** +1 ```cpp if (_type == TIME_TIME || (_month == 0 && _year == 0)) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:976:** +1 ```cpp if (_type == TIME_TIME || (_month == 0 && _year == 0)) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:980:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:987:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 9 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:995:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (_type == TIME_TIME) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:998:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 4 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:1011:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (_type == TIME_TIME) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:1014:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 4 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:1026:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 1 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:1033:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (to - begin + 1 > max_valid_length) [[unlikely]] { ^ ``` </details> ########## be/src/vec/runtime/vdatetime_value.cpp: ########## @@ -3421,10 +3519,12 @@ } template <typename T> -bool DateV2Value<T>::to_format_string(const char* format, int len, char* to) const { +bool DateV2Value<T>::to_format_string(const char* format, int len, char* to, Review Comment: warning: function 'to_format_string' has cognitive complexity of 132 (threshold 50) [readability-function-cognitive-complexity] ```cpp bool DateV2Value<T>::to_format_string(const char* format, int len, char* to, ^ ``` <details> <summary>Additional context</summary> **be/src/vec/runtime/vdatetime_value.cpp:3523:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (is_invalid(year(), month(), day(), hour(), minute(), second(), microsecond())) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3534:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp while (ptr < end) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3535:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (*ptr != '%' || (ptr + 1) == end) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3535:** +1 ```cpp if (*ptr != '%' || (ptr + 1) == end) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3536:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 1 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3544:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp switch (ch = *ptr++) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3547:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3556:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 4 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3565:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3573:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3582:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3590:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3600:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3610:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3619:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (this->year() == 0 && this->month() == 0) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3619:** +1 ```cpp if (this->year() == 0 && this->month() == 0) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3622:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 3 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3629:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (this->month() == 0) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3632:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 3 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3640:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3648:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3652:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (this->day() >= 10 && this->day() <= 19) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3652:** +1 ```cpp if (this->day() >= 10 && this->day() <= 19) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3654:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3655:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp switch (this->day() % 10) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3674:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3682:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(6L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3690:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(3L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3698:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3706:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3713:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (this->month() == 0) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3716:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 9 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3723:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3726:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if ((this->hour() % 24) >= 12) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3728:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3734:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 11 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3747:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if ((this->hour() % 24) >= 12) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3749:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3756:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 8 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3774:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3784:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3794:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3804:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 2 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3813:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (this->month() == 0 && this->year() == 0) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3813:** +1 ```cpp if (this->month() == 0 && this->year() == 0) { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3817:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + std::max(1L, pos - cursor) > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3824:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 9 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3832:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 4 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3846:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 4 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3859:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (to - begin + 1 > max_valid_length) [[unlikely]] { ^ ``` **be/src/vec/runtime/vdatetime_value.cpp:3866:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (to - begin + 1 > max_valid_length) [[unlikely]] { ^ ``` </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