private void updateCpdTextBlocks(Component component) { cpdTextBlocksEditor.setText(""); if (reader.hasCoverage(component.getRef())) { try (CloseableIterator<ScannerReport.CpdTextBlock> it = reader.readCpdTextBlocks(component.getRef())) { while (it.hasNext()) { ScannerReport.CpdTextBlock textBlock = it.next(); cpdTextBlocksEditor.getDocument().insertString(cpdTextBlocksEditor.getDocument().getEndPosition().getOffset(), textBlock + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read CPD text blocks for " + getNodeName(component), e); } } }
private void updateDuplications(Component component) { duplicationEditor.setText(""); if (reader.hasCoverage(component.getRef())) { try (CloseableIterator<ScannerReport.Duplication> it = reader.readComponentDuplications(component.getRef())) { while (it.hasNext()) { ScannerReport.Duplication dup = it.next(); duplicationEditor.getDocument().insertString(duplicationEditor.getDocument().getEndPosition().getOffset(), dup + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read duplications for " + getNodeName(component), e); } } }
private void updateSignificantCode(Component component) { significantCodeEditor.setText(""); if (reader.hasCoverage(component.getRef())) { try (CloseableIterator<ScannerReport.LineSgnificantCode> it = reader.readComponentSignificantCode(component.getRef())) { if (it != null) { while (it.hasNext()) { ScannerReport.LineSgnificantCode textBlock = it.next(); significantCodeEditor.getDocument().insertString(significantCodeEditor.getDocument().getEndPosition().getOffset(), textBlock + "\n", null); } } } catch (Exception e) { throw new IllegalStateException("Can't read significant code for " + getNodeName(component), e); } } }
@Test public void should_not_skip_report_for_unchanged_files_in_short_branch() { // sanity check, normally report gets generated AnalysisResult result = getResult(tester); assertThat(getResult(tester).getReportComponent(result.inputFile(FILE_PATH))).isNotNull(); int fileId = 2; assertThat(result.getReportReader().readChangesets(fileId)).isNotNull(); assertThat(result.getReportReader().hasCoverage(fileId)).isTrue(); assertThat(result.getReportReader().readFileSource(fileId)).isNotNull(); // file is not skipped for short branches (need coverage, duplications coming soon) AnalysisResult result2 = getResult(tester.setBranchType(BranchType.SHORT)); assertThat(result2.getReportComponent(result2.inputFile(FILE_PATH))).isNotNull(); assertThat(result2.getReportReader().readChangesets(fileId)).isNull(); assertThat(result2.getReportReader().hasCoverage(fileId)).isTrue(); assertThat(result2.getReportReader().readFileSource(fileId)).isNull(); }
private void updateCpdTextBlocks(Component component) { cpdTextBlocksEditor.setText(""); if (reader.hasCoverage(component.getRef())) { try (CloseableIterator<ScannerReport.CpdTextBlock> it = reader.readCpdTextBlocks(component.getRef())) { while (it.hasNext()) { ScannerReport.CpdTextBlock textBlock = it.next(); cpdTextBlocksEditor.getDocument().insertString(cpdTextBlocksEditor.getDocument().getEndPosition().getOffset(), textBlock + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read CPD text blocks for " + getNodeName(component), e); } } }
private void updateDuplications(Component component) { duplicationEditor.setText(""); if (reader.hasCoverage(component.getRef())) { try (CloseableIterator<ScannerReport.Duplication> it = reader.readComponentDuplications(component.getRef())) { while (it.hasNext()) { ScannerReport.Duplication dup = it.next(); duplicationEditor.getDocument().insertString(duplicationEditor.getDocument().getEndPosition().getOffset(), dup + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read duplications for " + getNodeName(component), e); } } }
private void updateSignificantCode(Component component) { significantCodeEditor.setText(""); if (reader.hasCoverage(component.getRef())) { try (CloseableIterator<ScannerReport.LineSgnificantCode> it = reader.readComponentSignificantCode(component.getRef())) { if (it != null) { while (it.hasNext()) { ScannerReport.LineSgnificantCode textBlock = it.next(); significantCodeEditor.getDocument().insertString(significantCodeEditor.getDocument().getEndPosition().getOffset(), textBlock + "\n", null); } } } catch (Exception e) { throw new IllegalStateException("Can't read significant code for " + getNodeName(component), e); } } }