From 4ef7210a06fbd6b979a648f8bdce967717a6512c Mon Sep 17 00:00:00 2001 From: George Tay Date: Thu, 18 Jan 2024 16:39:00 +0800 Subject: [PATCH] [#2073] Refactor `RepoConfigCsvParser::processLine` method to avoid arrowhead style code (#2080) The current implementation of `RepoConfigCsvParser::processLine` contains code that has 3 levels of indentation, making it difficult to read and maintain. With the proposed changes, the level of deep nesting has been reduced to 2 levels, making the code more readable and maintainable. Let's move to refactor and clean up the code to avoid arrowhead-style codes for better readability and maintainability. --- .../reposense/parser/RepoConfigCsvParser.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/reposense/parser/RepoConfigCsvParser.java b/src/main/java/reposense/parser/RepoConfigCsvParser.java index c461fb83cb..1248fdf75f 100644 --- a/src/main/java/reposense/parser/RepoConfigCsvParser.java +++ b/src/main/java/reposense/parser/RepoConfigCsvParser.java @@ -114,20 +114,19 @@ protected void processLine(List results, CSVRecord record) th // If file diff limit is specified if (fileSizeLimitStringList.size() > 0) { + String fileSizeLimitString = fileSizeLimitStringList.get(0).trim(); + int parseValue; + if (isFileSizeLimitIgnored) { logger.warning("Ignoring file size limit column since file size limit is ignored"); isFileSizeLimitOverriding = false; + } else if (!StringsUtil.isNumeric(fileSizeLimitString) + || (parseValue = Integer.parseInt(fileSizeLimitString)) <= 0) { + logger.warning(String.format("Values in \"%s\" column should be positive integers.", + FILESIZE_LIMIT_HEADER[0])); + isFileSizeLimitOverriding = false; } else { - String fileSizeLimitString = fileSizeLimitStringList.get(0).trim(); - int parseValue; - if (!StringsUtil.isNumeric(fileSizeLimitString) - || (parseValue = Integer.parseInt(fileSizeLimitString)) <= 0) { - logger.warning(String.format("Values in \"%s\" column should be positive integers.", - FILESIZE_LIMIT_HEADER[0])); - isFileSizeLimitOverriding = false; - } else { - fileSizeLimit = parseValue; - } + fileSizeLimit = parseValue; } }