--- /dev/null
+#!/bin/sh
+
+if [[ "$OSTYPE" == "darwin"* ]]; then
+ OS='macosx-universal-64'
+else
+ OS='linux-x86-64'
+fi
+
+if ! ls sonar-application/target/sonarqube-*.zip &> /dev/null; then
+ echo 'Sources are not built'
+ ./build.sh
+fi
+
+cd sonar-application/target/
+if ! ls sonarqube-*/bin/$OS/sonar.sh &> /dev/null; then
+ unzip sonarqube-*.zip
+fi
+cd sonarqube-*
+bin/$OS/sonar.sh restart
+echo "sonar.es.http.port=9200" >> conf/sonar.properties
+sleep 1
+tail -100f logs/sonar.log
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.text.JsonWriter;
import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.qualityprofile.ActiveRule;
import org.sonar.server.rule2.Rule;
import org.sonar.server.rule2.RuleParam;
import org.sonar.server.rule2.RuleService;
-import java.util.Map;
-
/**
* @since 4.4
*/
private void writeRule(Rule rule, JsonWriter json) {
json
- .prop("key", rule.key().toString())
.prop("repo", rule.key().repository())
- .prop("slug", rule.key().rule())
+ .prop("key", rule.key().rule())
.prop("lang", rule.language())
.prop("name", rule.name())
.prop("htmlDesc", rule.htmlDescription())
.endObject();
}
json.endArray();
- json.name("actives").beginArray();
-
- for (ActiveRule activeRule : result.getActiveRules()) {
- json
- .beginObject()
- .prop("key", activeRule.key().toString())
- .prop("inherit", activeRule.inherit())
- .prop("override", activeRule.override())
- .prop("severity", activeRule.severity())
- .prop("parent", activeRule.parent())
- .name("params").beginArray();
- for (Map.Entry<String, String> param : activeRule.params().entrySet()) {
- json.beginObject()
- .prop("key", param.getKey())
- .prop("value", param.getValue())
- .endObject();
- }
- json.endArray();
- }
}
}
--- /dev/null
+{"total": 1, "rules": [
+ {
+ "key": "java:S001",
+ "repo": "java",
+ "slug": "S001",
+ "lang": "js",
+ "name": "Rule S001",
+ "htmlDesc": "Description S001",
+ "status": "READY",
+ "template": false,
+ "internalKey": "InternalKeyS001",
+ "severity": "INFO",
+ "tags": [],
+ "sysTags": [],
+ "params": [
+ {
+ "key": "my_var",
+ "desc": "My small description",
+ "defaultValue": "some value"
+ }
+ ],
+ "actives": [
+ {
+ "key": "My Profile:java:java:S001",
+ "inherit": "none",
+ "override": false,
+ "severity": "BLOCKER",
+ "params": [
+ {
+ "key": "my_var",
+ "value": "The VALUE"
+ }
+ ]
+ }
+ ]
+ }
+]}