use of org.sonar.api.config.internal.MapSettings 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());
}
use of org.sonar.api.config.internal.MapSettings in project sonarlint-core by SonarSource.
the class DefaultServerTest method shouldLoadServerProperties.
@Test
public void shouldLoadServerProperties() {
SonarRuntime runtime = mock(SonarRuntime.class);
when(runtime.getApiVersion()).thenReturn(Version.create(2, 2));
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.SERVER_ID, "123");
settings.setProperty(CoreProperties.SERVER_STARTTIME, "2010-05-18T17:59:00+0000");
settings.setProperty(CoreProperties.PERMANENT_SERVER_ID, "abcde");
DefaultServer metadata = new DefaultServer(settings, runtime);
assertThat(metadata.getId()).isEqualTo("123");
assertThat(metadata.getVersion()).isEqualTo("2.2");
assertThat(metadata.getStartedAt()).isNotNull();
assertThat(metadata.getURL()).isNull();
assertThat(metadata.getPermanentServerId()).isEqualTo("abcde");
}
use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class JavaTestClasspathTest method setUp.
@Before
public void setUp() throws Exception {
fs = new DefaultFileSystem(new File("src/test/files/classpath/"));
TestInputFileBuilder inputFile = new TestInputFileBuilder("", "foo.java");
inputFile.setLanguage("java");
inputFile.setType(InputFile.Type.TEST);
fs.add(inputFile.build());
settings = new MapSettings();
}
use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class JavaClasspathTest method setUp.
@Before
public void setUp() throws Exception {
fs = new DefaultFileSystem(new File("src/test/files/classpath/"));
TestInputFileBuilder inputFile = new TestInputFileBuilder("", "foo.java");
inputFile.setLanguage("java");
inputFile.setType(InputFile.Type.MAIN);
fs.add(inputFile.build());
settings = new MapSettings();
}
use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class JavaRulesDefinitionTest method debug_rules.
@Test
public void debug_rules() {
MapSettings settings = new MapSettings();
settings.setProperty("sonar.java.debug", true);
JavaRulesDefinition definition = new JavaRulesDefinition(settings.asConfig());
RulesDefinition.Context context = new RulesDefinition.Context();
definition.define(context);
RulesDefinition.Repository repository = context.repository("squid");
assertThat(repository.name()).isEqualTo("SonarAnalyzer");
assertThat(repository.language()).isEqualTo("java");
assertThat(repository.rules()).hasSize(CheckList.getChecks().size() + CheckList.getDebugChecks().size());
}
Aggregations