sigee commented on PR #477: URL: https://github.com/apache/commons-csv/pull/477#issuecomment-2993466347
Hi @ppkarwasz , Thank you for taking the time to review my PR. I'd like to clarify my approach and reasoning. My primary goal was to reduce cognitive complexity as defined in [SonarSource's Cognitive Complexity whitepaper](https://www.sonarsource.com/docs/CognitiveComplexity.pdf). The original method contained multiple levels of nested blocks, which significantly increases cognitive load according to this metric. I extracted the entire nested if-statement block that follows the comment `// build the name to index mappings` into a separate method. I chose the name `buildHeaderNames()` based on that existing comment, though I'm open to suggestions for a more descriptive name. While I acknowledge that I haven't yet simplified the extracted logic itself, I believe this refactoring does provide measurable benefits: - The original `createHeaders()` method now has reduced nesting levels, making the high-level flow easier to follow - The extracted `buildHeaderNames()` method, while containing the same logic, has fewer nested levels than the original method had overall - This separation makes the complex header processing logic more focused I understand your concerns about the method's dual responsibility (returning a value while mutating a parameter). I appreciate your feedback and am happy to iterate on this approach. -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org