use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.
the class AnalysisContextReportPublisherTest method dumpServerSideModuleProps.
@Test
public void dumpServerSideModuleProps() throws Exception {
logTester.setLevel(LoggerLevel.DEBUG);
ScannerReportWriter writer = new ScannerReportWriter(temp.newFolder());
publisher.init(writer);
when(projectRepos.moduleExists("foo")).thenReturn(true);
when(projectRepos.settings("foo")).thenReturn(ImmutableMap.of(COM_FOO, "bar", SONAR_SKIP, "true"));
publisher.dumpModuleSettings(ProjectDefinition.create().setProperty("sonar.projectKey", "foo"));
String content = FileUtils.readFileToString(writer.getFileStructure().analysisLog());
assertThat(content).doesNotContain(COM_FOO);
assertThat(content).containsOnlyOnce(SONAR_SKIP);
}
use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.
the class ReportIteratorTest method setUp.
@Before
public void setUp() throws Exception {
File dir = temp.newFolder();
ScannerReportWriter writer = new ScannerReportWriter(dir);
writer.writeComponentCoverage(1, newArrayList(ScannerReport.LineCoverage.newBuilder().setLine(1).build()));
file = new FileStructure(dir).fileFor(FileStructure.Domain.COVERAGES, 1);
}
use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.
the class BatchReportReaderImplTest method setUp.
@Before
public void setUp() {
BatchReportDirectoryHolder holder = new ImmutableBatchReportDirectoryHolder(tempFolder.newDir());
underTest = new BatchReportReaderImpl(holder);
writer = new ScannerReportWriter(holder.getDirectory());
}
use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.
the class ChangedLinesPublisher method writeChangedLines.
private int writeChangedLines(ScmProvider provider, ScannerReportWriter writer, String targetScmBranch) {
Path rootBaseDir = project.getBaseDir();
Map<Path, DefaultInputFile> changedFiles = StreamSupport.stream(inputComponentStore.allChangedFilesToPublish().spliterator(), false).collect(Collectors.toMap(DefaultInputFile::path, f -> f));
Map<Path, Set<Integer>> pathSetMap = provider.branchChangedLines(targetScmBranch, rootBaseDir, changedFiles.keySet());
int count = 0;
if (pathSetMap == null) {
// the compute engine will use SCM dates to estimate which lines are new
return count;
}
for (Map.Entry<Path, DefaultInputFile> e : changedFiles.entrySet()) {
DefaultInputFile inputFile = e.getValue();
Set<Integer> changedLines = pathSetMap.get(e.getKey());
if (changedLines == null) {
if (branchConfiguration.isPullRequest()) {
LOG.warn("File '{}' was detected as changed but without having changed lines", e.getKey().toAbsolutePath());
}
// assume that no line was changed
writeChangedLines(writer, e.getValue().scannerId(), Collections.emptySet());
} else {
// detect unchanged last empty line
if (changedLines.size() + 1 == inputFile.lines() && inputFile.lineLength(inputFile.lines()) == 0) {
changedLines.add(inputFile.lines());
}
count++;
writeChangedLines(writer, e.getValue().scannerId(), changedLines);
}
}
return count;
}
use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method prepare.
@Before
public void prepare() throws Exception {
MetricFinder metricFinder = mock(MetricFinder.class);
when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
when(metricFinder.<Integer>findByKey(CoreMetrics.LINES_TO_COVER_KEY)).thenReturn(CoreMetrics.LINES_TO_COVER);
settings = new MapSettings();
moduleIssues = mock(IssuePublisher.class);
reportPublisher = mock(ReportPublisher.class);
final File reportDir = temp.newFolder();
reportWriter = new ScannerReportWriter(reportDir);
reportReader = new ScannerReportReader(reportDir);
when(reportPublisher.getWriter()).thenReturn(reportWriter);
when(reportPublisher.getReader()).thenReturn(reportReader);
branchConfiguration = mock(BranchConfiguration.class);
underTest = new DefaultSensorStorage(metricFinder, moduleIssues, settings.asConfig(), reportPublisher, mock(SonarCpdBlockIndex.class), contextPropertiesCache, new ScannerMetrics(), branchConfiguration);
project = new DefaultInputProject(ProjectDefinition.create().setKey("foo").setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder()));
}
Aggregations