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


##########
be/src/runtime/task_execution_context.cpp:
##########
@@ -0,0 +1,290 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "runtime/task_execution_context.h"
+
+#include <thrift/protocol/TDebugProtocol.h>
+#include <thrift/transport/TTransportException.h>
+
+#include <memory>
+
+#include "runtime/client_cache.h"
+#include "runtime/exec_env.h"
+#include "runtime/fragment_mgr.h"
+#include "service/backend_options.h"
+
+namespace doris {
+std::string to_http_path(const std::string& file_name) {
+    std::stringstream url;
+    url << "http://"; << BackendOptions::get_localhost() << ":" << 
config::webserver_port
+        << "/api/_download_load?"
+        << "token=" << ExecEnv::GetInstance()->token() << "&file=" << 
file_name;
+    return url.str();
+};
+
+Status TaskExecutionContext::trigger_profile_report(
+        std::shared_ptr<doris::ReportStatusRequest> request) {
+    // Create a shared pointer to capture and extend the lifetime of 
TaskExecutionContext
+    auto shared_this = shared_from_this();
+
+    auto report_profile_task = [shared_this, request]() {
+        shared_this->do_report_profile(request);
+
+        if (!request->done) {
+            shared_this->refresh_next_report_time();
+        }
+    };
+
+    return 
ExecEnv::GetInstance()->fragment_mgr()->submit_report_profile_task(report_profile_task);
+};
+
+void 
TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest>
 req) {

Review Comment:
   warning: function 'do_report_profile' exceeds recommended size/complexity 
thresholds [readability-function-size]
   ```cpp
   void 
TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest>
 req) {
                              ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/runtime/task_execution_context.cpp:54:** 233 lines including 
whitespace and comments (threshold 80)
   ```cpp
   void 
TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest>
 req) {
                              ^
   ```
   
   </details>
   



##########
be/src/runtime/task_execution_context.cpp:
##########
@@ -0,0 +1,290 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "runtime/task_execution_context.h"
+
+#include <thrift/protocol/TDebugProtocol.h>
+#include <thrift/transport/TTransportException.h>
+
+#include <memory>
+
+#include "runtime/client_cache.h"
+#include "runtime/exec_env.h"
+#include "runtime/fragment_mgr.h"
+#include "service/backend_options.h"
+
+namespace doris {
+std::string to_http_path(const std::string& file_name) {
+    std::stringstream url;
+    url << "http://"; << BackendOptions::get_localhost() << ":" << 
config::webserver_port
+        << "/api/_download_load?"
+        << "token=" << ExecEnv::GetInstance()->token() << "&file=" << 
file_name;
+    return url.str();
+};
+
+Status TaskExecutionContext::trigger_profile_report(
+        std::shared_ptr<doris::ReportStatusRequest> request) {
+    // Create a shared pointer to capture and extend the lifetime of 
TaskExecutionContext
+    auto shared_this = shared_from_this();
+
+    auto report_profile_task = [shared_this, request]() {
+        shared_this->do_report_profile(request);
+
+        if (!request->done) {
+            shared_this->refresh_next_report_time();
+        }
+    };
+
+    return 
ExecEnv::GetInstance()->fragment_mgr()->submit_report_profile_task(report_profile_task);
+};
+
+void 
TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest>
 req) {

Review Comment:
   warning: function 'do_report_profile' has cognitive complexity of 53 
(threshold 50) [readability-function-cognitive-complexity]
   ```cpp
   void 
TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest>
 req) {
                              ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/runtime/task_execution_context.cpp:57:** +1
   ```cpp
       DCHECK(req->status.ok() || req->done); // if !status.ok() => done
                               ^
   ```
   **be/src/runtime/task_execution_context.cpp:62:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if (!coord_status.ok()) {
       ^
   ```
   **be/src/runtime/task_execution_context.cpp:84:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if (req->runtime_state->query_type() == TQueryType::LOAD && !req->done 
&& req->status.ok()) {
       ^
   ```
   **be/src/runtime/task_execution_context.cpp:88:** +1, nesting level 
increased to 1
   ```cpp
       } else {
         ^
   ```
   **be/src/runtime/task_execution_context.cpp:89:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (req->runtime_state->query_type() == TQueryType::LOAD) {
           ^
   ```
   **be/src/runtime/task_execution_context.cpp:93:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (req->is_pipeline_x) {
           ^
   ```
   **be/src/runtime/task_execution_context.cpp:97:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (enable_profile) {
               ^
   ```
   **be/src/runtime/task_execution_context.cpp:108:** +1, nesting level 
increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/runtime/task_execution_context.cpp:112:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (enable_profile) {
               ^
   ```
   **be/src/runtime/task_execution_context.cpp:122:** +1, nesting level 
increased to 2
   ```cpp
           } else {
             ^
   ```
   **be/src/runtime/task_execution_context.cpp:123:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (req->profile != nullptr) {
               ^
   ```
   **be/src/runtime/task_execution_context.cpp:125:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   if (req->load_channel_profile) {
                   ^
   ```
   **be/src/runtime/task_execution_context.cpp:130:** +1, nesting level 
increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/runtime/task_execution_context.cpp:135:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (!req->runtime_state->output_files().empty()) {
           ^
   ```
   **be/src/runtime/task_execution_context.cpp:140:** +1, nesting level 
increased to 2
   ```cpp
           } else if (!req->runtime_states.empty()) {
                  ^
   ```
   **be/src/runtime/task_execution_context.cpp:146:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (!params.delta_urls.empty()) {
               ^
   ```
   **be/src/runtime/task_execution_context.cpp:158:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (req->runtime_state->num_rows_load_total() > 0 ||
           ^
   ```
   **be/src/runtime/task_execution_context.cpp:158:** +1
   ```cpp
           if (req->runtime_state->num_rows_load_total() > 0 ||
                                                             ^
   ```
   **be/src/runtime/task_execution_context.cpp:165:** +1, nesting level 
increased to 2
   ```cpp
           } else if (!req->runtime_states.empty()) {
                  ^
   ```
   **be/src/runtime/task_execution_context.cpp:179:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (!req->runtime_state->get_error_log_file_path().empty()) {
           ^
   ```
   **be/src/runtime/task_execution_context.cpp:182:** +1, nesting level 
increased to 2
   ```cpp
           } else if (!req->runtime_states.empty()) {
                  ^
   ```
   **be/src/runtime/task_execution_context.cpp:190:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (!req->runtime_state->export_output_files().empty()) {
           ^
   ```
   **be/src/runtime/task_execution_context.cpp:193:** +1, nesting level 
increased to 2
   ```cpp
           } else if (!req->runtime_states.empty()) {
                  ^
   ```
   **be/src/runtime/task_execution_context.cpp:203:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (!req->runtime_state->tablet_commit_infos().empty()) {
           ^
   ```
   **be/src/runtime/task_execution_context.cpp:209:** +1, nesting level 
increased to 2
   ```cpp
           } else if (!req->runtime_states.empty()) {
                  ^
   ```
   **be/src/runtime/task_execution_context.cpp:219:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (!req->runtime_state->error_tablet_infos().empty()) {
           ^
   ```
   **be/src/runtime/task_execution_context.cpp:225:** +1, nesting level 
increased to 2
   ```cpp
           } else if (!req->runtime_states.empty()) {
                  ^
   ```
   **be/src/runtime/task_execution_context.cpp:241:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if (ExecEnv::GetInstance()->master_info()->__isset.backend_id) {
       ^
   ```
   **be/src/runtime/task_execution_context.cpp:250:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if (!exec_status.ok()) {
       ^
   ```
   **be/src/runtime/task_execution_context.cpp:259:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
           } catch (TTransportException& e) {
             ^
   ```
   **be/src/runtime/task_execution_context.cpp:265:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
               if (!rpc_status.ok()) {
               ^
   ```
   **be/src/runtime/task_execution_context.cpp:275:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       } catch (TException& e) {
         ^
   ```
   **be/src/runtime/task_execution_context.cpp:280:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if (!rpc_status.ok()) {
       ^
   ```
   
   </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]

Reply via email to