]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6364 Display CLOSED issues on top of the component viewer
authorStas Vilchik <vilchiks@gmail.com>
Tue, 31 Mar 2015 14:30:47 +0000 (16:30 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 31 Mar 2015 14:33:19 +0000 (16:33 +0200)
server/sonar-web/src/main/coffee/issue/models/issue.coffee
server/sonar-web/src/main/coffee/issues/component-viewer/main.coffee
server/sonar-web/src/main/js/source-viewer/viewer.js
server/sonar-web/src/main/less/pages/issues.less
server/sonar-web/src/test/js/source-viewer-issues.js [new file with mode: 0644]
server/sonar-web/src/test/json/source-viewer-issues/app.json [new file with mode: 0644]
server/sonar-web/src/test/json/source-viewer-issues/closed-issues.json [new file with mode: 0644]
server/sonar-web/src/test/json/source-viewer-issues/lines.json [new file with mode: 0644]

index e5f99dc2beda957db87663171fcedb0caa59dd35..ca21696a82a0ac067d4a98a406edb14e79c3f5a1 100644 (file)
@@ -30,3 +30,8 @@ define ->
 
     parse: (r) ->
       if r.issue then r.issue else r
+
+
+    getDisplayLine: ->
+      return 0 if @get('status') == 'CLOSED'
+      @get('line') || 0
index 76288c332d7b4773acba4791b44a869fde075892..335db3259710f6c7faca5e1bb38cfa2ea2b02900 100644 (file)
@@ -52,7 +52,7 @@ define [
       super
       @bindShortcuts()
       if @baseIssue?
-        @scrollToLine @baseIssue.get 'line'
+        @scrollToLine @baseIssue.getDisplayLine()
 
 
     bindShortcuts: ->
index 66600022fa284fe8a48d0fdc669d1b8df648bd20..b86c28532d3522a60d43fbb23b6bd01497d55d9a 100644 (file)
@@ -298,7 +298,7 @@ define([
           var that = this,
               lines = {};
           issues.forEach(function (issue) {
-            var line = issue.get('line') || 0;
+            var line = issue.getDisplayLine();
             if (!_.isArray(lines[line])) {
               lines[line] = [];
             }
index 0cc944a4c37d3893db6ba137cfe446feb7333894..90998f33aea5d46b8e09eb5b135ae120b4af6dfe 100644 (file)
 }
 
 .issues-workspace-home {
-  width: ~"calc(100vw - @{sideWidth})";
+  width: ~"calc(100vw - @{sideWidth} - 20px)";
   max-width: 900px;
   margin-left: auto;
   margin-right: auto;
diff --git a/server/sonar-web/src/test/js/source-viewer-issues.js b/server/sonar-web/src/test/js/source-viewer-issues.js
new file mode 100644 (file)
index 0000000..e1822a1
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 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.
+ */
+/* global casper:false */
+
+
+var lib = require('../lib'),
+    testName = lib.testName('Source Viewer', 'Issues');
+
+lib.initMessages();
+lib.changeWorkingDirectory('source-viewer-issues');
+lib.configureCasper();
+
+
+casper.test.begin(testName('Closed Issues on Top'), function (test) {
+  casper
+      .start(lib.buildUrl('source-viewer'), function () {
+        lib.setDefaultViewport();
+
+
+        lib.mockRequestFromFile('/api/components/app', 'app.json');
+        lib.mockRequestFromFile('/api/sources/lines', 'lines.json');
+        lib.mockRequestFromFile('/api/issues/search', 'closed-issues.json');
+      })
+
+      .then(function () {
+        casper.evaluate(function () {
+          require(['/js/source-viewer/app.js']);
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.source-line');
+      })
+
+      .then(function () {
+        casper.click('.source-line-with-issues[data-line-number="0"]');
+        lib.capture();
+        test.assertElementCount('.source-line-code[data-line-number="0"] .issue', 2);
+      })
+
+      .then(function () {
+        lib.sendCoverage();
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
diff --git a/server/sonar-web/src/test/json/source-viewer-issues/app.json b/server/sonar-web/src/test/json/source-viewer-issues/app.json
new file mode 100644 (file)
index 0000000..bfee785
--- /dev/null
@@ -0,0 +1,19 @@
+{
+  "uuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaaa",
+  "key": "sample:sample",
+  "path": "sample/path",
+  "name": "Sample",
+  "longName": "Sample",
+  "q": "FIL",
+  "subProject": "sample:subproject",
+  "subProjectName": "Sample Sub-Project",
+  "project": "sample:project",
+  "projectName": "Sample Project",
+  "fav": false,
+  "canMarkAsFavourite": true,
+  "canCreateManualIssue": true,
+  "measures": {
+    "lines": "20",
+    "duplicationDensity": "25%"
+  }
+}
diff --git a/server/sonar-web/src/test/json/source-viewer-issues/closed-issues.json b/server/sonar-web/src/test/json/source-viewer-issues/closed-issues.json
new file mode 100644 (file)
index 0000000..338a220
--- /dev/null
@@ -0,0 +1,256 @@
+{
+  "total": 4,
+  "p": 1,
+  "ps": 50,
+  "paging": {
+    "pageIndex": 1,
+    "pageSize": 50,
+    "total": 4,
+    "fTotal": "4",
+    "pages": 1
+  },
+  "projects": [
+    {
+      "uuid": "69e57151-be0d-4157-adff-c06741d88879",
+      "key": "org.codehaus.sonar:sonar",
+      "id": 2865,
+      "qualifier": "TRK",
+      "name": "SonarQube",
+      "longName": "SonarQube"
+    }
+  ],
+  "components": [
+    {
+      "uuid": "69e57151-be0d-4157-adff-c06741d88879",
+      "key": "org.codehaus.sonar:sonar",
+      "id": 2865,
+      "enabled": true,
+      "qualifier": "TRK",
+      "name": "SonarQube",
+      "longName": "SonarQube"
+    },
+    {
+      "uuid": "cff90ddb-b51f-4dab-808d-2891affa34d9",
+      "key": "org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/qualityprofile/RuleActivator.java",
+      "id": 31223,
+      "enabled": true,
+      "qualifier": "FIL",
+      "name": "RuleActivator.java",
+      "longName": "src/main/java/org/sonar/server/qualityprofile/RuleActivator.java",
+      "path": "src/main/java/org/sonar/server/qualityprofile/RuleActivator.java",
+      "projectId": 2865,
+      "subProjectId": 2872
+    },
+    {
+      "uuid": "e1f6f8bd-6b5f-4e2d-b936-4abffc9e4264",
+      "key": "org.codehaus.sonar:sonar-server",
+      "id": 2872,
+      "enabled": true,
+      "qualifier": "BRC",
+      "name": "SonarQube :: Server",
+      "longName": "SonarQube :: Server",
+      "path": "sonar-server",
+      "projectId": 2865,
+      "subProjectId": 2865
+    },
+    {
+      "uuid": "e0071532-a00c-4952-82ac-aed4afb10e5a",
+      "key": "org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java",
+      "id": 24253,
+      "enabled": false,
+      "qualifier": "FIL",
+      "name": "QProfileOperations.java",
+      "longName": "src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java",
+      "path": "src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java",
+      "projectId": 2865,
+      "subProjectId": 2872
+    }
+  ],
+  "issues": [
+    {
+      "key": "5b810e20-4c3b-46cf-8b30-3e613e425001",
+      "component": "org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java",
+      "componentId": 24253,
+      "project": "org.codehaus.sonar:sonar",
+      "rule": "squid:S1143",
+      "status": "CLOSED",
+      "resolution": "FIXED",
+      "severity": "BLOCKER",
+      "message": "Remove this return statement from this finally block.",
+      "line": 90,
+      "debt": "20min",
+      "assignee": "julien.lancelot",
+      "author": "julien.lancelot@sonarsource.com",
+      "actionPlan": "eaf2a3b4-e06f-4e8a-92ec-444f1cf68231",
+      "creationDate": "2013-12-13T23:55:31+0100",
+      "updateDate": "2013-12-16T16:42:32+0100",
+      "fUpdateAge": "about a year",
+      "closeDate": "2013-12-16T16:42:32+0100",
+      "tags": [
+        "bug"
+      ],
+      "actions": [],
+      "transitions": [],
+      "assigneeName": "Julien Lancelot",
+      "actionPlanName": "4.2"
+    },
+    {
+      "key": "04595b75-2063-43e4-bd61-f83818ee0520",
+      "component": "org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/qualityprofile/RuleActivator.java",
+      "componentId": 31223,
+      "project": "org.codehaus.sonar:sonar",
+      "subProject": "org.codehaus.sonar:sonar-server",
+      "rule": "squid:S2259",
+      "status": "CLOSED",
+      "resolution": "FIXED",
+      "severity": "BLOCKER",
+      "message": "NullPointerException might be thrown as 'activeRule' is nullable here",
+      "line": 274,
+      "debt": "10min",
+      "assignee": "simon.brandhof",
+      "author": "simon.brandhof@sonarsource.com",
+      "creationDate": "2015-03-26T23:08:38+0100",
+      "updateDate": "2015-03-30T16:41:19+0200",
+      "fUpdateAge": "24 hours",
+      "closeDate": "2015-03-30T16:41:19+0200",
+      "tags": [
+        "bug",
+        "cert",
+        "cwe",
+        "owasp-a1",
+        "owasp-a2",
+        "owasp-a6",
+        "security"
+      ],
+      "actions": [],
+      "transitions": [],
+      "assigneeName": "Simon Brandhof"
+    },
+    {
+      "key": "5a5f6572-cdaa-4f2d-bd26-4eab8a8eef03",
+      "component": "org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/qualityprofile/RuleActivator.java",
+      "componentId": 31223,
+      "project": "org.codehaus.sonar:sonar",
+      "subProject": "org.codehaus.sonar:sonar-server",
+      "rule": "squid:S2259",
+      "status": "OPEN",
+      "severity": "BLOCKER",
+      "message": "NullPointerException might be thrown as 'activeRuleParamsAsMap' is nullable here",
+      "line": 4,
+      "debt": "10min",
+      "assignee": "simon.brandhof",
+      "author": "simon.brandhof@sonarsource.com",
+      "creationDate": "2015-03-26T23:08:38+0100",
+      "updateDate": "2015-03-26T23:08:38+0100",
+      "fUpdateAge": "4 days",
+      "tags": [
+        "bug",
+        "cert",
+        "cwe",
+        "owasp-a1",
+        "owasp-a2",
+        "owasp-a6",
+        "security"
+      ],
+      "actions": [],
+      "transitions": [],
+      "assigneeName": "Simon Brandhof"
+    },
+    {
+      "key": "2c69b917-a156-4638-a398-969916e29053",
+      "component": "org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/qualityprofile/RuleActivator.java",
+      "componentId": 31223,
+      "project": "org.codehaus.sonar:sonar",
+      "subProject": "org.codehaus.sonar:sonar-server",
+      "rule": "squid:S2259",
+      "status": "OPEN",
+      "severity": "BLOCKER",
+      "message": "NullPointerException might be thrown as 'activeRule' is nullable here",
+      "line": 5,
+      "debt": "10min",
+      "assignee": "simon.brandhof",
+      "author": "simon.brandhof@sonarsource.com",
+      "creationDate": "2015-03-26T23:08:38+0100",
+      "updateDate": "2015-03-26T23:08:38+0100",
+      "fUpdateAge": "4 days",
+      "tags": [
+        "bug",
+        "cert",
+        "cwe",
+        "owasp-a1",
+        "owasp-a2",
+        "owasp-a6",
+        "security"
+      ],
+      "actions": [],
+      "transitions": [],
+      "assigneeName": "Simon Brandhof"
+    }
+  ],
+  "rules": [
+    {
+      "key": "squid:S1143",
+      "name": "Return statements should not occur in finally blocks",
+      "lang": "java",
+      "desc": "",
+      "status": "READY",
+      "langName": "Java"
+    },
+    {
+      "key": "squid:S2259",
+      "name": "Null pointers should not be dereferenced",
+      "lang": "java",
+      "desc": "",
+      "status": "REMOVED",
+      "langName": "Java"
+    }
+  ],
+  "users": [
+    {
+      "login": "julien.lancelot",
+      "name": "Julien Lancelot",
+      "active": true,
+      "email": "julien.lancelot@sonarsource.com"
+    },
+    {
+      "login": "simon.brandhof",
+      "name": "Simon Brandhof",
+      "active": true,
+      "email": "simon.brandhof@sonarsource.com"
+    }
+  ],
+  "actionPlans": [
+    {
+      "key": "eaf2a3b4-e06f-4e8a-92ec-444f1cf68231",
+      "name": "4.2",
+      "status": "CLOSED",
+      "project": "org.codehaus.sonar:sonar",
+      "userLogin": "fabrice.bellingard",
+      "deadLine": "2014-01-31T00:00:00+0100",
+      "fDeadLine": "Jan 31, 2014 12:00 AM",
+      "createdAt": "2013-12-11T08:35:23+0100",
+      "fCreatedAt": "Dec 11, 2013 8:35 AM",
+      "updatedAt": "2014-04-14T11:55:03+0200",
+      "fUpdatedAt": "Apr 14, 2014 11:55 AM"
+    }
+  ],
+  "languages": [
+    {
+      "key": "py",
+      "name": "Python"
+    },
+    {
+      "key": "js",
+      "name": "JavaScript"
+    },
+    {
+      "key": "php",
+      "name": "PHP"
+    },
+    {
+      "key": "java",
+      "name": "Java"
+    }
+  ],
+  "facets": []
+}
diff --git a/server/sonar-web/src/test/json/source-viewer-issues/lines.json b/server/sonar-web/src/test/json/source-viewer-issues/lines.json
new file mode 100644 (file)
index 0000000..5fc7b0c
--- /dev/null
@@ -0,0 +1,22 @@
+{"sources": [
+  { "line": 1,  "code": "line 1" },
+  { "line": 2,  "code": "line 2" },
+  { "line": 3,  "code": "line 3" },
+  { "line": 4,  "code": "line 4" },
+  { "line": 5,  "code": "line 5" },
+  { "line": 6,  "code": "line 6" },
+  { "line": 7,  "code": "line 7" },
+  { "line": 8,  "code": "line 8" },
+  { "line": 9,  "code": "line 9" },
+  { "line": 10, "code": "line 10" },
+  { "line": 11, "code": "line 11", "duplicated": true },
+  { "line": 12, "code": "line 12", "duplicated": true },
+  { "line": 13, "code": "line 13", "duplicated": true },
+  { "line": 14, "code": "line 14", "duplicated": true },
+  { "line": 15, "code": "line 15", "duplicated": true },
+  { "line": 16, "code": "line 16" },
+  { "line": 17, "code": "line 17" },
+  { "line": 18, "code": "line 18" },
+  { "line": 19, "code": "line 19" },
+  { "line": 20, "code": "line 20" }
+]}