Source:
<code>public DocumentReportResult createReport(@NonNull final DocumentReportRequest request) { final StandardDocumentReportType standardDocumentReportType = computeStandardDocumentReportTypeOrNull(request); <START> ArchiveResult lastArchiveResult = ArchiveResult.EMPTY; <END> final DocumentReportAdvisor advisor; DocumentReportRequest requestEffective = request; if (standardDocumentReportType != null) { advisor = getAdvisorByType(standardDocumentReportType); } else if (requestEffective.getReportProcessId() != null) { advisor = getAdvisorByTableName(requestEffective.getDocumentRef().getTableName()); } else if (requestEffective.getPrintFormatIdToUse() != null) { final AdProcessId reportProcessId = util.getReportProcessIdByPrintFormatId(requestEffective.getPrintFormatIdToUse()); requestEffective = requestEffective.withReportProcessId(reportProcessId); advisor = getAdvisorByTableName(requestEffective.getDocumentRef().getTableName()); } else { final org.compiere.model.I_AD_Archive lastArchiveRecord = archiveBL .getLastArchive(requestEffective.getDocumentRef()) .orElseThrow(() -> new AdempiereException("@NoDocPrintFormat@@NoArchive@")); lastArchiveResult = ArchiveResult.builder() .archiveRecord(lastArchiveRecord) .data(archiveBL.getBinaryData(lastArchiveRecord)) .build(); final DocumentReportResult report = DocumentReportResult.builder() .lastArchiveResult(lastArchiveResult) .build(); return report; } final DocumentReportInfo reportInfo = getDocumentReportInfo( advisor, requestEffective.getDocumentRef(), requestEffective.getPrintFormatIdToUse(), requestEffective.getFlavor()); requestEffective = requestEffective .withPrintOptionsFallback(reportInfo.getPrintOptions()) .withPrintOptionsFallback(documentPrintOptionDescriptorsRepository.getPrintingOptionDescriptors(reportInfo.getReportProcessId()).getDefaults()) .withReportProcessId(reportInfo.getReportProcessId()) .withReportLanguage(reportInfo.getLanguage()); final DocumentReportResult report = executeReportProcessAndComputeResult(requestEffective); return report.withBpartnerId(reportInfo.getBpartnerId()); }</code><technical_language>limit scope, move down, is initialized</technical_language>

Target:
public DocumentReportResult createReport(@NonNull final DocumentReportRequest request) { final StandardDocumentReportType standardDocumentReportType = computeStandardDocumentReportTypeOrNull(request); final DocumentReportAdvisor advisor; DocumentReportRequest requestEffective = request; if (standardDocumentReportType != null) { advisor = getAdvisorByType(standardDocumentReportType); } else if (requestEffective.getReportProcessId() != null) { advisor = getAdvisorByTableName(requestEffective.getDocumentRef().getTableName()); } else if (requestEffective.getPrintFormatIdToUse() != null) { final AdProcessId reportProcessId = util.getReportProcessIdByPrintFormatId(requestEffective.getPrintFormatIdToUse()); requestEffective = requestEffective.withReportProcessId(reportProcessId); advisor = getAdvisorByTableName(requestEffective.getDocumentRef().getTableName()); } else { final org.compiere.model.I_AD_Archive lastArchiveRecord = archiveBL .getLastArchive(requestEffective.getDocumentRef()) .orElseThrow(() -> new AdempiereException("@NoDocPrintFormat@@NoArchive@")); final ArchiveResult lastArchive = ArchiveResult.builder() .archiveRecord(lastArchiveRecord) .data(archiveBL.getBinaryData(lastArchiveRecord)) .build(); final DocumentReportResult report = DocumentReportResult.builder() .lastArchive(lastArchive) .build(); return report; } final DocumentReportInfo reportInfo = getDocumentReportInfo( advisor, requestEffective.getDocumentRef(), requestEffective.getPrintFormatIdToUse(), requestEffective.getFlavor()); requestEffective = requestEffective .withPrintOptionsFallback(reportInfo.getPrintOptions()) .withPrintOptionsFallback(documentPrintOptionDescriptorsRepository.getPrintingOptionDescriptors(reportInfo.getReportProcessId()).getDefaults()) .withReportProcessId(reportInfo.getReportProcessId()) .withReportLanguage(reportInfo.getLanguage()); final DocumentReportResult report = executeReportProcessAndComputeResult(requestEffective); return report.withBpartnerId(reportInfo.getBpartnerId()); }