本文整理了Java中org.sonar.api.config.Configuration.getBoolean()
方法的一些代码示例,展示了Configuration.getBoolean()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getBoolean()
方法的具体详情如下:
包路径:org.sonar.api.config.Configuration
类名称:Configuration
方法名:getBoolean
[英]Effective value as boolean. It is empty if #get(String) is empty or if it does not return "true", even if it's not a boolean representation.
[中]有效值为布尔值。如果#get(String)为空,或者如果它不返回“true”,即使它不是布尔表示,它也是空的。
代码示例来源:origin: SonarSource/sonarqube
public boolean isCrossProjectDuplicationEnabled() {
return settings.getBoolean(CoreProperties.CPD_CROSS_PROJECT).orElse(false)
// No cross project duplication for branches
&& StringUtils.isBlank(branch);
}
代码示例来源:origin: SonarSource/sonarqube
public ValuesAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession, PropertyDefinitions propertyDefinitions,
SettingsWsSupport settingsWsSupport, Configuration configuration) {
this.dbClient = dbClient;
this.componentFinder = componentFinder;
this.userSession = userSession;
this.propertyDefinitions = propertyDefinitions;
this.settingsWsSupport = settingsWsSupport;
this.isSonarCloud = configuration.getBoolean(SONARCLOUD_ENABLED.getKey()).orElse(false);
}
代码示例来源:origin: SonarSource/sonarqube
public IntegrateCrossProjectDuplications(Configuration config, DuplicationRepository duplicationRepository) {
this.config = config;
this.duplicationRepository = duplicationRepository;
if (config.getBoolean(CoreProperties.CPD_CROSS_PROJECT).orElse(false)) {
LOGGER.warn("This analysis uses the deprecated cross-project duplication feature.");
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
protected void execute(Context context) throws SQLException {
if (configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false)) {
executeOnSonarCloud(context);
} else {
executeOnSonarQube(context);
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public boolean accept(FilterableIssue issue, IssueFilterChain chain) {
if (config.getBoolean("sonar.xoo.excludeAllIssuesOnOddLines").orElse(false) && isOdd(issue)) {
return false;
}
return chain.accept(issue);
}
代码示例来源:origin: SonarSource/sonarqube
public WebServerImpl(Configuration config) {
this.clusterEnabled = config.getBoolean(CLUSTER_ENABLED.getKey()).orElse(false);
if (this.clusterEnabled) {
this.startupLeader = config.getBoolean(CLUSTER_WEB_STARTUP_LEADER.getKey()).orElse(false);
Loggers.get(WebServerImpl.class).info("Cluster enabled (startup {})", startupLeader ? "leader" : "follower");
} else {
this.startupLeader = true;
}
}
代码示例来源:origin: SonarSource/sonarqube
private String provide(String path) {
getClass().getResourceAsStream(INDEX_HTML_PATH);
boolean isSonarCloud = configuration.getBoolean(SONARCLOUD_ENABLED.getKey()).orElse(false);
String instance = isSonarCloud ? SONARCLOUD_INSTANCE_VALUE : SONARQUBE_INSTANCE_VALUE;
return loadHtmlFile(path, status.name(), instance);
}
代码示例来源:origin: SonarSource/sonarqube
private Credentials fixCase(Credentials credentials) {
if (config.getBoolean("sonar.authenticator.downcase").orElse(false)) {
return new Credentials(credentials.getLogin().toLowerCase(Locale.ENGLISH), credentials.getPassword().orElse(null));
}
return credentials;
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void describe(SensorDescriptor descriptor) {
descriptor
.name(NAME)
.onlyOnLanguages(Xoo.KEY)
.onlyWhenConfiguration(c -> c.getBoolean(ACTIVATE).orElse(false));
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void describe(SensorDescriptor descriptor) {
descriptor
.name(NAME)
.onlyOnLanguages(Xoo.KEY)
.onlyWhenConfiguration(c -> c.getBoolean(ACTIVATE).orElse(false));
}
代码示例来源:origin: SonarSource/sonarqube
@Override
protected void execute(Context context) throws SQLException {
if (!configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false)) {
return;
}
long now = system2.now();
insertMissingOrgQProfiles(context, now);
insertMissingDefaultQProfiles(context, now);
}
代码示例来源:origin: SonarSource/sonarqube
private void logProfiling(long start, Configuration config) {
if (config.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY).orElse(false)) {
long duration = System.currentTimeMillis() - start;
LOG.info("\n -------- Profiling for purge: " + TimeUtils.formatDuration(duration) + " --------\n");
profiler.dump(duration, LOG);
LOG.info("\n -------- End of profiling for purge --------\n");
}
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void start() {
this.systemSettingValuesByKey.put(SONAR_UPDATECENTER_ACTIVATE.getKey(), config.get(SONAR_UPDATECENTER_ACTIVATE.getKey()).orElse(null));
boolean isOnSonarCloud = config.getBoolean(SONARCLOUD_ENABLED.getKey()).orElse(false);
if (isOnSonarCloud) {
this.systemSettingValuesByKey.put(SONAR_PRISMIC_ACCESS_TOKEN.getKey(), config.get(SONAR_PRISMIC_ACCESS_TOKEN.getKey()).orElse(null));
this.systemSettingValuesByKey.put(SONAR_ANALYTICS_TRACKING_ID.getKey(), config.get(SONAR_ANALYTICS_TRACKING_ID.getKey()).orElse(null));
}
}
代码示例来源:origin: SonarSource/sonarqube
public SvgGenerator(Configuration config) {
boolean isOnSonarCloud = config.getBoolean(SONARCLOUD_ENABLED.getKey()).orElse(false);
String templatePath = isOnSonarCloud ? TEMPLATES_SONARCLOUD : TEMPLATES_SONARQUBE;
this.errorTemplate = readTemplate("templates/error.svg");
this.badgeTemplate = readTemplate(templatePath + "/badge.svg");
this.qualityGateTemplates = ImmutableMap.of(
OK, readTemplate(templatePath + "/quality_gate_passed.svg"),
WARN, readTemplate(templatePath + "/quality_gate_warn.svg"),
ERROR, readTemplate(templatePath + "/quality_gate_failed.svg"));
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void start() {
if (config.getBoolean(SONAR_WEB_SSO_ENABLE.getKey()).orElse(false)) {
LOG.info("HTTP headers authentication enabled");
enabled = true;
PROPERTIES.forEach(entry -> settingsByKey.put(entry.getKey(), config.get(entry.getKey()).orElse(entry.getDefaultValue())));
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
@UseDataProvider("scmDisabledProperty")
public void exclusion_is_disabled_by_property(boolean scmDisabled, boolean scmExclusionsDisabled, boolean isScmExclusionDisabled) {
when(settings.getBoolean(CoreProperties.SCM_DISABLED_KEY)).thenReturn(Optional.of(scmDisabled));
when(settings.getBoolean(CoreProperties.SCM_EXCLUSIONS_DISABLED_KEY)).thenReturn(Optional.of(scmExclusionsDisabled));
underTest.start();
assertThat(underTest.isExclusionDisabled()).isEqualTo(isScmExclusionDisabled);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void return_early_from_start_in_issues_mode() {
// return early = doesn't reach the logging when disabled
when(settings.getBoolean(CoreProperties.SCM_DISABLED_KEY)).thenReturn(Optional.of(true));
when(analysisMode.isIssues()).thenReturn(true);
underTest.start();
assertThat(logTester.logs()).isEmpty();
}
代码示例来源:origin: SonarSource/sonarqube
private void loadUserSession(HttpServletRequest request, HttpServletResponse response, boolean urlSupportsSystemPasscode) {
UserSession session = requestAuthenticator.authenticate(request, response);
if (!session.isLoggedIn() && !urlSupportsSystemPasscode && config.getBoolean(CORE_FORCE_AUTHENTICATION_PROPERTY).orElse(false)) {
// authentication is required
throw AuthenticationException.newBuilder()
.setSource(Source.local(AuthenticationEvent.Method.BASIC))
.setMessage("User must be authenticated")
.build();
}
threadLocalSession.set(session);
request.setAttribute(ACCESS_LOG_LOGIN, defaultString(session.getLogin(), "-"));
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void log_when_disabled() {
when(settings.getBoolean(CoreProperties.SCM_DISABLED_KEY)).thenReturn(Optional.of(true));
underTest.start();
assertThat(logTester.logs()).contains(MESSAGE_SCM_STEP_IS_DISABLED_BY_CONFIGURATION);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void log_when_exclusion_is_disabled() {
when(settings.getBoolean(CoreProperties.SCM_EXCLUSIONS_DISABLED_KEY)).thenReturn(Optional.of(true));
underTest.start();
assertThat(logTester.logs()).contains(MESSAGE_SCM_EXLUSIONS_IS_DISABLED_BY_CONFIGURATION);
}
内容来源于网络,如有侵权,请联系作者删除!