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


##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -2933,14 +2937,17 @@ bool DateV2Value<T>::get_date_from_daynr(uint64_t 
daynr) {
         }
     }
 
-    set_time(year, month, day, this->hour(), this->minute(), this->second(), 
this->microsecond());
+    unchecked_set_time(year, month, day, this->hour(), this->minute(), 
this->second(),
+                       this->microsecond());
     return true;
 }
 
 template <typename T>
 template <TimeUnit unit, typename TO>
 bool DateV2Value<T>::date_add_interval(const TimeInterval& interval, 
DateV2Value<TO>& to_value) {

Review Comment:
   warning: function 'date_add_interval' has cognitive complexity of 59 
(threshold 50) [readability-function-cognitive-complexity]
   ```cpp
   bool DateV2Value<T>::date_add_interval(const TimeInterval& interval, 
DateV2Value<TO>& to_value) {
                        ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/vec/runtime/vdatetime_value.cpp:2947:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if (!is_valid_date()) {
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2951:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       int sign = interval.is_neg ? -1 : 1;
                                  ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2953:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if constexpr ((unit == MICROSECOND) || (unit == MILLISECOND) || (unit == 
SECOND) ||
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2958:** +1
   ```cpp
                     (unit == DAY_HOUR) || (unit == DAY) || (unit == WEEK)) {
                                                         ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2971:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (microseconds < 0) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2977:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (seconds < 0) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2982:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (!to_value.get_date_from_daynr(day_nr)) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2985:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           PROPAGATE_FALSE(to_value.check_range_and_set_time(
           ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2985:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
           PROPAGATE_FALSE(to_value.check_range_and_set_time(
           ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2987:** +1, nesting level increased 
to 1
   ```cpp
       } else if constexpr (unit == YEAR) {
              ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2989:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           PROPAGATE_FALSE(to_value.template 
set_time_unit<TimeUnit::YEAR>(date_v2_value_.year_ +
           ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2989:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
           PROPAGATE_FALSE(to_value.template 
set_time_unit<TimeUnit::YEAR>(date_v2_value_.year_ +
           ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2991:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (date_v2_value_.month_ == 2 && date_v2_value_.day_ == 29 &&
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2994:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               PROPAGATE_FALSE(to_value.template 
set_time_unit<TimeUnit::DAY>(28));
               ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2994:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
               PROPAGATE_FALSE(to_value.template 
set_time_unit<TimeUnit::DAY>(28));
               ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2996:** +1, nesting level increased 
to 1
   ```cpp
       } else if constexpr (unit == QUARTER || unit == MONTH || unit == 
YEAR_MONTH) {
              ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:2996:** +1
   ```cpp
       } else if constexpr (unit == QUARTER || unit == MONTH || unit == 
YEAR_MONTH) {
                                                             ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3000:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (months < 0) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3003:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           PROPAGATE_FALSE(to_value.template 
set_time_unit<TimeUnit::YEAR>(months / 12));
           ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3003:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
           PROPAGATE_FALSE(to_value.template 
set_time_unit<TimeUnit::YEAR>(months / 12));
           ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3004:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           PROPAGATE_FALSE(to_value.template 
set_time_unit<TimeUnit::MONTH>((months % 12) + 1));
           ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3004:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
           PROPAGATE_FALSE(to_value.template 
set_time_unit<TimeUnit::MONTH>((months % 12) + 1));
           ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3005:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (date_v2_value_.day_ > S_DAYS_IN_MONTH[to_value.month()]) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3007:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (to_value.month() == 2 && doris::is_leap(to_value.year())) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3007:** +1
   ```cpp
               if (to_value.month() == 2 && doris::is_leap(to_value.year())) {
                                         ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3008:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   PROPAGATE_FALSE(
                   ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3008:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                   PROPAGATE_FALSE(
                   ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   
   </details>
   



##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -3010,7 +3018,9 @@
 template <TimeUnit unit, bool need_check>
 bool DateV2Value<T>::date_add_interval(const TimeInterval& interval) {

Review Comment:
   warning: function 'date_add_interval' has cognitive complexity of 65 
(threshold 50) [readability-function-cognitive-complexity]
   ```cpp
   bool DateV2Value<T>::date_add_interval(const TimeInterval& interval) {
                        ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/vec/runtime/vdatetime_value.cpp:3019:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if constexpr (need_check) {
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3020:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (!is_valid_date()) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3025:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       int sign = interval.is_neg ? -1 : 1;
                                  ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3027:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if constexpr ((unit == MICROSECOND) || (unit == MILLISECOND) || (unit == 
SECOND) ||
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3032:** +1
   ```cpp
                     (unit == DAY_HOUR) || (unit == DAY) || (unit == WEEK)) {
                                                         ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3045:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (microseconds < 0) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3051:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (seconds < 0) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3056:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (!this->get_date_from_daynr(day_nr)) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3059:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if constexpr (is_datetime) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3060:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               PROPAGATE_FALSE(this->check_range_and_set_time(0, 0, 0, seconds 
/ 3600,
               ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3060:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
               PROPAGATE_FALSE(this->check_range_and_set_time(0, 0, 0, seconds 
/ 3600,
               ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3064:** +1, nesting level increased 
to 1
   ```cpp
       } else if constexpr (unit == YEAR) {
              ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3066:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           PROPAGATE_FALSE(
           ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3066:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
           PROPAGATE_FALSE(
           ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3068:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (date_v2_value_.month_ == 2 && date_v2_value_.day_ == 29 &&
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3071:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               PROPAGATE_FALSE(this->template set_time_unit<TimeUnit::DAY>(28));
               ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3071:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
               PROPAGATE_FALSE(this->template set_time_unit<TimeUnit::DAY>(28));
               ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3073:** +1, nesting level increased 
to 1
   ```cpp
       } else if constexpr (unit == QUARTER || unit == MONTH || unit == 
YEAR_MONTH) {
              ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3073:** +1
   ```cpp
       } else if constexpr (unit == QUARTER || unit == MONTH || unit == 
YEAR_MONTH) {
                                                             ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3077:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (months < 0) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3080:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           PROPAGATE_FALSE(this->template set_time_unit<TimeUnit::YEAR>(months 
/ 12));
           ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3080:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
           PROPAGATE_FALSE(this->template set_time_unit<TimeUnit::YEAR>(months 
/ 12));
           ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3081:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           PROPAGATE_FALSE(this->template 
set_time_unit<TimeUnit::MONTH>((months % 12) + 1));
           ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3081:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
           PROPAGATE_FALSE(this->template 
set_time_unit<TimeUnit::MONTH>((months % 12) + 1));
           ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3082:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (date_v2_value_.day_ > S_DAYS_IN_MONTH[this->month()]) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3084:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (this->month() == 2 && doris::is_leap(this->year())) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3084:** +1
   ```cpp
               if (this->month() == 2 && doris::is_leap(this->year())) {
                                      ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3085:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   PROPAGATE_FALSE(
                   ^
   ```
   **be/src/common/status.h:622:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
       do {                                          \
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:3085:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                   PROPAGATE_FALSE(
                   ^
   ```
   **be/src/common/status.h:623:** expanded from macro 'PROPAGATE_FALSE'
   ```cpp
           if (UNLIKELY(!static_cast<bool>(stmt))) { \
           ^
   ```
   
   </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