aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountOpenIssuesDecoratorTest.java17
-rw-r--r--sonar-server/src/main/java/org/sonar/server/text/RubyTextService.java6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb32
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java10
4 files changed, 30 insertions, 35 deletions
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountOpenIssuesDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountOpenIssuesDecoratorTest.java
index 7202fb5cc50..4d388e2ac8a 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountOpenIssuesDecoratorTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountOpenIssuesDecoratorTest.java
@@ -144,8 +144,8 @@ public class CountOpenIssuesDecoratorTest {
when(resource.getScope()).thenReturn(Scopes.PROJECT);
when(issuable.issues()).thenReturn(createIssues());
when(context.getChildrenMeasures(any(MeasuresFilter.class))).thenReturn(Collections.<Measure>emptyList());
- when(context.getMeasure(CoreMetrics.VIOLATIONS)).thenReturn(new Measure(CoreMetrics.ISSUES, 3000.0));
- when(context.getMeasure(CoreMetrics.MAJOR_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.MAJOR_ISSUES, 500.0));
+ when(context.getMeasure(CoreMetrics.VIOLATIONS)).thenReturn(new Measure(CoreMetrics.VIOLATIONS, 3000.0));
+ when(context.getMeasure(CoreMetrics.MAJOR_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.MAJOR_VIOLATIONS, 500.0));
decorator.decorate(resource, context);
@@ -207,19 +207,6 @@ public class CountOpenIssuesDecoratorTest {
}
@Test
- public void should_save_unassigned_issues() {
- List<Issue> issues = newArrayList();
- issues.add(new DefaultIssue().setRuleKey(ruleA1.ruleKey()).setStatus(Issue.STATUS_OPEN).setSeverity(RulePriority.CRITICAL.name()));
- issues.add(new DefaultIssue().setRuleKey(ruleA1.ruleKey()).setStatus(Issue.STATUS_REOPENED).setSeverity(RulePriority.CRITICAL.name()));
- issues.add(new DefaultIssue().setRuleKey(ruleA2.ruleKey()).setStatus(Issue.STATUS_OPEN).setAssignee("arthur").setSeverity(RulePriority.CRITICAL.name()));
- when(issuable.issues()).thenReturn(issues);
-
- decorator.decorate(resource, context);
-
- verify(context).saveMeasure(CoreMetrics.UNASSIGNED_ISSUES, 2.0);
- }
-
- @Test
public void same_rule_should_have_different_severities() {
List<Issue> issues = newArrayList();
issues.add(new DefaultIssue().setRuleKey(ruleA1.ruleKey()).setSeverity(RulePriority.CRITICAL.name()));
diff --git a/sonar-server/src/main/java/org/sonar/server/text/RubyTextService.java b/sonar-server/src/main/java/org/sonar/server/text/RubyTextService.java
index e7f8da8fe66..135a28731ad 100644
--- a/sonar-server/src/main/java/org/sonar/server/text/RubyTextService.java
+++ b/sonar-server/src/main/java/org/sonar/server/text/RubyTextService.java
@@ -26,6 +26,9 @@ import org.sonar.markdown.Markdown;
import java.util.List;
+/**
+ * @since 3.6
+ */
public class RubyTextService implements ServerComponent {
private final MacroInterpreter macroInterpreter;
@@ -36,15 +39,18 @@ public class RubyTextService implements ServerComponent {
this.sourceDecorator = sourceDecorator;
}
+ // TODO add ruby example
public String interpretMacros(String text) {
return macroInterpreter.interpret(text);
}
+ // TODO add ruby example
public String markdownToHtml(String markdown) {
// TODO move HTML escaping to sonar-markdown
return Markdown.convertToHtml(StringEscapeUtils.escapeHtml(markdown));
}
+ // TODO add ruby example
public List<String> highlightedSourceLines(long snapshotId) {
return sourceDecorator.getDecoratedSourceAsHtml(snapshotId);
}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb
index fcde2452670..aeadcfd963e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb
@@ -33,29 +33,31 @@ class Api::ViolationsController < Api::ApiController
resource = params[:resource]
depth=(params['depth'] ? params['depth'].to_i : 0)
- if depth==0
- conditions[:components] = resource
- elsif depth>0
- rest_error('The parameter "depth" is not supported since version 3.6.')
- else
- # negative : all the resource tree
- conditions[:componentRoots] = resource
+ if resource
+ if depth==0
+ conditions['components'] = resource
+ elsif depth>0
+ rest_error('The parameter "depth" is not supported since version 3.6.')
+ else
+ # negative : all the resource tree
+ conditions['componentRoots'] = resource
+ end
end
-
+
if params[:rules]
- conditions[:rules] = params[:rules].split(',')
+ conditions['rules'] = params[:rules].split(',')
end
if params[:priorities]
- conditions[:severities] = params[:priorities].split(',')
+ conditions['severities'] = params[:priorities].split(',')
end
-
+
if params[:switched_off] == 'true'
- conditions[:resolutions]='FALSE-POSITIVE'
+ conditions['resolutions']='FALSE-POSITIVE'
end
- limit = (params[:limit] ? [params[:limit].to_i,5000].min : 5000)
- conditions[:pageSize]=limit
+ limit = (params[:limit] ? [params[:limit].to_i, 5000].min : 5000)
+ conditions['pageSize']=limit
results = Api.issues.find(conditions)
@@ -68,7 +70,7 @@ class Api::ViolationsController < Api::ApiController
hash[:switchedOff]=true if issue.resolution=='FALSE-POSITIVE'
rule = results.rule(issue)
if rule
- hash[:rule] = {:key => rule.ruleKey, :name => Internal.rules.ruleL10nName(rule)}
+ hash[:rule] = {:key => rule.ruleKey.toString(), :name => Internal.rules.ruleL10nName(rule)}
end
resource = results.component(issue)
if resource
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java
index 38a9fb71a5b..c9f20f9ec9d 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java
@@ -27,15 +27,15 @@ public class ViolationQuery extends Query<Violation> {
public static final String BASE_URL = "/api/violations";
- private String resourceKeyOrId;
+ private String resourceKey;
private int depth = 0;
private String[] qualifiers;
private String[] ruleKeys;
private String[] severities;
private Integer limit;
- public ViolationQuery(String resourceKeyOrId) {
- this.resourceKeyOrId = resourceKeyOrId;
+ public ViolationQuery(String resourceKey) {
+ this.resourceKey = resourceKey;
}
public String[] getQualifiers() {
@@ -116,7 +116,7 @@ public class ViolationQuery extends Query<Violation> {
public String getUrl() {
StringBuilder url = new StringBuilder(BASE_URL);
url.append('?');
- appendUrlParameter(url, "resource", resourceKeyOrId);
+ appendUrlParameter(url, "resource", resourceKey);
if (depth != 0) {
url.append("depth=").append(depth).append("&");
}
@@ -124,7 +124,7 @@ public class ViolationQuery extends Query<Violation> {
appendUrlParameter(url, "qualifiers", qualifiers);
appendUrlParameter(url, "rules", ruleKeys);
appendUrlParameter(url, "priorities", severities);
- return url.toString();
+ return url.toString();
}
@Override