@Test public void default_number_values_are_zero() { Settings settings = new MapSettings(); assertThat(settings.getInt("foo")).isEqualTo(0); assertThat(settings.getLong("foo")).isEqualTo(0L); }
@Test public void set_property_int() { Settings settings = new MapSettings(); settings.setProperty("foo", 123); assertThat(settings.getInt("foo")).isEqualTo(123); assertThat(settings.getString("foo")).isEqualTo("123"); assertThat(settings.getBoolean("foo")).isFalse(); }
@Test public void getInt_value_must_be_valid() { thrown.expect(NumberFormatException.class); Settings settings = new MapSettings(); settings.setProperty("foo", "not a number"); settings.getInt("foo"); }
public int getStashTimeout() { return settings.getInt(StashPlugin.STASH_TIMEOUT); }
public Integer getPullRequestId() { return settings.getInt(StashPlugin.STASH_PULL_REQUEST_ID); }
public int getFilesLimitInOverview() { return settings.getInt(StashPlugin.STASH_FILES_LIMIT_IN_OVERVIEW); }
private int hoursInDay() { return settings.getInt(CoreProperties.HOURS_IN_DAY); }
public int pullRequestNumber() { return settings.getInt(GitHubPlugin.GITHUB_PULL_REQUEST); }
public int getIssueThreshold() { return settings.getInt(StashPlugin.STASH_ISSUE_THRESHOLD); }
public int issueVicinityRange() { return settings.getInt(StashPlugin.STASH_INCLUDE_VICINITY_RANGE); }
@VisibleForTesting int getMinimumTokens(String languageKey) { int minimumTokens = settings.getInt("sonar.cpd." + languageKey + ".minimumTokens"); if (minimumTokens == 0) { minimumTokens = settings.getInt(CoreProperties.CPD_MINIMUM_TOKENS_PROPERTY); } if (minimumTokens == 0) { minimumTokens = 100; } return minimumTokens; }
@VisibleForTesting /** * Not applicable to Java, as the {@link BlockChunker} that it uses does not record start and end units of each block. * Also, it uses statements instead of tokens. * @param languageKey * @return */ int getMinimumTokens(String languageKey) { int minimumTokens = settings.getInt("sonar.cpd." + languageKey + ".minimumTokens"); if (minimumTokens == 0) { minimumTokens = 100; } return minimumTokens; }
@VisibleForTesting int getBlockSize(String languageKey) { int blockSize = settings.getInt("sonar.cpd." + languageKey + ".minimumLines"); if (blockSize == 0) { blockSize = getDefaultBlockSize(languageKey); } return blockSize; }
@VisibleForTesting int getBlockSize(String languageKey) { int blockSize = settings.getInt("sonar.cpd." + languageKey + ".minimumLines"); if (blockSize == 0) { blockSize = getDefaultBlockSize(languageKey); } return blockSize; }
static Date getDateFromWeeks(Settings settings, String propertyKey) { int weeks = settings.getInt(propertyKey); return DateUtils.addWeeks(new Date(), -weeks); }
static Date getDateFromHours(Settings settings, String propertyKey) { int hours = settings.getInt(propertyKey); return DateUtils.addHours(new Date(), -hours); }
/** * @see Settings#getInteger(String, Integer) */ public int getInt(String key) { int result = -1; // look if this key existed before String previousKey = (String) newToPreviousParamMap.get(key); if (StringUtils.isNotBlank(previousKey) && settings.hasKey(previousKey)) { result = settings.getInt(previousKey); // a former parameter has been specified, let's take this value logInfo(result, previousKey); return result; } // if this key wasn't used before, or if no value for was for it, use the value of the current key return settings.getInt(key); }
public static PurgeConfiguration newDefaultPurgeConfiguration(Settings settings, IdUuidPair idUuidPair, Collection<String> disabledComponentUuids) { String[] scopes = new String[] {Scopes.FILE}; if (settings.getBoolean(PurgeConstants.PROPERTY_CLEAN_DIRECTORY)) { scopes = new String[] {Scopes.DIRECTORY, Scopes.FILE}; } return new PurgeConfiguration(idUuidPair, scopes, settings.getInt(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES), System2.INSTANCE, disabledComponentUuids); }
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; }
rulesetFile, reportFile, settings.getInt(fxCopConf.timeoutPropertyKey()), settings.getBoolean(fxCopConf.aspnetPropertyKey()), splitOnCommas(settings.getString(fxCopConf.directoriesPropertyKey())), splitOnCommas(settings.getString(fxCopConf.referencesPropertyKey()))); } else {