aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@sonarsource.com>2015-12-03 18:37:23 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-12-04 10:01:59 +0100
commitfaa74b33eb99d62ad8c6ee760a9367ec62b8dc00 (patch)
tree720512f9d5e4605886f422d1bf2b9bf63e156248 /sonar-plugin-api
parent2a95bdb1fe32d66ebb71f7d5e506c94fb87a0551 (diff)
downloadsonarqube-faa74b33eb99d62ad8c6ee760a9367ec62b8dc00.tar.gz
sonarqube-faa74b33eb99d62ad8c6ee760a9367ec62b8dc00.zip
SONAR-7049 check max length of rule/rule param fields
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java18
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java7
2 files changed, 20 insertions, 5 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
index e9c878c0218..15e96c7189c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
@@ -426,6 +426,9 @@ public interface RulesDefinition {
}
interface NewExtendedRepository {
+ /**
+ * Create a rule with specified key. Max length of key is 200 characters.
+ */
NewRule createRule(String ruleKey);
@CheckForNull
@@ -692,6 +695,10 @@ public interface RulesDefinition {
return this;
}
+ /**
+ * The optional description, in HTML format, has no max length. It's exclusive with markdown description
+ * (see {@link #setMarkdownDescription(String)})
+ */
public NewRule setHtmlDescription(@Nullable String s) {
if (markdownDescription != null) {
throw new IllegalStateException(String.format("Rule '%s' already has a Markdown description", this));
@@ -716,6 +723,10 @@ public interface RulesDefinition {
return this;
}
+ /**
+ * The optional description, in a restricted Markdown format, has no max length. It's exclusive with HTML description
+ * (see {@link #setHtmlDescription(String)})
+ */
public NewRule setMarkdownDescription(@Nullable String s) {
if (htmlDescription != null) {
throw new IllegalStateException(String.format("Rule '%s' already has an HTML description", this));
@@ -792,6 +803,9 @@ public interface RulesDefinition {
return this;
}
+ /**
+ * Create a parameter with given unique key. Max length of key is 128 characters.
+ */
public NewParam createParam(String paramKey) {
if (paramsByKey.containsKey(paramKey)) {
throw new IllegalArgumentException(String.format("The parameter '%s' is declared several times on the rule %s", paramKey, this));
@@ -1020,7 +1034,7 @@ public interface RulesDefinition {
}
/**
- * Plain-text description. Can be null.
+ * Plain-text description. Can be null. Max length is 4000 characters.
*/
public NewParam setDescription(@Nullable String s) {
this.description = StringUtils.defaultIfBlank(s, null);
@@ -1028,7 +1042,7 @@ public interface RulesDefinition {
}
/**
- * Empty default value will be converted to null.
+ * Empty default value will be converted to null. Max length is 4000 characters.
*/
public NewParam setDefaultValue(@Nullable String s) {
this.defaultValue = Strings.emptyToNull(s);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
index 8a8096e4ebf..f088221b883 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
@@ -74,10 +74,10 @@ import static org.apache.commons.lang.StringUtils.trim;
* <pre>
* &lt;rules&gt;
* &lt;rule&gt;
- * &lt;!-- required key --&gt;
+ * &lt;!-- required key. Max length is 200. --&gt;
* &lt;key&gt;the-rule-key&lt;/key&gt;
*
- * &lt;!-- required name --&gt;
+ * &lt;!-- required name. Max length is 200. --&gt;
* &lt;name&gt;The purpose of the rule&lt;/name&gt;
*
* &lt;!-- required description, in HTML format --&gt;
@@ -98,11 +98,12 @@ import static org.apache.commons.lang.StringUtils.trim;
* &lt;!-- Status displayed in rules console. Possible values are BETA, READY (default), DEPRECATED. --&gt;
* &lt;status&gt;BETA&lt;/status&gt;
*
- * &lt;!-- Optional tags. See org.sonar.api.server.rule.RuleTagFormat. --&gt;
+ * &lt;!-- Optional tags. See org.sonar.api.server.rule.RuleTagFormat. The maximal length of all tags is 4000. --&gt;
* &lt;tag&gt;style&lt;/tag&gt;
* &lt;tag&gt;security&lt;/tag&gt;
*
* &lt;param&gt;
+ * &lt;!-- Status displayed in rules console. Possible values are BETA, READY (default), DEPRECATED. --&gt;
* &lt;key&gt;the-param-key&lt;/key&gt;
* &lt;description&gt;
* &lt;![CDATA[the optional description, in HTML format]]&gt;