aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-06-17 11:58:30 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-06-17 11:58:38 +0200
commit610cca8350f54ce80f7925579c6ee672784c52cc (patch)
treed5b34a0342549b1899f8e262bd768c9b7cab7a32 /sonar-server
parente09f42884478ab1a1da0d79bde3c466200101e3b (diff)
downloadsonarqube-610cca8350f54ce80f7925579c6ee672784c52cc.tar.gz
sonarqube-610cca8350f54ce80f7925579c6ee672784c52cc.zip
SONAR-4514 Settings -> Manual Rules page now uses Java service for searching manual rules
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java17
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/manual_rules/index.html.erb14
3 files changed, 22 insertions, 11 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java b/sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java
index 833a149fd0e..35e770447f0 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java
@@ -20,7 +20,6 @@
package org.sonar.server.rule;
import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
import org.picocontainer.Startable;
import org.sonar.api.ServerComponent;
import org.sonar.api.rule.RuleKey;
@@ -29,6 +28,7 @@ import org.sonar.api.server.debt.DebtRemediationFunction;
import org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction;
import org.sonar.server.paging.PagedResult;
import org.sonar.server.paging.PagingResult;
+import org.sonar.server.rule.index.RuleDoc;
import org.sonar.server.rule.index.RuleNormalizer;
import org.sonar.server.rule.index.RuleQuery;
import org.sonar.server.search.QueryOptions;
@@ -36,9 +36,12 @@ import org.sonar.server.user.UserSession;
import org.sonar.server.util.RubyUtils;
import javax.annotation.CheckForNull;
+
import java.util.List;
import java.util.Map;
+import static com.google.common.collect.Lists.newArrayList;
+
/**
* Used through ruby code <pre>Internal.rules</pre>
*
@@ -59,7 +62,7 @@ public class RubyRuleService implements ServerComponent, Startable {
* Used in issues_controller.rb and in manual_rules_controller.rb
*/
@CheckForNull
- public org.sonar.server.rule.Rule findByKey(String ruleKey) {
+ public Rule findByKey(String ruleKey) {
return service.getByKey(RuleKey.parse(ruleKey));
}
@@ -80,10 +83,18 @@ public class RubyRuleService implements ServerComponent, Startable {
query.setSortField(RuleNormalizer.RuleField.NAME);
QueryOptions options = new QueryOptions().setScroll(true);
- List<Rule> rules = Lists.newArrayList(service.search(query, options).scroll());
+ List<Rule> rules = newArrayList(service.search(query, options).scroll());
return new PagedResult<org.sonar.server.rule.Rule>(rules, PagingResult.create(Integer.MAX_VALUE, 1, rules.size()));
}
+ /**
+ * Used in manual_rules_controller.rb
+ */
+ public List<Rule> searchManualRules() {
+ return service.search(new RuleQuery().setRepositories(newArrayList(RuleDoc.MANUAL_REPOSITORY)).setSortField(RuleNormalizer.RuleField.NAME), new QueryOptions()).getHits();
+ }
+
+
// sqale
public void updateRule(Map<String, Object> params) {
RuleUpdate update = RuleUpdate.createForPluginRule(RuleKey.parse((String) params.get("ruleKey")));
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb
index e71fcfafaf7..ec3e9f02d50 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb
@@ -24,7 +24,7 @@ class ManualRulesController < ApplicationController
SECTION=Navigation::SECTION_CONFIGURATION
def index
- @rules = Rule.manual_rules()
+ @rules = Internal.rules.searchManualRules
render :action => 'index'
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_rules/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_rules/index.html.erb
index 43cd4f5ac40..e911fb46dea 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_rules/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_rules/index.html.erb
@@ -29,19 +29,19 @@
<% @rules.each do |rule| %>
<tr class="<%= cycle('even', 'odd') -%>">
<td class="left" nowrap>
- <%= h rule.name -%>
+ <%= h rule.name() -%>
&nbsp;&nbsp;
- <span class="note"><%= h rule.description -%></span>
+ <span class="note"><%= h rule.htmlDescription() -%></span>
</td>
<td class="right thin nowrap">
- <a id="edit-<%= u(rule.key) -%>" class="open-modal link-action" href="<%=ApplicationController.root_context-%>/manual_rules/edit_form?key=<%= h rule.key -%>">Edit</a>&nbsp;
- <%= link_to_action message('delete'), "#{ApplicationController.root_context}/manual_rules/delete?key=#{rule.key}",
+ <a id="edit-<%= u(rule.key().to_s) -%>" class="open-modal link-action" href="<%=ApplicationController.root_context-%>/manual_rules/edit_form?key=<%= h rule.key().to_s -%>">Edit</a>&nbsp;
+ <%= link_to_action message('delete'), "#{ApplicationController.root_context}/manual_rules/delete?key=#{rule.key().to_s}",
:class => 'link-action link-red',
- :id => "delete_#{rule.key.parameterize}",
+ :id => "delete_#{rule.key().to_s.parameterize}",
:confirm_button => message('delete'),
:confirm_title => message('manual_rules.delete_manual_rule'),
- :confirm_msg => message('manual_rules.delete_manual_rule_message', :params => [h(rule.name)]),
- :confirm_msg_params => [rule.name]
+ :confirm_msg => message('manual_rules.delete_manual_rule_message', :params => [h(rule.name())]),
+ :confirm_msg_params => [rule.name()]
-%>
</td>
</tr>