org.sonar.api.config.Settings Java Examples
The following examples show how to use
org.sonar.api.config.Settings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TsCoverageSensorImplTest.java From SonarTsPlugin with MIT License | 6 votes |
@Before public void setUp() throws Exception { this.file = new DefaultInputFile("", "src/test/existing.ts").setLanguage(TypeScriptLanguage.LANGUAGE_KEY); this.file.setLines(5); this.settings = mock(Settings.class); when(this.settings.getString(TypeScriptPlugin.SETTING_LCOV_REPORT_PATH)).thenReturn("lcovpath"); this.parser = mock(LCOVParser.class); this.sensor = spy(new TsCoverageSensorImpl()); this.context = SensorContextTester.create(new File("")); this.context.fileSystem().add(this.file); this.context.setSettings(this.settings); this.lcovFile = mock(File.class); when(this.lcovFile.isFile()).thenReturn(true); doReturn(this.lcovFile).when(this.sensor).getIOFile(any(File.class), eq("lcovpath")); doReturn(this.parser).when(this.sensor).getParser(eq(this.context), any(File[].class)); }
Example #2
Source File: BaseTsqlSensor.java From sonar-tsql-plugin with GNU General Public License v3.0 | 6 votes |
@Override public void execute(final org.sonar.api.batch.sensor.SensorContext context) { final Settings settings = context.settings(); final boolean skipAnalysis = settings.getBoolean(Constants.PLUGIN_SKIP); if (skipAnalysis) { LOGGER.debug(String.format("Skipping plugin as skip flag is set: %s", Constants.PLUGIN_SKIP)); return; } final boolean skipSensor = settings.getBoolean(sensorName); if (skipSensor) { LOGGER.debug(String.format("Skipping sensor as skip flag is set: %s", sensorName)); return; } try { innerExecute(context); } catch (Throwable e) { e.printStackTrace(); } }
Example #3
Source File: LuaTest.java From sonar-lua with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testGetFileSuffixes() { Settings settings = new Settings(); Lua lua = new Lua(settings); assertThat(lua.getFileSuffixes()).isEqualTo(new String[] {"lua"}); settings.setProperty(LuaPlugin.FILE_SUFFIXES_KEY, ""); assertThat(lua.getFileSuffixes()).isEqualTo(new String[] {"lua"}); settings.setProperty(LuaPlugin.FILE_SUFFIXES_KEY, "lua"); assertThat(lua.getFileSuffixes()).isEqualTo(new String[] {"lua"}); }
Example #4
Source File: AbstractLanguageAnalyzerSensor.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
public AbstractLanguageAnalyzerSensor(FileSystem fileSystem, CheckFactory checkFactory, Settings settings, NoSonarFilter noSonarFilter, @Nullable CustomRulesDefinition[] customRulesDefinition) { this.fileSystem = fileSystem; this.settings = settings; this.noSonarFilter = noSonarFilter; this.checkFactory = checkFactory; this.customRulesDefinition = customRulesDefinition; this.parser = parser(fileSystem); }
Example #5
Source File: CssLanguageTest.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void custom_file_suffixes() { Settings settings = new Settings(); settings.setProperty("sonar.css.file.suffixes", "css,css3"); CssLanguage language = new CssLanguage(settings); assertThat(language.getFileSuffixes()).containsOnly("css", "css3"); }
Example #6
Source File: LessLanguageTest.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void custom_file_suffixes() { Settings settings = new Settings(); settings.setProperty("sonar.less.file.suffixes", "less,less3"); LessLanguage language = new LessLanguage(settings); assertThat(language.getFileSuffixes()).containsOnly("less", "less3"); }
Example #7
Source File: ScssLanguageTest.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void custom_file_suffixes() { Settings settings = new Settings(); settings.setProperty("sonar.scss.file.suffixes", "scss,scss3"); ScssLanguage language = new ScssLanguage(settings); assertThat(language.getFileSuffixes()).containsOnly("scss", "scss3"); }
Example #8
Source File: RubyTest.java From sonar-ruby-plugin with MIT License | 5 votes |
@Test public void testGetFileSuffixes_Default() { Ruby ruby = new Ruby(new Settings()); String[] fileSuffixes = ruby.getFileSuffixes(); assertThat(fileSuffixes).hasSize(8); assertThat(fileSuffixes).hasSameElementsAs(Lists.newArrayList("rb", "Gemfile", "gemspec", "rake", "spec", "Capfile", "ru", "Rakefile")); }
Example #9
Source File: RubyTest.java From sonar-ruby-plugin with MIT License | 5 votes |
@Test public void testGetFileSuffixes_Override() { Settings settings = new Settings(); settings.setProperty("sonar.ruby.file.suffixes", "rb"); Ruby ruby = new Ruby(settings); String[] fileSuffixes = ruby.getFileSuffixes(); assertThat(fileSuffixes).hasSize(1); assertThat(fileSuffixes).hasSameElementsAs(Lists.newArrayList("rb")); }
Example #10
Source File: RubyTest.java From sonar-ruby-plugin with MIT License | 5 votes |
@Test public void testGetFileSuffixes_WithSpaces() { Settings settings = new Settings(); settings.setProperty("sonar.ruby.file.suffixes", "rb, , gemspec"); Ruby ruby = new Ruby(settings); String[] fileSuffixes = ruby.getFileSuffixes(); assertThat(fileSuffixes).hasSize(2); assertThat(fileSuffixes).hasSameElementsAs(Lists.newArrayList("rb", "gemspec")); }
Example #11
Source File: ApexTest.java From enforce-sonarqube-plugin with MIT License | 5 votes |
@Test public void testCustomFileSuffixes() { Map<String, String> props = Maps.newHashMap(); props.put(Apex.FILE_SUFFIXES_KEY, "cls,apex"); Settings settings = new Settings(); settings.addProperties(props); assertThat(apexLanguage.getFileSuffixes(), is(new String[]{"cls", "trigger"})); }
Example #12
Source File: TsLintExecutorConfig.java From SonarTsPlugin with MIT License | 5 votes |
public static TsLintExecutorConfig fromSettings(Settings settings, SensorContext ctx, PathResolver resolver) { TsLintExecutorConfig toReturn = new TsLintExecutorConfig(); toReturn.setPathToTsLint(resolver.getPath(ctx, TypeScriptPlugin.SETTING_TS_LINT_PATH, TSLINT_FALLBACK_PATH)); toReturn.setConfigFile(resolver.getPath(ctx, TypeScriptPlugin.SETTING_TS_LINT_CONFIG_PATH, CONFIG_FILENAME)); toReturn.setRulesDir(resolver.getPath(ctx, TypeScriptPlugin.SETTING_TS_LINT_RULES_DIR, null)); toReturn.setPathToTsConfig(resolver.getPath(ctx, TypeScriptPlugin.SETTING_TS_LINT_PROJECT_PATH, null)); toReturn.setPathToTsLintOutput(resolver.getPath(ctx, TypeScriptPlugin.SETTING_TS_LINT_OUTPUT_PATH, null)); toReturn.setPathToNode(resolver.getPath(ctx, TypeScriptPlugin.SETTING_TS_LINT_NODE_PATH, NODE_FALLBACK_PATH)); toReturn.setTimeoutMs(Math.max(5000, settings.getInt(TypeScriptPlugin.SETTING_TS_LINT_TIMEOUT))); toReturn.setShouldPerformTypeCheck(settings.getBoolean(TypeScriptPlugin.SETTING_TS_LINT_TYPECHECK)); return toReturn; }
Example #13
Source File: TsRulesDefinitionTest.java From SonarTsPlugin with MIT License | 5 votes |
@Test public void CheckCustomRulesConfigNotProvided() { Settings settings = mock(Settings.class); when(settings.getKeysStartingWith(TypeScriptPlugin.SETTING_TS_RULE_CONFIGS)).thenReturn(new ArrayList<String>()); TsRulesDefinition rulesDef = new TsRulesDefinition(settings); List<TsLintRule> rules = rulesDef.getRules(); assertNotNull(rules); assertEquals(0, rules.size()); }
Example #14
Source File: TsRulesDefinitionTest.java From SonarTsPlugin with MIT License | 5 votes |
@Test public void CheckCustomRulesInhibited() { Settings settings = mock(Settings.class); when(settings.getBoolean(TypeScriptPlugin.SETTING_TS_LINT_DISALLOW_CUSTOM_RULES)).thenReturn(true); TsRulesDefinition rulesDef = new TsRulesDefinition(settings); List<TsLintRule> rules = rulesDef.getRules(); assertNotNull(rules); assertEquals(0, rules.size()); }
Example #15
Source File: TsLintExecutorConfigTest.java From SonarTsPlugin with MIT License | 5 votes |
@Test public void fromSettings_setsTimeoutTo5000msMinimum_ifSetToLess() { Settings settings = new Settings(); settings.setProperty(TypeScriptPlugin.SETTING_TS_LINT_TIMEOUT, 1000); PathResolver resolver = mock(PathResolver.class); TsLintExecutorConfig config = TsLintExecutorConfig.fromSettings(settings, SensorContextTester.create(new File("")), resolver); assertEquals((Integer) 5000, config.getTimeoutMs()); }
Example #16
Source File: GerritPostJob.java From sonar-gerrit-plugin with Apache License 2.0 | 5 votes |
public GerritPostJob(Settings settings, GerritConfiguration gerritConfiguration, GerritFacadeFactory gerritFacadeFactory) { LOG.debug("[GERRIT PLUGIN] Instanciating GerritPostJob"); this.settings = settings; this.gerritFacade = gerritFacadeFactory.getFacade(); this.gerritConfiguration = gerritConfiguration; }
Example #17
Source File: GerritConfiguration.java From sonar-gerrit-plugin with Apache License 2.0 | 5 votes |
public GerritConfiguration(Settings settings) { LOG.debug("[GERRIT PLUGIN] Instanciating GerritConfiguration"); this.enable(settings.getBoolean(PropertyKey.GERRIT_ENABLED)); this.commentNewIssuesOnly(settings.getBoolean(PropertyKey.GERRIT_COMMENT_NEW_ISSUES_ONLY)); this.strictlyCheckHostkey(settings.getBoolean(PropertyKey.GERRIT_STRICT_HOSTKEY)); this.setScheme(settings.getString(PropertyKey.GERRIT_SCHEME)); this.setHost(settings.getString(PropertyKey.GERRIT_HOST)); this.setPort(settings.getInt(PropertyKey.GERRIT_PORT)); this.setUsername(settings.getString(PropertyKey.GERRIT_USERNAME)); this.setPassword(settings.getString(PropertyKey.GERRIT_PASSWORD)); this.setHttpAuthScheme(settings.getString(PropertyKey.GERRIT_HTTP_AUTH_SCHEME)); this.setBasePath(settings.getString(PropertyKey.GERRIT_BASE_PATH)); this.setSshKeyPath(settings.getString(PropertyKey.GERRIT_SSH_KEY_PATH)); this.setLabel(settings.getString(PropertyKey.GERRIT_LABEL)); this.setMessage(settings.getString(PropertyKey.GERRIT_MESSAGE)); this.setIssueComment(settings.getString(PropertyKey.GERRIT_ISSUE_COMMENT)); this.setThreshold(settings.getString(PropertyKey.GERRIT_THRESHOLD)); this.setVoteNoIssue(settings.getInt(PropertyKey.GERRIT_VOTE_NO_ISSUE)); this.setVoteBelowThreshold(settings.getInt(PropertyKey.GERRIT_VOTE_ISSUE_BELOW_THRESHOLD)); this.setVoteAboveThreshold(settings.getInt(PropertyKey.GERRIT_VOTE_ISSUE_ABOVE_THRESHOLD)); this.setProjectName(settings.getString(PropertyKey.GERRIT_PROJECT)); this.setBranchName(settings.getString(PropertyKey.GERRIT_BRANCH)); this.setChangeId(settings.getString(PropertyKey.GERRIT_CHANGE_ID)); this.setRevisionId(settings.getString(PropertyKey.GERRIT_REVISION_ID)); this.assertGerritConfiguration(); }
Example #18
Source File: TSQLLanguageTest.java From sonar-tsql-plugin with GNU General Public License v3.0 | 5 votes |
@Test public void testDefinedSuffixes() { final Settings settings = new org.sonar.api.config.internal.MapSettings(); settings.setProperty(Constants.PLUGIN_SUFFIXES, ".sql,.test"); final TSQLLanguage language = new TSQLLanguage(settings); Assert.assertArrayEquals(new String[] { ".sql", ".test" }, language.getFileSuffixes()); }
Example #19
Source File: PmdExecutor.java From sonar-p3c-pmd with MIT License | 5 votes |
public PmdExecutor(FileSystem fileSystem, RulesProfile rulesProfile, PmdProfileExporter pmdProfileExporter, PmdConfiguration pmdConfiguration, JavaResourceLocator javaResourceLocator, Settings settings) { this.fs = fileSystem; this.rulesProfile = rulesProfile; this.pmdProfileExporter = pmdProfileExporter; this.pmdConfiguration = pmdConfiguration; this.javaResourceLocator = javaResourceLocator; this.settings = settings; }
Example #20
Source File: AbstractLanguageAnalyzerSensor.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public AbstractLanguageAnalyzerSensor(FileSystem fileSystem, CheckFactory checkFactory, Settings settings, NoSonarFilter noSonarFilter) { this(fileSystem, checkFactory, settings, noSonarFilter, null); }
Example #21
Source File: EmbeddedCssAnalyzerSensor.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public EmbeddedCssAnalyzerSensor(FileSystem fileSystem, CheckFactory checkFactory, Settings settings, NoSonarFilter noSonarFilter) { super(fileSystem, checkFactory, settings, noSonarFilter); }
Example #22
Source File: TsLintSensor.java From SonarTsPlugin with MIT License | 4 votes |
public TsLintSensor(Settings settings, PathResolver resolver, TsLintExecutor executor, TsLintParser parser) { this.settings = settings; this.resolver = resolver; this.executor = executor; this.parser = parser; }
Example #23
Source File: EmbeddedCssAnalyzerSensor.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public EmbeddedCssAnalyzerSensor(FileSystem fileSystem, CheckFactory checkFactory, Settings settings, NoSonarFilter noSonarFilter, @Nullable CustomCssRulesDefinition[] customRulesDefinition) { super(fileSystem, checkFactory, settings, noSonarFilter, customRulesDefinition); }
Example #24
Source File: TSQLLanguageTest.java From sonar-tsql-plugin with GNU General Public License v3.0 | 4 votes |
@Test public void testDefaultSuffixes() { final Settings settings = new org.sonar.api.config.internal.MapSettings(); final TSQLLanguage language = new TSQLLanguage(settings); Assert.assertArrayEquals(new String[] { ".sql" }, language.getFileSuffixes()); }
Example #25
Source File: CoverageSensor.java From sonar-tsql-plugin with GNU General Public License v3.0 | 4 votes |
public CoverageSensor(final FileSystem fs, final Settings settings) { this(new SqlCoverCoverageProvider(settings, fs)); }
Example #26
Source File: CssLanguageTest.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void default_file_suffix() { CssLanguage language = new CssLanguage(mock(Settings.class)); assertThat(language.getFileSuffixes()).containsOnly("css"); }
Example #27
Source File: LessAnalyzerSensor.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public LessAnalyzerSensor(FileSystem fileSystem, CheckFactory checkFactory, Settings settings, NoSonarFilter noSonarFilter) { super(fileSystem, checkFactory, settings, noSonarFilter); }
Example #28
Source File: CodeGuardIssuesLoaderSensor.java From sonar-tsql-plugin with GNU General Public License v3.0 | 4 votes |
public CodeGuardIssuesLoaderSensor(final Settings settings, final TempFolder tempFolder) { super(new CodeGuardIssuesProvider(settings, tempFolder), Constants.PLUGIN_SKIP_CG, Constants.CG_REPO_KEY); }
Example #29
Source File: SqlCoverCoverageProvider.java From sonar-tsql-plugin with GNU General Public License v3.0 | 4 votes |
public SqlCoverCoverageProvider(final Settings settings, final FileSystem fileSystem) { this.settings = settings; this.fileSystem = fileSystem; }
Example #30
Source File: CssLanguage.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public CssLanguage(Settings settings) { super(KEY, NAME); this.settings = settings; }