Source:
<code>public NotificationDto process(File runDirectory, TimeZone tz) throws IOException { Process process = new ProcessBuilder("nice", "runscanner-illumina", runDirectory.getAbsolutePath()).directory(runDirectory).start(); IlluminaNotificationDto dto = createObjectMapper().readValue(process.getInputStream(), IlluminaNotificationDto.class); dto.setSequencerFolderPath(runDirectory.getAbsolutePath()); try { if (process.waitFor() != 0) { throw new IOException("Illumina run processor did not exit cleanly: " + runDirectory.getAbsolutePath()); } } catch (InterruptedException e) { throw new IOException(e); } try { Document parameters = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(runDirectory, "runParameters.xml")); dto.setChemistry(Arrays.stream(IlluminaChemistry.values()).filter(chemistry -> chemistry.test(parameters)).findFirst() .orElse(IlluminaChemistry.UNKNOWN)); } catch (SAXException | ParserConfigurationException e) { log.error("Failed to parse parameters", e); } File rtaLogDir = new File(runDirectory, "/Data/RTALogs"); boolean failed = Optional .ofNullable(rtaLogDir.listFiles(file -> file.getName().endsWith("Log.txt") || file.getName().endsWith("Log_00.txt"))) <START> .map(files -> Arrays.stream(files) <END> .anyMatch(file -> { try (Scanner scanner = new Scanner(file)) { return scanner.findWithinHorizon(FAILED_MESSAGE, 0) != null; } catch (FileNotFoundException e) { log.error("RTA file vanished before reading", e); return false; } })) .orElse(false); if (failed) { dto.setHealthType(HealthType.Failed); } return dto; }</code><technical_language>![MINOR](<LINK_1> 'Severity: MINOR') Refactor code get this URI a customizable parameter. [![rule](<LINK_0>](<LINK_2></technical_language>

Target:
public NotificationDto process(File runDirectory, TimeZone tz) throws IOException { Process process = new ProcessBuilder("nice", "runscanner-illumina", runDirectory.getAbsolutePath()).directory(runDirectory).start(); IlluminaNotificationDto dto = createObjectMapper().readValue(process.getInputStream(), IlluminaNotificationDto.class); dto.setSequencerFolderPath(runDirectory.getAbsolutePath()); try { if (process.waitFor() != 0) { throw new IOException("Illumina run processor did not exit cleanly: " + runDirectory.getAbsolutePath()); } } catch (InterruptedException e) { throw new IOException(e); } dto.setChemistry(Stream.of("runParameters.xml", "RunParameters.xml").map(f -> new File(runDirectory, f)) .filter(file -> file.exists() && file.canRead()).findAny().flatMap(file -> { try { Document parameters = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file); return Arrays.stream(IlluminaChemistry.values()).filter(chemistry -> chemistry.test(parameters)).findFirst(); } catch (SAXException | ParserConfigurationException | IOException e) { log.error("Failed to parse parameters", e); return Optional.empty(); } }).orElse(IlluminaChemistry.UNKNOWN)); File rtaLogDir = new File(runDirectory, "/Data/RTALogs"); boolean failed = Optional .ofNullable(rtaLogDir.listFiles(file -> file.getName().endsWith("Log.txt") || file.getName().endsWith("Log_00.txt"))) .map(files -> Arrays.stream(files) .anyMatch(file -> { try (Scanner scanner = new Scanner(file)) { return scanner.findWithinHorizon(FAILED_MESSAGE, 0) != null; } catch (FileNotFoundException e) { log.error("RTA file vanished before reading", e); return false; } })) .orElse(false); if (failed) { dto.setHealthType(HealthType.Failed); } return dto; }