tanmay created NUTCH-3169:
-----------------------------

             Summary: Reduce Cognitive Complexity in AdaptiveFetchSchedule
                 Key: NUTCH-3169
                 URL: https://issues.apache.org/jira/browse/NUTCH-3169
             Project: Nutch
          Issue Type: Improvement
          Components: fetcher
            Reporter: tanmay


The `setFetchSchedule` method in `org.apache.nutch.crawl.AdaptiveFetchSchedule` 
currently has a high Cognitive Complexity score of 26, which exceeds the 
standard SonarQube threshold of 15 (Warning java:S3776).

The complexity is primarily driven by deep nesting, a large switch statement, 
and embedded synchronization delta logic all housed within a single `else` 
block. 

Proposed Improvement.
Refactor the `setFetchSchedule` method to improve readability and 
maintainability by:
1. Utilizing early returns (guard clauses) to eliminate the outermost nesting 
levels.
2. Extracting the state adjustment and synchronization delta calculations into 
private, focused helper methods.

This is strictly a structural refactor. No core business logic or expected 
outputs of the scheduling algorithm will be altered.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to