Codota Logo
RuleTagFormat.validate
Code IndexAdd Codota to your IDE (free)

How to use
validate
method
in
org.sonar.api.server.rule.RuleTagFormat

Best Java code snippets using org.sonar.api.server.rule.RuleTagFormat.validate (Showing top 13 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ArrayList a =
  • Codota Iconnew ArrayList<String>()
  • Codota Iconnew ArrayList()
  • Codota Iconnew ArrayList<Object>()
  • Smart code suggestions by Codota
}
origin: SonarSource/sonarqube

/**
 * @see RuleTagFormat
 */
public NewRule addTags(String... list) {
 for (String tag : list) {
  RuleTagFormat.validate(tag);
  tags.add(tag);
 }
 return this;
}
origin: SonarSource/sonarqube

 private Set<String> parseTags(Map<String, Object> properties) {
  Set<String> result = new HashSet<>();
  String tagsString = (String) properties.get(TAGS_PARAMETER);
  if (!Strings.isNullOrEmpty(tagsString)) {
   for (String tag : TAGS_SPLITTER.split(tagsString)) {
    RuleTagFormat.validate(tag);
    result.add(tag);
   }
  }
  return result;
 }
}
origin: SonarSource/sonarqube

 /**
  * Validates tags and resolves conflicts between user and system tags.
  */
 static boolean applyTags(RuleDto rule, Set<String> tags) {
  for (String tag : tags) {
   RuleTagFormat.validate(tag);
  }

  Set<String> initialTags = rule.getTags();
  final Set<String> systemTags = rule.getSystemTags();
  Set<String> withoutSystemTags = Sets.filter(tags, input -> input != null && !systemTags.contains(input));
  rule.setTags(withoutSystemTags);
  return withoutSystemTags.size() != initialTags.size() || !withoutSystemTags.containsAll(initialTags);
 }
}
origin: SonarSource/sonarqube

public boolean setTags(DefaultIssue issue, Collection<String> tags, IssueChangeContext context) {
 Set<String> newTags = RuleTagFormat.validate(tags);
 Set<String> oldTags = new HashSet<>(issue.tags());
 if (!oldTags.equals(newTags)) {
  issue.setFieldChange(context, TAGS,
   oldTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(oldTags),
   newTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(newTags));
  issue.setTags(newTags);
  issue.setUpdateDate(context.date());
  issue.setChanged(true);
  issue.setSendNotifications(true);
  return true;
 }
 return false;
}
origin: SonarSource/sonarqube

@Test
public void validate() {
 RuleTagFormat.validate("style");
 // no error
}
origin: SonarSource/sonarqube

@Test
public void validate_and_sanitize_collection_of_tags() {
 assertThat(RuleTagFormat.validate(asList("style", "coding-style", ""))).containsExactly("coding-style", "style");
 assertThat(RuleTagFormat.validate(asList("style", "coding-style", null))).containsExactly("coding-style", "style");
 assertThat(RuleTagFormat.validate(asList("style", "style", null))).containsExactly("style");
 assertThat(RuleTagFormat.validate(singletonList("Uppercase"))).containsExactly("uppercase");
 assertThat(RuleTagFormat.validate(Collections.emptyList())).isEmpty();
}
origin: SonarSource/sonarqube

 @Test
 public void fail_to_validate_collection_of_tags() {
  try {
   RuleTagFormat.validate(asList("coding style", "Stylé", "valid"));
   fail();
  } catch (IllegalArgumentException e) {
   assertThat(e).hasMessage("Tags 'coding style, stylé' are invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
  }
 }
}
origin: SonarSource/sonarqube

@Test
public void validate_and_fail() {
 try {
  RuleTagFormat.validate("  ");
  fail();
 } catch (IllegalArgumentException e) {
  assertThat(e).hasMessage("Tag '  ' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
 }
}
origin: org.codehaus.sonar/sonar-plugin-api

/**
 * @see RuleTagFormat
 */
public NewRule addTags(String... list) {
 for (String tag : list) {
  RuleTagFormat.validate(tag);
  tags.add(tag);
 }
 return this;
}
origin: org.sonarsource.sonarqube/sonar-plugin-api

/**
 * @see RuleTagFormat
 */
public NewRule addTags(String... list) {
 for (String tag : list) {
  RuleTagFormat.validate(tag);
  tags.add(tag);
 }
 return this;
}
origin: org.sonarsource.sonarqube/sonar-server

 private Set<String> parseTags(Map<String, Object> properties) {
  Set<String> result = new HashSet<>();
  String tagsString = (String) properties.get(TAGS_PARAMETER);
  if (!Strings.isNullOrEmpty(tagsString)) {
   for (String tag : TAGS_SPLITTER.split(tagsString)) {
    RuleTagFormat.validate(tag);
    result.add(tag);
   }
  }
  return result;
 }
}
origin: org.sonarsource.sonarqube/sonar-server

 /**
  * Validates tags and resolves conflicts between user and system tags.
  */
 static boolean applyTags(RuleDto rule, Set<String> tags) {
  for (String tag : tags) {
   RuleTagFormat.validate(tag);
  }

  Set<String> initialTags = rule.getTags();
  final Set<String> systemTags = rule.getSystemTags();
  Set<String> withoutSystemTags = Sets.filter(tags, input -> input != null && !systemTags.contains(input));
  rule.setTags(withoutSystemTags);
  return withoutSystemTags.size() != initialTags.size() || !withoutSystemTags.containsAll(initialTags);
 }
}
origin: org.sonarsource.sonarqube/sonar-server

public boolean setTags(DefaultIssue issue, Collection<String> tags, IssueChangeContext context) {
 Set<String> newTags = tags.stream()
  .filter(Objects::nonNull)
  .filter(tag -> !tag.isEmpty())
  .map(tag -> RuleTagFormat.validate(tag.toLowerCase(Locale.ENGLISH)))
  .collect(MoreCollectors.toSet());
 Set<String> oldTags = new HashSet<>(issue.tags());
 if (!oldTags.equals(newTags)) {
  issue.setFieldChange(context, TAGS,
   oldTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(oldTags),
   newTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(newTags));
  issue.setTags(newTags);
  issue.setUpdateDate(context.date());
  issue.setChanged(true);
  issue.setSendNotifications(true);
  return true;
 }
 return false;
}
org.sonar.api.server.ruleRuleTagFormatvalidate

Popular methods of RuleTagFormat

  • isValid

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • putExtra (Intent)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • JPanel (javax.swing)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now