Source:
<code>public void execute(Path path) { File f = path.toAbsolutePath() .toFile(); String[] list = f.list(new MetadataFilenameFilter()); List<String> filePaths = list != null ? Arrays.asList(list) : new ArrayList<>(); String parentPath = path.getParent() .toAbsolutePath() .toString(); if (!filePaths.isEmpty()) { if (!getVisitedRootPaths().isEmpty() && getVisitedRootPaths().containsKey(parentPath)) { List<File> visitedVersionPaths = getVisitedRootPaths().get(parentPath); if (visitedVersionPaths.contains(f)) { return; } } if (logger.isDebugEnabled()) { System.out.println(parentPath); } if (previousPath != null && !parentPath.startsWith(previousPath)) { getVisitedRootPaths().remove(previousPath); previousPath = parentPath; } if (previousPath == null) { previousPath = parentPath; } List<File> versionDirectories = getVersionDirectories(Paths.get(parentPath)); if (versionDirectories != null) { getVisitedRootPaths().put(parentPath, versionDirectories); if (logger.isDebugEnabled()) { <START> for (File directory : versionDirectories) <END> { System.out.println(" " + directory.getAbsolutePath()); } } String artifactPath = parentPath.substring(getRepository().getBasedir() .length() + 1, parentPath.length()); try { LayoutProvider layoutProvider = getLayoutProvider(getRepository(), layoutProviderRegistry); layoutProvider.generateChecksum(getRepository(), artifactPath, versionDirectories, forceRegeneration); } catch (IOException | NoSuchAlgorithmException | ProviderImplementationException | UnknownRepositoryTypeException | ArtifactTransportException e) { logger.error("Failed to generate checksum for " + artifactPath, e); } } } }</code><technical_language>![MINOR](<LINK_0> 'Severity: MINOR') Refactor this code nest more 3 if/for/while/switch/try statements. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
public void execute(Path path) { File f = path.toAbsolutePath() .toFile(); LayoutProvider layoutProvider = null; try { layoutProvider = getLayoutProvider(getRepository(), layoutProviderRegistry); setFilenameFilter(layoutProvider.getMetadataFilenameFilter()); } catch (ProviderImplementationException e) { logger.error("Failed to get layout provider for repository " + getRepository(), e); } String[] list = f.list(getFilenameFilter()); List<String> filePaths = list != null ? Arrays.asList(list) : new ArrayList<>(); String parentPath = path.getParent() .toAbsolutePath() .toString(); if (!filePaths.isEmpty()) { if (!getVisitedRootPaths().isEmpty() && getVisitedRootPaths().containsKey(parentPath)) { List<File> visitedVersionPaths = getVisitedRootPaths().get(parentPath); if (visitedVersionPaths.contains(f)) { return; } } if (logger.isDebugEnabled()) { System.out.println(parentPath); } if (previousPath != null && !parentPath.startsWith(previousPath)) { getVisitedRootPaths().remove(previousPath); previousPath = parentPath; } if (previousPath == null) { previousPath = parentPath; } List<File> versionDirectories = getVersionDirectories(Paths.get(parentPath)); if (versionDirectories != null) { getVisitedRootPaths().put(parentPath, versionDirectories); if (logger.isDebugEnabled()) { for (File directory : versionDirectories) { System.out.println(" " + directory.getAbsolutePath()); } } String artifactPath = parentPath.substring(getRepository().getBasedir() .length() + 1, parentPath.length()); try { layoutProvider.generateChecksum(getRepository(), artifactPath, versionDirectories, forceRegeneration); } catch (IOException | NoSuchAlgorithmException | ProviderImplementationException | UnknownRepositoryTypeException | ArtifactTransportException e) { logger.error("Failed to generate checksum for " + artifactPath, e); } } } }