use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class SensorsExecutorTests method testThrowingSensorShouldBeLogged.
@Test
void testThrowingSensorShouldBeLogged() {
var sensorOptimizer = mock(SensorOptimizer.class);
when(sensorOptimizer.shouldExecute(any())).thenReturn(true);
var executor = new SensorsExecutor(null, sensorOptimizer, new ProgressMonitor(null), new Sensor[] { new ThrowingSensor() });
executor.execute();
assertThat(logTester.logs(ClientLogOutput.Level.ERROR)).contains("Error executing sensor: 'Throwing sensor'");
}
use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method analyze.
@Override
public AnalysisResults analyze(ConnectedAnalysisConfiguration configuration, IssueListener issueListener, @Nullable ClientLogOutput logOutput, @Nullable ClientProgressMonitor monitor) {
requireNonNull(configuration);
requireNonNull(issueListener);
setLogging(logOutput);
checkStatus(configuration.projectKey());
var analysisConfigBuilder = AnalysisConfiguration.builder().addInputFiles(configuration.inputFiles());
var projectKey = configuration.projectKey();
if (projectKey != null) {
analysisConfigBuilder.putAllExtraProperties(projectStorage.getAnalyzerConfiguration(projectKey).getSettings().getAll());
analysisConfigBuilder.putAllExtraProperties(globalConfig.extraProperties());
}
var activeRulesContext = buildActiveRulesContext(configuration);
analysisConfigBuilder.putAllExtraProperties(configuration.extraProperties()).addActiveRules(activeRulesContext.activeRules).setBaseDir(configuration.baseDir()).build();
var analysisConfiguration = analysisConfigBuilder.build();
try {
var analysisResults = getAnalysisEngine().post(new AnalyzeCommand(configuration.moduleKey(), analysisConfiguration, issue -> streamIssue(issueListener, issue, activeRulesContext), logOutput), new ProgressMonitor(monitor)).get();
return analysisResults == null ? new AnalysisResults() : analysisResults;
} catch (Exception e) {
throw SonarLintWrappedException.wrap(e);
}
}
use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method sync.
@Override
public void sync(EndpointParams endpoint, HttpClient client, Set<String> projectKeys, @Nullable ClientProgressMonitor monitor) {
var serverApi = new ServerApi(new ServerApiHelper(endpoint, client));
var result = storageSynchronizer.synchronize(serverApi, projectKeys, new ProgressMonitor(monitor));
if (result.hasAnalyzerBeenUpdated()) {
restartAnalysisEngine();
}
}
use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method update.
@Override
public UpdateResult update(EndpointParams endpoint, HttpClient client, @Nullable ClientProgressMonitor monitor) {
requireNonNull(endpoint);
setLogging(null);
globalStorageUpdateExecutor.update(new ServerApiHelper(endpoint, client), new ProgressMonitor(monitor));
return new UpdateResult(globalStatusReader.read());
}
use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class IssueApiTest method should_download_all_vulnerabilities.
@Test
void should_download_all_vulnerabilities() {
mockServer.addProtobufResponse("/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED&types=VULNERABILITY&componentKeys=keyyy&rules=ruleKey&ps=500&p=1", Issues.SearchWsResponse.newBuilder().addIssues(Issues.Issue.newBuilder().setKey("issueKey").build()).build());
mockServer.addProtobufResponse("/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED&types=VULNERABILITY&componentKeys=keyyy&rules=ruleKey&ps=500&p=2", Issues.SearchWsResponse.newBuilder().addComponents(Issues.Component.newBuilder().setKey("componentKey").setPath("componentPath").build()).build());
var result = underTest.downloadVulnerabilitiesForRules("keyyy", Set.of("ruleKey"), null, new ProgressMonitor(null));
assertThat(result.getIssues()).extracting("key").containsOnly("issueKey");
assertThat(result.getComponentPathsByKey()).containsOnly(entry("componentKey", "componentPath"));
}
Aggregations