]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4785 Revert display of rule name if no issue message by migration of issues...
authorJulien Lancelot <julien.lancelot@gmail.com>
Sun, 9 Feb 2014 21:06:12 +0000 (22:06 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Sun, 9 Feb 2014 21:06:12 +0000 (22:06 +0100)
24 files changed:
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/issue.rb
sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/issues/_issues_list.html.erb
sonar-server/src/main/webapp/WEB-INF/db/migrate/497_update_issue_message_by_rule_name_when_no_message.rb [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/issue/ws/IssueShowWsHandlerTest.java
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_display_name_when_no_message.json [deleted file]
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_on_removed_component.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_on_removed_project_and_component.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_action_plan.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_actions.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_actions_defined_by_plugins.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_assign_to_me_action.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_changelog.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_characteristics.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_comments.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_dates.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_set_severity_action.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_technical_debt.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_transitions.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_users.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_without_assign_to_me_action.json

index f3a8c1ba9c12ffd7a8f630c63349700e6b9ff8c6..25a6abf2ff3adb9f8cb239199b40be5a65111485 100644 (file)
@@ -33,7 +33,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 496;
+  public static final int LAST_VERSION = 497;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index ac18bdeb6d3073cc911cfa2697b7c02ed50481d1..cd313dd28c1c2ab4eee76e4ffd8b9616ea4bf311 100644 (file)
@@ -207,6 +207,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('493');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('494');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('495');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('496');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('497');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index 1b8f0a5d2cce3c39e3c655fb9ced7306ba71a251..856a4a38c514b76395d4669a4d97acca89e0ba88 100644 (file)
@@ -47,7 +47,6 @@ import org.sonar.server.user.UserSession;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -97,8 +96,6 @@ public class IssueShowWsHandler implements RequestHandler {
   }
 
   private void writeIssue(IssueQueryResult result, DefaultIssue issue, JsonWriter json) {
-    String message = issue.message();
-    String ruleName = result.rule(issue).getName();
     Component component = result.component(issue);
     Component project = result.project(issue);
     String actionPlanKey = issue.actionPlanKey();
@@ -115,9 +112,9 @@ public class IssueShowWsHandler implements RequestHandler {
       .prop("project", issue.projectKey())
       .prop("projectLongName", project != null ? project.longName() : null)
       .prop("rule", issue.ruleKey().toString())
-      .prop("ruleName", ruleName)
+      .prop("ruleName", result.rule(issue).getName())
       .prop("line", issue.line())
-      .prop("message", message != null ? message : ruleName)
+      .prop("message",issue.message())
       .prop("resolution", issue.resolution())
       .prop("status", issue.status())
       .prop("severity", issue.severity())
index 21d65503aeb2e61b8874641f0a3409e16c0d77fd..7aa39a5161d32a3c5d642bcdd999cd9a56b5f6a3 100644 (file)
@@ -32,7 +32,7 @@ class Api::IssuesController < Api::ApiController
     hash = {
       :maxResultsReached => results.maxResultsReached,
       :paging => paging_to_hash(results.paging),
-      :issues => results.issues.map { |issue| Issue.to_hash(issue, results.rule(issue) ? results.rule(issue).name : nil) },
+      :issues => results.issues.map { |issue| Issue.to_hash(issue) },
       :components => results.components.map { |component| component_to_hash(component) },
       :projects => results.projects.map { |project| component_to_hash(project) },
       :rules => results.rules.map { |rule| Rule.to_hash(rule) },
index a3a34a3dd5dba207bfbd32fd48c0faf3f33cf339..0350bfbea9a892a9c1ca34d2f2e5b37c30adb13d 100644 (file)
@@ -30,7 +30,7 @@ class Issue
     }
     hash[:resolution] = issue.resolution if issue.resolution
     hash[:severity] = issue.severity if issue.severity
-    hash[:message] = issue.message ? issue.message : rule_name
+    hash[:message] = issue.message if issue.message
     hash[:line] = issue.line.to_i if issue.line
     hash[:effortToFix] = issue.effortToFix.to_f if issue.effortToFix
     hash[:technicalDebt] = technical_debt_to_hash(issue.technicalDebt) if issue.technicalDebt
index e72993ab6aeb82957159ec483bbd07af1f7aeb60..05ada28c9a7731442e64a15977a96cc8ccefb82d 100644 (file)
@@ -38,8 +38,7 @@
         <td><i class="icon-severity-<%= issue.severity.downcase -%>"></i></td>
         <td>
           <a class="rule-modal" href="#" onclick="return openModalWindow('<%= url_for :controller => 'issue', :action => 'show', :id => issue.key, :modal => true -%>', {'width': 800})">
-            <!-- SONAR-4785 Display rule name if issue has no message -->
-            <%= h truncate(issue.message ? issue.message : results.rule(issue).name, :length => 100) -%></a>
+            <%= h truncate(issue.message, :length => 100) -%></a>
           <% if last_comment %>
             <div class="comment-excerpt">
               <img src="<%= ApplicationController.root_context -%>/images/reviews/comment.png"/>
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/497_update_issue_message_by_rule_name_when_no_message.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/497_update_issue_message_by_rule_name_when_no_message.rb
new file mode 100644 (file)
index 0000000..e439888
--- /dev/null
@@ -0,0 +1,44 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# Sonar 4.2
+# SONAR-4785
+#
+class UpdateIssueMessageByRuleNameWhenNoMessage < ActiveRecord::Migration
+
+  class Rule < ActiveRecord::Base
+  end
+
+  class Issue < ActiveRecord::Base
+    belongs_to :rule, :class_name => 'Rule', :foreign_key => 'rule_id'
+  end
+
+  def self.up
+    issuesWithoutMessage = Issue.all(
+        :include => :rule,
+        :conditions => 'message IS NULL'
+    )
+    issuesWithoutMessage.each do |issue|
+      issue.message = issue.rule.name
+      issue.save!
+    end
+  end
+end
index c8337a872792501064ea8e57fa8da5bbfea5c558..aa2ec681d0b4a0563d8519690455d419a06e3507 100644 (file)
@@ -402,19 +402,6 @@ public class IssueShowWsHandlerTest {
     request.execute().assertJson(getClass(), "show_issue_with_changelog.json");
   }
 
-  /**
-   * SONAR-4785
-   */
-  @Test
-  public void show_issue_display_name_when_no_message() throws Exception {
-    Issue issue = createStandardIssue().setMessage(null);
-    issues.add(issue);
-
-    MockUserSession.set();
-    WsTester.TestRequest request = tester.newRequest("show").setParam("key", issue.key());
-    request.execute().assertJson(getClass(), "show_issue_display_name_when_no_message.json");
-  }
-
   private DefaultIssue createStandardIssue() {
     DefaultIssue issue = createIssue();
     addComponentAndProject();
@@ -424,7 +411,6 @@ public class IssueShowWsHandlerTest {
   private DefaultIssue createIssue() {
     return new DefaultIssue()
       .setKey("ABCD")
-      .setMessage("Fix it")
       .setComponentKey("org.sonar.server.issue.IssueClient")
       .setProjectKey("org.sonar.Sonar")
       .setRuleKey(RuleKey.of("squid", "AvoidCycle"))
diff --git a/sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_display_name_when_no_message.json b/sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_display_name_when_no_message.json
deleted file mode 100644 (file)
index 9865380..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-  "issue": {
-    "key": "ABCD",
-    "component": "org.sonar.server.issue.IssueClient",
-    "componentLongName": "SonarQube :: Issue Client",
-    "componentQualifier": "FIL",
-    "project": "org.sonar.Sonar",
-    "projectLongName": "SonarQube",
-    "rule": "squid:AvoidCycle",
-    "ruleName": "Avoid cycle",
-    "message": "Avoid cycle",
-    "creationDate": "2014-01-22T19:10:03+0100",
-    "fCreationDate": "Jan 22, 2014 10:03 AM",
-    "transitions": [],
-    "actions": [],
-    "comments": [],
-    "changelog": [
-      {
-        "creationDate": "2014-01-22T19:10:03+0100",
-        "fCreationDate": "Jan 22, 2014 10:03 AM",
-        "diffs": ["Created"]
-      }
-    ]
-  }
-}
index 0391e0c6e8d373b49276a857ae23491ced9ca45b..1f6563e1eac5841546a67f8fda33787f34498f1e 100644 (file)
@@ -6,7 +6,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
index 654ae679c04f0b7d5f7eab54966addf636601f1e..74542d5ed0ec8f91ee63fdaa05ac26ce9749628e 100644 (file)
@@ -5,7 +5,6 @@
     "project": "org.sonar.Sonar",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
index dead025099c942e08fef432e17a6707f552b4f54..49f7db8f8c06bab843c4ec8b40fbdac2d571754a 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "actionPlan" : "AP-ABCD",
     "actionPlanName" : "Version 4.2",
     "creationDate": "2014-01-22T19:10:03+0100",
index 14ceb5051cb4b332570381322bc8c48dee3b9333..011a92460cba11474dcfdccc6fb756ce1e8c0eff 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "status": "OPEN",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
index 0eed8b5cfcf1c5dd855129f9805d5bb59c2099cc..1b75cbc5b7cd876cbde2ec848859de9b6ddd0125 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "status": "OPEN",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
index 14ceb5051cb4b332570381322bc8c48dee3b9333..011a92460cba11474dcfdccc6fb756ce1e8c0eff 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "status": "OPEN",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
index 41349ce3d45f183a44dd56e3f40d0b53ee099512..35bc7c3ef599e3051d43ba6bf423f2fc59b5ce5c 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
index 41f351d840a78f50817cdbfdc0053165f0532d41..373ad27273ca0078130d890e455357db7b154b22 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "characteristic": "Maintainability",
     "subCharacteristic": "Readability",
     "creationDate": "2014-01-22T19:10:03+0100",
index 1e3a73b1c31b06922f24bfd1e0633dab06d1f5ff..1e863053a9bbeb65064655ef806089f4e4884ff4 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
index e08fdd0f33c67fdc756066a845b44d771a7d784e..67db98ec7c1e08d6ebcb5802b5f1b66905fb34e1 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
     "updateDate": "2014-01-23T19:10:03+0100",
index 60e5aeb58bb4135f855ade3b5bf95bc6c95e205c..9e2ce2a3daad4af9204ace84d97aefbbc61385e3 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "status": "OPEN",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
index 792e26128faa4ccd15a0ce222328a7510f95ef2e..f938630cfaa401b6d8bb5c4ffcc0afc982d17867 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "debt": "2 hours 1 minutes",
     "creationDate": "2014-01-22T19:10:03+0100",
     "fCreationDate": "Jan 22, 2014 10:03 AM",
index 2b0bda3f4d35acde7b5c964bc6a41146b44ce897..d7646909a37d0896ab4a74ba3b829b513cb95a03 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "status": "RESOLVED",
     "resolution": "FIXED",
     "creationDate": "2014-01-22T19:10:03+0100",
index f7c249e1ed526d1955cb678ceb7a1185ac642140..f26e887d9d65a93d202f1d77cba093dd6ca2c711 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "assignee": "john",
     "assigneeName": "John",
     "reporter": "steven",
index 93a38a2da05133bae7a46dd5dbee1770df4c0911..4adcdc4d5336d60e2a4ebe6775502807dfad3092 100644 (file)
@@ -8,7 +8,6 @@
     "projectLongName": "SonarQube",
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
-    "message": "Fix it",
     "assignee": "john",
     "assigneeName": "John",
     "status": "OPEN",