]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5479 Allow to filter on Lines and Lines of Code in the Component Viewer
authorStas Vilchik <vilchiks@gmail.com>
Tue, 29 Jul 2014 09:52:39 +0000 (11:52 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 29 Jul 2014 09:52:46 +0000 (11:52 +0200)
Do not show ncloc filter if there is no ncloc_data

server/sonar-web/src/main/hbs/component-viewer/header/cw-basic-header.hbs
server/sonar-web/src/main/js/tests/e2e/tests/component-viewer-lines-filters-spec.js
server/sonar-web/src/main/js/tests/e2e/tests/component-viewer-spec/resources-without-ncloc-data.json [new file with mode: 0644]

index 32cd2c1730f0f113f47c924c710912605c8e1818..b108d744d005392a572137047b113c300787eee8 100644 (file)
@@ -5,7 +5,7 @@
     </div>
     <ul class="component-viewer-header-expanded-bar-section-list">
       {{{componentViewerHeaderLink lines 'lines' 'js-filter-lines'}}}
-      {{#if 'ncloc_data'}}
+      {{#if ncloc_data}}
         {{{componentViewerHeaderLink ncloc 'ncloc' 'js-filter-ncloc'}}}
       {{else}}
         {{{componentViewerHeaderItem ncloc 'ncloc'}}}
index d2470ccc8a9ce14809799791daf33c60f6fab8d5..2960f784d25460fa9d406203f960b345fccfc4ba 100644 (file)
@@ -38,3 +38,32 @@ casper.test.begin(testName('Lines Filters'), function (test) {
         test.done();
       });
 });
+
+
+casper.test.begin(testName('Do Not Show Ncloc Filter If No Data'), function (test) {
+  casper
+      .start(lib.buildUrl('component-viewer#component=component'), function () {
+        lib.setDefaultViewport();
+        lib.mockRequest('/api/l10n/index', '{}');
+        lib.mockRequestFromFile('/api/components/app', 'app.json');
+        lib.mockRequestFromFile('/api/sources/show', 'source.json');
+        lib.mockRequestFromFile('/api/resources', 'resources-without-ncloc-data.json');
+      })
+
+      .then(function () {
+        casper.waitForSelector('.component-viewer-source .row');
+      })
+
+      .then(function () {
+        casper.click('.js-header-tab-basic');
+        casper.waitForSelector('[data-metric="ncloc"]');
+      })
+
+      .then(function () {
+        test.assertDoesntExist('.js-filter-ncloc');
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/component-viewer-spec/resources-without-ncloc-data.json b/server/sonar-web/src/main/js/tests/e2e/tests/component-viewer-spec/resources-without-ncloc-data.json
new file mode 100644 (file)
index 0000000..dfbacdf
--- /dev/null
@@ -0,0 +1,150 @@
+[
+  {
+    "id": 19983,
+    "key": "org.codehaus.sonar:sonar-batch:src/main/java/org/sonar/batch/index/Cache.java",
+    "name": "Cache.java",
+    "scope": "FIL",
+    "qualifier": "FIL",
+    "date": "2014-07-21T23:18:51+0200",
+    "creationDate": "2013-04-17T04:06:45+0200",
+    "lname": "src/main/java/org/sonar/batch/index/Cache.java",
+    "lang": "java",
+    "msr": [
+      {
+        "key": "lines",
+        "val": 519.0,
+        "frmt_val": "519"
+      },
+      {
+        "key": "ncloc",
+        "val": 379.0,
+        "frmt_val": "379"
+      },
+      {
+        "key": "classes",
+        "val": 6.0,
+        "frmt_val": "6"
+      },
+      {
+        "key": "functions",
+        "val": 56.0,
+        "frmt_val": "56"
+      },
+      {
+        "key": "accessors",
+        "val": 0.0,
+        "frmt_val": "0"
+      },
+      {
+        "key": "statements",
+        "val": 174.0,
+        "frmt_val": "174"
+      },
+      {
+        "key": "public_api",
+        "val": 33.0,
+        "frmt_val": "33"
+      },
+      {
+        "key": "comment_lines",
+        "val": 23.0,
+        "frmt_val": "23"
+      },
+      {
+        "key": "comment_lines_density",
+        "val": 5.7,
+        "frmt_val": "5.7%"
+      },
+      {
+        "key": "public_documented_api_density",
+        "val": 36.4,
+        "frmt_val": "36.4%"
+      },
+      {
+        "key": "public_undocumented_api",
+        "val": 21.0,
+        "frmt_val": "21"
+      },
+      {
+        "key": "complexity",
+        "val": 116.0,
+        "frmt_val": "116"
+      },
+      {
+        "key": "function_complexity",
+        "val": 2.1,
+        "frmt_val": "2.1"
+      },
+      {
+        "key": "coverage",
+        "val": 74.3,
+        "frmt_val": "74.3%"
+      },
+      {
+        "key": "lines_to_cover",
+        "val": 194.0,
+        "frmt_val": "194"
+      },
+      {
+        "key": "uncovered_lines",
+        "val": 50.0,
+        "frmt_val": "50"
+      },
+      {
+        "key": "line_coverage",
+        "val": 74.2,
+        "frmt_val": "74.2%"
+      },
+      {
+        "key": "conditions_to_cover",
+        "val": 16.0,
+        "frmt_val": "16"
+      },
+      {
+        "key": "uncovered_conditions",
+        "val": 4.0,
+        "frmt_val": "4"
+      },
+      {
+        "key": "branch_coverage",
+        "val": 75.0,
+        "frmt_val": "75.0%"
+      },
+      {
+        "key": "duplicated_lines",
+        "val": 30.0,
+        "frmt_val": "30"
+      },
+      {
+        "key": "duplicated_blocks",
+        "val": 2.0,
+        "frmt_val": "2"
+      },
+      {
+        "key": "duplicated_files",
+        "val": 1.0,
+        "frmt_val": "1"
+      },
+      {
+        "key": "duplicated_lines_density",
+        "val": 5.8,
+        "frmt_val": "5.8%"
+      },
+      {
+        "key": "major_violations",
+        "val": 1.0,
+        "frmt_val": "1"
+      },
+      {
+        "key": "minor_violations",
+        "val": 1.0,
+        "frmt_val": "1"
+      },
+      {
+        "key": "info_violations",
+        "val": 4.0,
+        "frmt_val": "4"
+      }
+    ]
+  }
+]