use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class FileSourceDataWarningsTest method create_highlighting_warning_when_one_file_HIGHLIGHT_read_error.
@Test
public void create_highlighting_warning_when_one_file_HIGHLIGHT_read_error() {
ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1).setUuid("uuid").setName(path).build();
LineReader.ReadError readError = new LineReader.ReadError(HIGHLIGHTING, line);
when(system2.now()).thenReturn(timeStamp);
underTest.addWarning(file, readError);
verifyZeroInteractions(taskMessages);
underTest.commitWarnings();
verify(taskMessages, times(1)).add(new CeTaskMessages.Message("Inconsistent highlighting data detected on file '" + path + "'. " + "File source may have been modified while analysis was running.", timeStamp));
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class FileSourceDataWarningsTest method create_symbol_warning_when_any_number_of_read_error_for_one_file.
@Test
public void create_symbol_warning_when_any_number_of_read_error_for_one_file() {
ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1).setUuid("uuid").setName(path).build();
LineReader.ReadError[] readErrors = IntStream.range(0, 1 + random.nextInt(10)).mapToObj(i -> new LineReader.ReadError(SYMBOLS, line + i)).toArray(LineReader.ReadError[]::new);
when(system2.now()).thenReturn(timeStamp);
Arrays.stream(readErrors).forEach(readError -> underTest.addWarning(file, readError));
verifyZeroInteractions(taskMessages);
underTest.commitWarnings();
verify(taskMessages, times(1)).add(new CeTaskMessages.Message("Inconsistent symbol data detected on file '" + path + "'. " + "File source may have been modified while analysis was running.", timeStamp));
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method compute_new_development_cost.
@Test
public void compute_new_development_cost() {
ReportComponent file1 = builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 4)).build();
ReportComponent file2 = builder(FILE, 22_222).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 6)).build();
when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).addChildren(builder(DIRECTORY, 111).addChildren(file1, file2).build()).build());
// 4 lines file, only first one is not ncloc
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
// first 2 lines are before all snapshots, 2 last lines are after PERIOD 2's snapshot date
setNewLines(file1, 3, 4);
// 6 lines file, only last one is not ncloc
measureRepository.addRawMeasure(22_222, NCLOC_DATA_KEY, createNclocDataMeasure(1, 2, 3, 4, 5));
// first 2 lines are before all snapshots, 4 last lines are after PERIOD 2's snapshot date
setNewLines(file2, 3, 4, 5, 6);
underTest.visit(treeRootHolder.getRoot());
assertNewDevelopmentCostValues(ROOT_REF, 5 * LANGUAGE_1_DEV_COST);
assertNewDevelopmentCostValues(LANGUAGE_1_FILE_REF, 2 * LANGUAGE_1_DEV_COST);
assertNewDevelopmentCostValues(22_222, 3 * LANGUAGE_1_DEV_COST);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class LastCommitVisitorTest method compute_date_of_file_from_scm_repo.
@Test
public void compute_date_of_file_from_scm_repo() {
VisitorsCrawler underTest = new VisitorsCrawler(Lists.newArrayList(new LastCommitVisitor(metricRepository, measureRepository, scmInfoRepository)));
scmInfoRepository.setScmInfo(FILE_1_REF, Changeset.newChangesetBuilder().setAuthor("john").setDate(1_500_000_000_000L).setRevision("rev-1").build(), Changeset.newChangesetBuilder().setAuthor("tom").setDate(1_600_000_000_000L).setRevision("rev-2").build(), Changeset.newChangesetBuilder().setAuthor("john").setDate(1_500_000_000_000L).setRevision("rev-1").build());
ReportComponent file = createFileComponent(FILE_1_REF);
treeRootHolder.setRoot(file);
underTest.visit(file);
assertDate(FILE_1_REF, 1_600_000_000_000L);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class LastCommitVisitorTest method date_is_not_computed_on_file_if_blame_is_not_in_scm_repo.
@Test
public void date_is_not_computed_on_file_if_blame_is_not_in_scm_repo() {
VisitorsCrawler underTest = new VisitorsCrawler(Lists.newArrayList(new LastCommitVisitor(metricRepository, measureRepository, scmInfoRepository)));
ReportComponent file = createFileComponent(FILE_1_REF);
treeRootHolder.setRoot(file);
underTest.visit(file);
Optional<Measure> measure = measureRepository.getAddedRawMeasure(FILE_1_REF, LAST_COMMIT_DATE_KEY);
assertThat(measure).isEmpty();
}
Aggregations