import org.sonar.api.ServerExtension;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
-import org.sonar.api.utils.MessageException;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
*/
public NewRule addTags(String... list) {
for (String tag : list) {
- try {
- RuleTagFormat.validate(tag);
- } catch (IllegalArgumentException e) {
- throw MessageException.of(String.format("Tag '%s' is invalid. %s", tag, e.getMessage()));
- }
+ RuleTagFormat.validate(tag);
tags.add(tag);
}
return this;
public static void validate(String tag) {
if (!isValid(tag)) {
- throw new IllegalArgumentException("Rule tags accept only the following characters: a-z, 0-9, '+', '-', '#', '.'");
+ throw new IllegalArgumentException(String.format("Rule tags accept only the following characters: a-z, 0-9, '+', '-', '#', '.' - '%s'", tag));
}
}
}
package org.sonar.api.server.rule;
import org.junit.Test;
-import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
-import org.sonar.api.utils.MessageException;
+import org.sonar.api.rule.RuleStatus;
import java.net.URL;
// whitespaces are not allowed in tags
context.newRepository("findbugs", "java").newRule("NPE").setTags("coding style");
fail();
- } catch (Exception e) {
- assertThat(e).isInstanceOf(MessageException.class)
- .hasMessage("Tag 'coding style' is invalid. Rule tags accept only the following characters: a-z, 0-9, '+', '-', '#', '.'");
+ } catch (IllegalArgumentException e) {
+ assertThat(e).hasMessage("Rule tags accept only the following characters: a-z, 0-9, '+', '-', '#', '.' - 'coding style'");
}
}
RuleTagFormat.validate(" ");
fail();
} catch (IllegalArgumentException e) {
- assertThat(e).hasMessage("Rule tags accept only the following characters: a-z, 0-9, '+', '-', '#', '.'");
+ assertThat(e).hasMessage("Rule tags accept only the following characters: a-z, 0-9, '+', '-', '#', '.' - ' '");
}
}
}
import java.util.Collection;
/**
- * Used through ruby code <pre>Internal.rule_tags</pre>
+ * Used through ruby code <pre>Internal.quality_profiles</pre>
*/
public class RuleTags implements ServerExtension {