use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class SignificantCodeRepositoryTest method return_null_for_lines_without_information.
@Test
public void return_null_for_lines_without_information() {
Component component = createComponent(5);
List<ScannerReport.LineSgnificantCode> significantCode = new ArrayList<>();
// line 3 and 5 missing
significantCode.add(createLineSignificantCode(1, 1, 2));
significantCode.add(createLineSignificantCode(2, 1, 2));
significantCode.add(createLineSignificantCode(4, 1, 2));
reportReader.putSignificantCode(component.getReportAttributes().getRef(), significantCode);
assertThat(underTest.getRangesPerLine(component)).isNotEmpty();
LineRange[] lines = underTest.getRangesPerLine(component).get();
assertThat(lines).hasSize(5);
assertThat(lines[0]).isNotNull();
assertThat(lines[1]).isNotNull();
assertThat(lines[2]).isNull();
assertThat(lines[3]).isNotNull();
assertThat(lines[4]).isNull();
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class SourceLinesDiffImplTest method should_find_diff_with_reference_branch_for_prs.
@Test
public void should_find_diff_with_reference_branch_for_prs() {
periodHolder.setPeriod(null);
Component component = fileComponent(FILE_REF);
mockLineHashesInDb(2, CONTENT);
setLineHashesInReport(component, CONTENT);
when(analysisMetadataHolder.isPullRequest()).thenReturn(true);
when(referenceBranchComponentUuids.getComponentUuid(component.getKey())).thenReturn("uuid_2");
assertThat(underTest.computeMatchingLines(component)).containsExactly(1, 2, 3, 4, 5, 6, 7);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class SourceLinesDiffImplTest method should_find_no_diff_when_report_and_db_content_are_identical.
@Test
public void should_find_no_diff_when_report_and_db_content_are_identical() {
periodHolder.setPeriod(null);
Component component = fileComponent(FILE_REF);
mockLineHashesInDb(FILE_REF, CONTENT);
setLineHashesInReport(component, CONTENT);
assertThat(underTest.computeMatchingLines(component)).containsExactly(1, 2, 3, 4, 5, 6, 7);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class NewEffortAggregator method beforeComponent.
@Override
public void beforeComponent(Component component) {
counter = new NewEffortCounter();
counterByComponentUuid.put(component.getUuid(), counter);
for (Component child : component.getChildren()) {
NewEffortCounter childSum = counterByComponentUuid.remove(child.getUuid());
if (childSum != null) {
counter.add(childSum);
}
}
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class IssueCounter method beforeComponent.
@Override
public void beforeComponent(Component component) {
currentCounters = new Counters();
countersByComponentUuid.put(component.getUuid(), currentCounters);
// aggregate children counters
for (Component child : component.getChildren()) {
Counters childCounters = countersByComponentUuid.remove(child.getUuid());
currentCounters.add(childCounters);
}
}
Aggregations