use of org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties in project sonarlint-core by SonarSource.
the class SettingsDownloaderTest method testFetchGlobalProperties.
@Test
public void testFetchGlobalProperties() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithReaderResponse("/api/properties?format=json", new StringReader("[{\"key\": \"sonar.core.treemap.colormetric\",\"value\": \"violations_density\"}," + "{\"key\": \"sonar.core.treemap.sizemetric\",\"value\": \"ncloc\"}," + "{\"key\": \"views.servers\",\"value\": \"135817900907501\",\"values\": [\"135817900907501\"]}]"));
new SettingsDownloader(wsClient).fetchGlobalSettingsTo("6.2", destDir);
GlobalProperties properties = ProtobufUtil.readFile(destDir.resolve(StoragePaths.PROPERTIES_PB), GlobalProperties.parser());
assertThat(properties.getPropertiesMap()).containsOnly(entry("sonar.core.treemap.colormetric", "violations_density"), entry("sonar.core.treemap.sizemetric", "ncloc"), entry("views.servers", "135817900907501"));
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties in project sonarlint-core by SonarSource.
the class SettingsDownloaderTest method testFetchGlobalSettings.
@Test
public void testFetchGlobalSettings() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
ValuesWsResponse response = ValuesWsResponse.newBuilder().addSettings(Setting.newBuilder().setKey("sonar.core.treemap.colormetric").setValue("violations_density").setInherited(true)).addSettings(Setting.newBuilder().setKey("sonar.core.treemap.sizemetric").setValue("ncloc")).addSettings(Setting.newBuilder().setKey("views.servers").setValues(Values.newBuilder().addValues("135817900907501"))).build();
PipedInputStream in = new PipedInputStream();
final PipedOutputStream out = new PipedOutputStream(in);
response.writeTo(out);
out.close();
WsClientTestUtils.addResponse(wsClient, "/api/settings/values.protobuf", in);
new SettingsDownloader(wsClient).fetchGlobalSettingsTo("6.3", destDir);
GlobalProperties properties = ProtobufUtil.readFile(destDir.resolve(StoragePaths.PROPERTIES_PB), GlobalProperties.parser());
assertThat(properties.getPropertiesMap()).containsOnly(entry("sonar.core.treemap.sizemetric", "ncloc"), entry("views.servers", "135817900907501"));
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateChecker method checkForUpdates.
public StorageUpdateCheckResult checkForUpdates(String moduleKey, ProgressWrapper progress) {
DefaultStorageUpdateCheckResult result = new DefaultStorageUpdateCheckResult();
String serverVersion = storageReader.readServerInfos().getVersion();
GlobalProperties globalProps = settingsDownloader.fetchGlobalSettings(serverVersion);
ModuleConfiguration serverModuleConfiguration = moduleConfigurationDownloader.fetchModuleConfiguration(serverVersion, moduleKey, globalProps, progress);
ModuleConfiguration storageModuleConfiguration = storageReader.readModuleConfig(moduleKey);
checkForSettingsUpdates(result, serverModuleConfiguration, storageModuleConfiguration);
checkForQualityProfilesUpdates(result, serverModuleConfiguration, storageModuleConfiguration);
return result;
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateExecutor method update.
public void update(String moduleKey, ProgressWrapper progress) {
GlobalProperties globalProps = storageReader.readGlobalProperties();
FileUtils.replaceDir(temp -> {
updateModuleConfiguration(moduleKey, globalProps, temp, progress);
updateRemoteIssues(moduleKey, temp);
updateStatus(temp);
}, storagePaths.getModuleStorageRoot(moduleKey), tempFolder.newDir().toPath());
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties in project sonarlint-core by SonarSource.
the class StorageFileExclusions method getExcludedFiles.
public Set<String> getExcludedFiles(String moduleKey, Collection<String> filePaths, Predicate<String> testFilePredicate) {
GlobalProperties globalProps = storageReader.readGlobalProperties();
ModuleConfiguration moduleConfig = storageReader.readModuleConfig(moduleKey);
MapSettings settings = new MapSettings();
settings.addProperties(globalProps.getProperties());
settings.addProperties(moduleConfig.getProperties());
ExclusionFilters exclusionFilters = new ExclusionFilters(new ConfigurationBridge(settings));
exclusionFilters.prepare();
return filePaths.stream().filter(filePath -> !exclusionFilters.accept(filePath, testFilePredicate.test(filePath) ? Type.TEST : Type.MAIN)).collect(Collectors.toSet());
}
Aggregations