Source:
<code>public void delete(String storageId, String repositoryId, String path, boolean force) throws IOException { logger.debug("Removing " + storageId + ":" + repositoryId + ":" + path + "..."); Storage storage = getConfiguration().getStorage(storageId); Repository repository = storage.getRepository(repositoryId); RepositoryPath repositoryPath = resolve(repository, path); if (!Files.isDirectory(repositoryPath)) { deleteFromIndex(storageId, repositoryId, path); } else { String[] artifactCoordinateElements = path.split("/"); StringBuilder groupId = new StringBuilder(); for (int i = 0; i < artifactCoordinateElements.length - 2; i++) { String element = artifactCoordinateElements[i]; groupId.append((groupId.length() == 0) ? element : "." + element); } String artifactId = artifactCoordinateElements[artifactCoordinateElements.length - 2]; String version = artifactCoordinateElements[artifactCoordinateElements.length - 1]; String pomFilePath = path + "/" + artifactId + "-" + version + ".pom"; if (Files.exists(resolve(repository, pomFilePath))) { SearchRequest request = new SearchRequest(storageId, repositoryId, "+g:" + groupId + " " + "+a:" + artifactId + " " + "+v:" + version); try { SearchResults results = artifactSearchService.search(request); <START> for (SearchResult result : results.getResults()) <END> { String artifactPath = result.getArtifactCoordinates().toPath(); logger.debug("Removing " + artifactPath + " from index..."); deleteFromIndex(storageId, repositoryId, artifactPath); } } catch (ParseException e) { logger.error(e.getMessage(), e); } } } super.delete(storageId, repositoryId, path, force); deleteMetadata(storageId, repositoryId, path); }</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 delete(String storageId, String repositoryId, String path, boolean force) throws IOException, SearchException { logger.debug("Removing " + storageId + ":" + repositoryId + ":" + path + "..."); Storage storage = getConfiguration().getStorage(storageId); Repository repository = storage.getRepository(repositoryId); RepositoryPath repositoryPath = resolve(repository, path); if (!Files.isDirectory(repositoryPath)) { deleteFromIndex(storageId, repositoryId, path); } else { String[] artifactCoordinateElements = path.split("/"); StringBuilder groupId = new StringBuilder(); for (int i = 0; i < artifactCoordinateElements.length - 2; i++) { String element = artifactCoordinateElements[i]; groupId.append((groupId.length() == 0) ? element : "." + element); } String artifactId = artifactCoordinateElements[artifactCoordinateElements.length - 2]; String version = artifactCoordinateElements[artifactCoordinateElements.length - 1]; String pomFilePath = path + "/" + artifactId + "-" + version + ".pom"; if (Files.exists(resolve(repository, pomFilePath))) { SearchRequest request = new SearchRequest(storageId, repositoryId, "+g:" + groupId + " " + "+a:" + artifactId + " " + "+v:" + version, MavenIndexerSearchProvider.ALIAS); try { SearchResults results = artifactSearchService.search(request); for (SearchResult result : results.getResults()) { String artifactPath = result.getArtifactCoordinates().toPath(); logger.debug("Removing " + artifactPath + " from index..."); deleteFromIndex(storageId, repositoryId, artifactPath); } } catch (SearchException e) { logger.error(e.getMessage(), e); } } } super.delete(storageId, repositoryId, path, force); deleteMetadata(storageId, repositoryId, path); }