use of org.sonar.ce.task.projectanalysis.component.FileAttributes in project sonarqube by SonarSource.
the class CommonRuleEngineImplTest method do_not_process_files_with_unknown_language.
@Test
public void do_not_process_files_with_unknown_language() {
ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1).setKey("FILE_KEY").setUuid("FILE_UUID").setFileAttributes(new FileAttributes(false, null, 1)).build();
Collection<DefaultIssue> issues = underTest.process(file);
assertThat(issues).isEmpty();
verifyZeroInteractions(rule1, rule2);
}
use of org.sonar.ce.task.projectanalysis.component.FileAttributes in project sonarqube by SonarSource.
the class CommonRuleEngineImplTest method process_files_with_known_language.
@Test
public void process_files_with_known_language() {
ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1).setKey("FILE_KEY").setUuid("FILE_UUID").setFileAttributes(new FileAttributes(false, "java", 1)).build();
DefaultIssue issue = new DefaultIssue();
when(rule1.processFile(file, "java")).thenReturn(issue);
when(rule2.processFile(file, "java")).thenReturn(null);
Collection<DefaultIssue> issues = underTest.process(file);
assertThat(issues).containsOnly(issue);
}
use of org.sonar.ce.task.projectanalysis.component.FileAttributes in project sonarqube by SonarSource.
the class SourceLineReadersFactoryTest method initBasicReport.
private void initBasicReport(int numberOfLines) {
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(ReportComponent.builder(Component.Type.DIRECTORY, 2).setUuid("MODULE").setKey("MODULE_KEY").addChildren(ReportComponent.builder(Component.Type.FILE, FILE1_REF).setUuid(FILE1_UUID).setKey("MODULE_KEY:src/Foo.java").setFileAttributes(new FileAttributes(false, null, numberOfLines)).build()).build()).build());
reportReader.putComponent(ScannerReport.Component.newBuilder().setRef(1).setType(ScannerReport.Component.ComponentType.PROJECT).addChildRef(2).build());
reportReader.putComponent(ScannerReport.Component.newBuilder().setRef(2).setType(ScannerReport.Component.ComponentType.MODULE).addChildRef(FILE1_REF).build());
reportReader.putComponent(ScannerReport.Component.newBuilder().setRef(FILE1_REF).setType(ScannerReport.Component.ComponentType.FILE).setLines(numberOfLines).build());
}
use of org.sonar.ce.task.projectanalysis.component.FileAttributes in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method compute_new_maintainability_rating_to_A_when_no_debt.
@Test
public void compute_new_maintainability_rating_to_A_when_no_debt() {
when(newLinesRepository.newLinesAvailable()).thenReturn(true);
when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).addChildren(builder(DIRECTORY, 111).addChildren(builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build()).build()).build());
underTest.visit(treeRootHolder.getRoot());
assertNewMaintainability(LANGUAGE_1_FILE_REF, A);
assertNewMaintainability(111, A);
assertNewMaintainability(ROOT_REF, A);
}
use of org.sonar.ce.task.projectanalysis.component.FileAttributes in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method file_has_0_new_debt_ratio_if_no_line_is_new.
@Test
public void file_has_0_new_debt_ratio_if_no_line_is_new() {
ReportComponent file = builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build();
treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).addChildren(file).build());
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50));
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
setNewLines(file);
underTest.visit(treeRootHolder.getRoot());
assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 0);
assertNewDebtRatioValues(ROOT_REF, 0);
}
Aggregations