dataroaring commented on PR #55751:
URL: https://github.com/apache/doris/pull/55751#issuecomment-3284138749

   **🚨 CRITICAL: Complex Boolean Logic Hard to Maintain**
   
   **File**: `be/src/olap/tablet.cpp` lines 172-175
   
   ```cpp
   if (!(injection || (!config::disable_auto_compaction &&
                       
!_tablet->tablet_meta()->tablet_schema()->disable_auto_compaction()))) {
       return Status::OK();
   }
   ```
   
   **Issue**: This double negation with nested boolean logic is extremely 
difficult to read, understand, and maintain. Future developers (including 
yourself) will struggle to reason about this condition.
   
   **Problems**:
   - Double negation makes logic confusing
   - Complex nested conditions are error-prone
   - Maintenance nightmare for bug fixes or modifications
   - High cognitive load to understand the intended behavior
   
   **Recommendation**: Simplify with clear intermediate variables:
   ```cpp
   bool debug_injection = injection;
   bool auto_compaction_enabled = !config::disable_auto_compaction && 
                                  
!_tablet->tablet_meta()->tablet_schema()->disable_auto_compaction();
   
   if (!debug_injection && !auto_compaction_enabled) {
       return Status::OK();
   }
   ```
   
   This makes the logic crystal clear: "Return early if neither debug injection 
is active nor auto-compaction is enabled."


-- 
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