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

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

Best Java code snippets using org.sonar.api.server.rule.RuleTagFormat (Showing top 19 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

public static String validate(String tag) {
 if (!isValid(tag)) {
  throw new IllegalArgumentException(format("Tag '%s' is invalid. %s", tag, ERROR_MESSAGE_SUFFIX));
 }
 return tag;
}
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

public static Set<String> validate(Collection<String> tags) {
 Set<String> sanitizedTags = tags.stream()
  .filter(Objects::nonNull)
  .filter(tag -> !tag.isEmpty())
  .map(tag -> tag.toLowerCase(ENGLISH))
  .collect(toSet());
 Set<String> invalidTags = sanitizedTags.stream()
  .filter(tag -> !isValid(tag))
  .collect(toSet());
 if (invalidTags.isEmpty()) {
  return sanitizedTags;
 }
 throw new IllegalArgumentException(format("Tags '%s' are invalid. %s", join(", ", invalidTags), ERROR_MESSAGE_SUFFIX));
}
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

@Test
public void isValid() {
 assertThat(RuleTagFormat.isValid(null)).isFalse();
 assertThat(RuleTagFormat.isValid("")).isFalse();
 assertThat(RuleTagFormat.isValid(" ")).isFalse();
 assertThat(RuleTagFormat.isValid("coding style")).isFalse();
 assertThat(RuleTagFormat.isValid("Style")).isFalse();
 assertThat(RuleTagFormat.isValid("sTyle")).isFalse();
 assertThat(RuleTagFormat.isValid("@style")).isFalse();
 assertThat(RuleTagFormat.isValid("style")).isTrue();
 assertThat(RuleTagFormat.isValid("c++")).isTrue();
 assertThat(RuleTagFormat.isValid("f#")).isTrue();
 assertThat(RuleTagFormat.isValid("c++11")).isTrue();
 assertThat(RuleTagFormat.isValid("c.d")).isTrue();
}
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: org.codehaus.sonar/sonar-plugin-api

 public static void validate(String tag) {
  if (!isValid(tag)) {
   throw new IllegalArgumentException(String.format("Tag '%s' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'", tag));
  }
 }
}
origin: SonarSource/sonarqube

@Test
public void validate() {
 RuleTagFormat.validate("style");
 // no error
}
origin: org.sonarsource.sonarqube/sonar-plugin-api

public static String validate(String tag) {
 if (!isValid(tag)) {
  throw new IllegalArgumentException(format("Tag '%s' is invalid. %s", tag, ERROR_MESSAGE_SUFFIX));
 }
 return tag;
}
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: org.sonarsource.sonarqube/sonar-plugin-api

public static Set<String> validate(Collection<String> tags) {
 Set<String> sanitizedTags = tags.stream()
  .filter(Objects::nonNull)
  .filter(tag -> !tag.isEmpty())
  .map(tag -> tag.toLowerCase(ENGLISH))
  .collect(toSet());
 Set<String> invalidTags = sanitizedTags.stream()
  .filter(tag -> !isValid(tag))
  .collect(toSet());
 if (invalidTags.isEmpty()) {
  return sanitizedTags;
 }
 throw new IllegalArgumentException(format("Tags '%s' are invalid. %s", join(", ", invalidTags), ERROR_MESSAGE_SUFFIX));
}
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.ruleRuleTagFormat

Javadoc

The characters allowed in rule tags are the same as those on StackOverflow, basically lower-case letters, digits, plus (+), sharp (#), dash (-) and dot (.) See http://meta.stackoverflow.com/questions/22624/what-symbols-characters-are-not-allowed-in-tags

Most used methods

  • validate
  • isValid

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • onRequestPermissionsResult (Fragment)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • PriorityQueue (java.util)
    An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
  • BoxLayout (javax.swing)
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
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