org.sonar.api.config.Settings.hasKey()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.sonar.api.config.Settings.hasKey()方法的一些代码示例,展示了Settings.hasKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.hasKey()方法的具体详情如下:
包路径:org.sonar.api.config.Settings
类名称:Settings
方法名:hasKey

Settings.hasKey介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Override
public boolean hasKey(String key) {
 return settings.hasKey(key);
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public boolean hasKey(String key) {
 return settings.hasKey(key);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
@UseDataProvider("setPropertyCalls")
public void all_set_property_methods_trims_key(BiConsumer<Settings, String> setPropertyCaller) {
 Settings underTest = new MapSettings();
 Random random = new Random();
 String blankBefore = blank(random);
 String blankAfter = blank(random);
 String key = randomAlphanumeric(3);
 setPropertyCaller.accept(underTest, blankBefore + key + blankAfter);
 assertThat(underTest.hasKey(key)).isTrue();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void set_property_string_array_trims_key() {
 String key = randomAlphanumeric(3);
 Settings underTest = new MapSettings(new PropertyDefinitions(singletonList(PropertyDefinition.builder(key).multiValues(true).build())));
 Random random = new Random();
 String blankBefore = blank(random);
 String blankAfter = blank(random);
 underTest.setProperty(blankBefore + key + blankAfter, new String[] {"1", "2"});
 assertThat(underTest.hasKey(key)).isTrue();
}

代码示例来源:origin: stackoverflow.com

public class YourRulesDefinition implements RulesDefinition {
 private final Settings settings;

 public YourRulesDefinition(Settings s) {
  this.settings = s;
 }

 void yourMethod() {
  if(settings.hasKey("sonar.root.path")) {
   // ...
  }
 }
}

代码示例来源:origin: org.codehaus.sonar.dotnet.fxcop/sonar-fxcop-library

private void checkTimeoutProeprty(Settings settings) {
 if (!settings.hasKey(timeoutPropertyKey) && settings.hasKey(DEPRECATED_TIMEOUT_MINUTES_PROPERTY_KEY)) {
  timeoutPropertyKey = DEPRECATED_TIMEOUT_MINUTES_PROPERTY_KEY;
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api

@Override
public boolean hasKey(String key) {
 return settings.hasKey(key);
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

@Override
public boolean hasKey(String key) {
 return settings.hasKey(key);
}

代码示例来源:origin: org.codehaus.sonar.dotnet.fxcop/sonar-fxcop-library

private void checkMandatoryProperties(Settings settings) {
 if (!settings.hasKey(assemblyPropertyKey)) {
  throw new IllegalArgumentException("The property \"" + assemblyPropertyKey + "\" must be set and the project must have been built to execute FxCop rules. "
   + "This property can be automatically set by the Analysis Bootstrapper for Visual Studio Projects plugin, see: http://docs.codehaus.org/x/TAA1Dg."
   + "If you wish to skip the analysis of not built projects, set the property \"sonar.visualstudio.skipIfNotBuilt\".");
 }
}

代码示例来源:origin: org.codehaus.sonar.dotnet.fxcop/sonar-fxcop-library

private void checkFxCopCmdPathProperty(Settings settings) {
 if (!settings.hasKey(fxCopCmdPropertyKey) && settings.hasKey(DEPRECATED_FXCOPCMD_PATH_PROPERTY_KEY)) {
  fxCopCmdPropertyKey = DEPRECATED_FXCOPCMD_PATH_PROPERTY_KEY;
 }
 String value = settings.getString(fxCopCmdPropertyKey);
 File file = new File(value);
 Preconditions.checkArgument(
  file.isFile(),
  "Cannot find the FxCopCmd executable \"" + file.getAbsolutePath() + "\" provided by the property \"" + fxCopCmdPropertyKey + "\".");
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

private void considerOldScmUrl() {
 if (settings.hasKey(CoreProperties.LINKS_SOURCES_DEV)) {
  String url = settings.getString(CoreProperties.LINKS_SOURCES_DEV);
  if (url.startsWith("scm:")) {
   String[] split = url.split(":");
   if (split.length > 1) {
    setProviderIfSupported(split[1]);
   }
  }
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

private void considerOldScmUrl() {
 if (settings.hasKey(CoreProperties.LINKS_SOURCES_DEV)) {
  String url = settings.getString(CoreProperties.LINKS_SOURCES_DEV);
  if (url.startsWith("scm:")) {
   String[] split = url.split(":");
   if (split.length > 1) {
    setProviderIfSupported(split[1]);
   }
  }
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

@VisibleForTesting
boolean isSkipped(String language) {
 String key = "sonar.cpd." + language + ".skip";
 if (settings.hasKey(key)) {
  return settings.getBoolean(key);
 }
 return settings.getBoolean(CoreProperties.CPD_SKIP_PROPERTY);
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

@VisibleForTesting
boolean isSkipped(String language) {
 String key = "sonar.cpd." + language + ".skip";
 if (settings.hasKey(key)) {
  return settings.getBoolean(key);
 }
 return settings.getBoolean(CoreProperties.CPD_SKIP_PROPERTY);
}

代码示例来源:origin: SonarSource/sonar-github

public MarkDownUtils(Settings settings) {
 // If server base URL was not configured in SQ server then is is better to take URL configured on batch side
 String baseUrl = settings.hasKey(CoreProperties.SERVER_BASE_URL) ? settings.getString(CoreProperties.SERVER_BASE_URL) : settings.getString("sonar.host.url");
 if (!baseUrl.endsWith("/")) {
  baseUrl += "/";
 }
 this.ruleUrlPrefix = baseUrl;
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

private boolean settingsCondition(DefaultSensorDescriptor descriptor) {
 if (!descriptor.properties().isEmpty()) {
  for (String propertyKey : descriptor.properties()) {
   if (!settings.hasKey(propertyKey)) {
    return false;
   }
  }
 }
 return true;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

private boolean settingsCondition(DefaultPostJobDescriptor descriptor) {
 if (!descriptor.properties().isEmpty()) {
  for (String propertyKey : descriptor.properties()) {
   if (!settings.hasKey(propertyKey)) {
    return false;
   }
  }
 }
 return true;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

private boolean settingsCondition(DefaultSensorDescriptor descriptor) {
 if (!descriptor.properties().isEmpty()) {
  for (String propertyKey : descriptor.properties()) {
   if (!settings.hasKey(propertyKey)) {
    return false;
   }
  }
 }
 return true;
}

代码示例来源:origin: SonarSource/sonar-github

public String repository() {
 if (settings.hasKey(GitHubPlugin.GITHUB_REPO)) {
  return repoFromProp();
 }
 if (isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES_DEV)) || isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES))) {
  return repoFromScmProps();
 }
 throw MessageException.of("Unable to determine GitHub repository name for this project. Please provide it using property '" + GitHubPlugin.GITHUB_REPO
  + "' or configure property '" + CoreProperties.LINKS_SOURCES + "'.");
}

代码示例来源:origin: org.codehaus.sonar.dotnet.fxcop/sonar-fxcop-library

public void checkProperties(Settings settings) {
 if (settings.hasKey(reportPathPropertyKey)) {
  checkReportPathProperty(settings);
 } else {
  checkMandatoryProperties(settings);
  checkAssemblyProperty(settings);
  checkFxCopCmdPathProperty(settings);
  checkTimeoutProeprty(settings);
 }
}

相关文章